Skip to content

Commit d281abd

Browse files
committed
inline repeat instances should inherit assets even in strict mode (fix #1080)
1 parent 8184a95 commit d281abd

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

src/directives/repeat.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module.exports = {
107107
// default constructor
108108
this.Ctor = _.Vue
109109
// inline repeats should inherit
110-
this.inherit = true
110+
this.inline = true
111111
// important: transclude with no options, just
112112
// to ensure block start and block end
113113
this.template = compiler.transclude(this.template)
@@ -370,12 +370,12 @@ module.exports = {
370370
var vm = parent.$addChild({
371371
el: templateParser.clone(this.template),
372372
data: data,
373-
inherit: this.inherit,
373+
inherit: this.inline,
374374
template: this.inlineTemplate,
375375
// repeater meta, e.g. $index, $key
376376
_meta: meta,
377377
// mark this as an inline-repeat instance
378-
_repeat: this.inherit,
378+
_repeat: this.inline,
379379
// is this a component?
380380
_asComponent: this.asComponent,
381381
// linker cachable if no inline-template

src/util/options.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ exports.mergeOptions = function merge (parent, child, vm) {
341341

342342
exports.resolveAsset = function resolve (options, type, id) {
343343
var asset = options[type][id]
344-
while (!config.strict && !asset && options._parent) {
344+
while (
345+
!asset && options._parent &&
346+
(!config.strict || options._repeat)
347+
) {
345348
options = options._parent.$options
346349
asset = options[type][id]
347350
}

test/unit/specs/misc_spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,25 @@ describe('Misc', function () {
244244
Vue.config.strict = false
245245
})
246246

247+
it('strict mode for repeat instances', function () {
248+
Vue.config.strict = true
249+
var vm = new Vue({
250+
el: document.createElement('div'),
251+
template: '<div v-repeat="list"><test></test></div>',
252+
data: {
253+
list: [1, 2]
254+
},
255+
components: {
256+
test: {
257+
template: 'hi'
258+
}
259+
}
260+
})
261+
expect(_.warn).not.toHaveBeenCalled()
262+
expect(vm.$el.textContent).toBe('hihi')
263+
Vue.config.strict = false
264+
})
265+
247266
it('class interpolation and v-class should work together', function (done) {
248267
var el = document.createElement('div')
249268
el.setAttribute('class', 'a {{classB}}')

0 commit comments

Comments
 (0)