Skip to content

Commit

Permalink
inline repeat instances should inherit assets even in strict mode (fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 27, 2015
1 parent 8184a95 commit d281abd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/directives/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = {
// default constructor
this.Ctor = _.Vue
// inline repeats should inherit
this.inherit = true
this.inline = true
// important: transclude with no options, just
// to ensure block start and block end
this.template = compiler.transclude(this.template)
Expand Down Expand Up @@ -370,12 +370,12 @@ module.exports = {
var vm = parent.$addChild({
el: templateParser.clone(this.template),
data: data,
inherit: this.inherit,
inherit: this.inline,
template: this.inlineTemplate,
// repeater meta, e.g. $index, $key
_meta: meta,
// mark this as an inline-repeat instance
_repeat: this.inherit,
_repeat: this.inline,
// is this a component?
_asComponent: this.asComponent,
// linker cachable if no inline-template
Expand Down
5 changes: 4 additions & 1 deletion src/util/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ exports.mergeOptions = function merge (parent, child, vm) {

exports.resolveAsset = function resolve (options, type, id) {
var asset = options[type][id]
while (!config.strict && !asset && options._parent) {
while (
!asset && options._parent &&
(!config.strict || options._repeat)
) {
options = options._parent.$options
asset = options[type][id]
}
Expand Down
19 changes: 19 additions & 0 deletions test/unit/specs/misc_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@ describe('Misc', function () {
Vue.config.strict = false
})

it('strict mode for repeat instances', function () {
Vue.config.strict = true
var vm = new Vue({
el: document.createElement('div'),
template: '<div v-repeat="list"><test></test></div>',
data: {
list: [1, 2]
},
components: {
test: {
template: 'hi'
}
}
})
expect(_.warn).not.toHaveBeenCalled()
expect(vm.$el.textContent).toBe('hihi')
Vue.config.strict = false
})

it('class interpolation and v-class should work together', function (done) {
var el = document.createElement('div')
el.setAttribute('class', 'a {{classB}}')
Expand Down

0 comments on commit d281abd

Please sign in to comment.