+35
-2
lines changedFilter options
+35
-2
lines changed Original file line number Diff line number Diff line change
@@ -260,9 +260,14 @@ export function createPatchFunction (backend) {
260
260
// of going through the normal attribute patching process.
261
261
function setScope (vnode) {
262
262
let i
263
-
if (isDef(i = vnode.context) && isDef(i = i.$options._scopeId)) {
264
-
nodeOps.setAttribute(vnode.elm, i, '')
263
+
let ancestor = vnode
264
+
while (ancestor) {
265
+
if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
266
+
nodeOps.setAttribute(vnode.elm, i, '')
267
+
}
268
+
ancestor = ancestor.parent
265
269
}
270
+
// for slot content they should also get the scopeId from the host instance.
266
271
if (isDef(i = activeInstance) &&
267
272
i !== vnode.context &&
268
273
isDef(i = i.$options._scopeId)) {
Original file line number Diff line number Diff line change
@@ -40,4 +40,32 @@ describe('Options _scopeId', () => {
40
40
expect(vm.$el.children[0].children[0].hasAttribute('foo')).toBe(true)
41
41
expect(vm.$el.children[0].children[0].hasAttribute('bar')).toBe(true)
42
42
})
43
+
44
+
// #4774
45
+
it('should not discard parent scopeId when component root element is replaced', done => {
46
+
const vm = new Vue({
47
+
_scopeId: 'data-1',
48
+
template: `<div><child ref="child" /></div>`,
49
+
components: {
50
+
child: {
51
+
_scopeId: 'data-2',
52
+
data: () => ({ show: true }),
53
+
template: '<div v-if="show"></div>'
54
+
}
55
+
}
56
+
}).$mount()
57
+
58
+
const child = vm.$refs.child
59
+
60
+
expect(child.$el.hasAttribute('data-1')).toBe(true)
61
+
expect(child.$el.hasAttribute('data-2')).toBe(true)
62
+
63
+
child.show = false
64
+
waitForUpdate(() => {
65
+
child.show = true
66
+
}).then(() => {
67
+
expect(child.$el.hasAttribute('data-1')).toBe(true)
68
+
expect(child.$el.hasAttribute('data-2')).toBe(true)
69
+
}).then(done)
70
+
})
43
71
})
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4