Explorar o código

global mixin should not drop scope id (fix #4266) (#4274)

katashin %!s(int64=9) %!d(string=hai) anos
pai
achega
c57ba3e622
Modificáronse 2 ficheiros con 15 adicións e 0 borrados
  1. 1 0
      src/core/instance/init.js
  2. 14 0
      test/unit/features/global-api/mixin.spec.js

+ 1 - 0
src/core/instance/init.js

@@ -72,6 +72,7 @@ export function resolveConstructorOptions (Ctor: Class<Component>) {
       Ctor.superOptions = superOptions
       extendOptions.render = options.render
       extendOptions.staticRenderFns = options.staticRenderFns
+      extendOptions._scopeId = options._scopeId
       options = Ctor.options = mergeOptions(superOptions, extendOptions)
       if (options.name) {
         options.components[options.name] = Ctor

+ 14 - 0
test/unit/features/global-api/mixin.spec.js

@@ -70,4 +70,18 @@ describe('Global API: mixin', () => {
 
     expect(vm.$el.textContent).toBe('hello')
   })
+
+  // #4266
+  it('should not drop scopedId', () => {
+    const Test = Vue.extend({})
+    Test.options._scopeId = 'foo'
+
+    Vue.mixin({})
+
+    const vm = new Test({
+      template: '<div><p>hi<p></div>'
+    }).$mount()
+
+    expect(vm.$el.children[0].hasAttribute('foo')).toBe(true)
+  })
 })