Răsfoiți Sursa

fix global mixin + export constructor in vue-loader (fix vue-loader#433)

Evan You 9 ani în urmă
părinte
comite
09f9783943
2 a modificat fișierele cu 18 adăugiri și 1 ștergeri
  1. 4 1
      src/core/instance/init.js
  2. 14 0
      test/unit/features/global-api/mixin.spec.js

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

@@ -66,10 +66,13 @@ export function resolveConstructorOptions (Ctor: Class<Component>) {
   if (Ctor.super) {
     const superOptions = Ctor.super.options
     const cachedSuperOptions = Ctor.superOptions
+    const extendOptions = Ctor.extendOptions
     if (superOptions !== cachedSuperOptions) {
       // super option changed
       Ctor.superOptions = superOptions
-      options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions)
+      extendOptions.render = options.render
+      extendOptions.staticRenderFns = options.staticRenderFns
+      options = Ctor.options = mergeOptions(superOptions, extendOptions)
       if (options.name) {
         options.components[options.name] = Ctor
       }

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

@@ -56,4 +56,18 @@ describe('Global API: mixin', () => {
 
     expect(vm.$el.textContent).toBe('hi')
   })
+
+  // vue-loader#433
+  it('should not drop late-set render functions', () => {
+    const Test = Vue.extend({})
+    Test.options.render = h => h('div', 'hello')
+
+    Vue.mixin({})
+
+    const vm = new Vue({
+      render: h => h(Test)
+    }).$mount()
+
+    expect(vm.$el.textContent).toBe('hello')
+  })
 })