mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-02 12:07:39 +08:00
avoid merging text nodes when the node is a cloned slot node (fix #4209)
This commit is contained in:
parent
02620c928f
commit
eb92723df5
@ -28,7 +28,9 @@ export function normalizeChildren (
|
||||
}
|
||||
} else if (c instanceof VNode) {
|
||||
if (c.text && last && last.text) {
|
||||
last.text += c.text
|
||||
if (!last.isCloned) {
|
||||
last.text += c.text
|
||||
}
|
||||
} else {
|
||||
// inherit parent namespace
|
||||
if (ns) {
|
||||
|
@ -574,4 +574,27 @@ describe('Component slot', () => {
|
||||
}).$mount()
|
||||
expect(vm.$el.innerHTML.trim()).toBe('<div>two</div><div>one</div>')
|
||||
})
|
||||
|
||||
// #4209
|
||||
it('slot of multiple text nodes should not be infinitely merged', done => {
|
||||
const wrap = {
|
||||
template: `<inner ref="inner">foo<slot></slot></inner>`,
|
||||
components: {
|
||||
inner: {
|
||||
data: () => ({ a: 1 }),
|
||||
template: `<div>{{a}}<slot></slot></div>`
|
||||
}
|
||||
}
|
||||
}
|
||||
const vm = new Vue({
|
||||
template: `<wrap ref="wrap">bar</wrap>`,
|
||||
components: { wrap }
|
||||
}).$mount()
|
||||
|
||||
expect(vm.$el.textContent).toBe('1foobar')
|
||||
vm.$refs.wrap.$refs.inner.a++
|
||||
waitForUpdate(() => {
|
||||
expect(vm.$el.textContent).toBe('2foobar')
|
||||
}).then(done)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user