|
|
@@ -40,4 +40,32 @@ describe('Options _scopeId', () => {
|
|
|
expect(vm.$el.children[0].children[0].hasAttribute('foo')).toBe(true)
|
|
|
expect(vm.$el.children[0].children[0].hasAttribute('bar')).toBe(true)
|
|
|
})
|
|
|
+
|
|
|
+ // #4774
|
|
|
+ it('should not discard parent scopeId when component root element is replaced', done => {
|
|
|
+ const vm = new Vue({
|
|
|
+ _scopeId: 'data-1',
|
|
|
+ template: `<div><child ref="child" /></div>`,
|
|
|
+ components: {
|
|
|
+ child: {
|
|
|
+ _scopeId: 'data-2',
|
|
|
+ data: () => ({ show: true }),
|
|
|
+ template: '<div v-if="show"></div>'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).$mount()
|
|
|
+
|
|
|
+ const child = vm.$refs.child
|
|
|
+
|
|
|
+ expect(child.$el.hasAttribute('data-1')).toBe(true)
|
|
|
+ expect(child.$el.hasAttribute('data-2')).toBe(true)
|
|
|
+
|
|
|
+ child.show = false
|
|
|
+ waitForUpdate(() => {
|
|
|
+ child.show = true
|
|
|
+ }).then(() => {
|
|
|
+ expect(child.$el.hasAttribute('data-1')).toBe(true)
|
|
|
+ expect(child.$el.hasAttribute('data-2')).toBe(true)
|
|
|
+ }).then(done)
|
|
|
+ })
|
|
|
})
|