Skip to content

Commit 1166f87

Browse files
committed
optimize v-repeat with component using new transclude logic
1 parent 154c845 commit 1166f87

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/compiler/transclude.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ function insertContentAt (outlet, contents) {
188188
*/
189189

190190
function extractAttrs (attrs) {
191+
if (!attrs) return null
191192
var res = {}
192193
var vwith = config.prefix + 'with'
193194
var i = attrs.length

src/directives/repeat.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,14 @@ module.exports = {
107107
if (!tokens) { // static component
108108
var Ctor = this.Ctor = options.components[id]
109109
_.assertAsset(Ctor, 'component', id)
110-
// If there's no parent scope directives and no
111-
// content to be transcluded, we can optimize the
112-
// rendering by pre-transcluding + compiling here
113-
// and provide a link function to every instance.
114-
if (!this.el.hasChildNodes() &&
115-
!this.el.hasAttributes()) {
116-
// merge an empty object with owner vm as parent
117-
// so child vms can access parent assets.
118-
var merged = mergeOptions(Ctor.options, {}, {
119-
$parent: this.vm
120-
})
121-
merged.template = this.inlineTempalte || merged.template
122-
this.template = transclude(this.template, merged)
123-
this._linkFn = compile(this.template, merged)
124-
}
110+
var merged = mergeOptions(Ctor.options, {}, {
111+
$parent: this.vm
112+
})
113+
merged.template = this.inlineTempalte || merged.template
114+
merged._asComponent = true
115+
merged._parent = this.vm
116+
this.template = transclude(this.template, merged)
117+
this._linkFn = compile(this.template, merged)
125118
} else {
126119
// to be resolved later
127120
var ctorExp = textParser.tokensToExp(tokens)

0 commit comments

Comments
 (0)