Browse Source

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

dev
Evan You 8 years ago
parent
commit
09f9783943
  1. 5
      src/core/instance/init.js
  2. 14
      test/unit/features/global-api/mixin.spec.js

5
src/core/instance/init.js

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

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

@ -56,4 +56,18 @@ describe('Global API: mixin', () => {
expect(vm.$el.textContent).toBe('hi') 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')
})
}) })

Loading…
Cancel
Save