Skip to content

Commit

Permalink
Fix handling v-if along with v-for on a template tag (vuejs#2663)
Browse files Browse the repository at this point in the history
* Fix handling multiple directives on a template tag

* Use a simpler check
  • Loading branch information
simplesmiler authored and yyx990803 committed Apr 13, 2016
1 parent 219b80b commit f28260a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fragment/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function FragmentFactory (vm, el) {
this.vm = vm
var template
var isString = typeof el === 'string'
if (isString || isTemplate(el)) {
if (isString || isTemplate(el) && !el.hasAttribute('v-if')) {
template = parseTemplate(el, true)
} else {
template = document.createDocumentFragment()
Expand Down
9 changes: 9 additions & 0 deletions test/unit/specs/misc_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,4 +537,13 @@ describe('Misc', function () {
})
expect(vm.$el.querySelector('image-field').namespaceURI).not.toMatch(/svg/)
})

// #2657
it('template v-for with v-if', function () {
var vm = new Vue({
el: document.createElement('div'),
template: '<div><template v-for="n in 6" v-if="n % 2">{{ n }}</template></div>'
})
expect(vm.$el.textContent).toBe('135')
})
})

0 comments on commit f28260a

Please sign in to comment.