app.component('BarBaz', () => 'barbaz!')
+ app.component('BarBaz', () => 'barbaz!')
+ expect(
+ 'Component "BarBaz" has already been registered in target app.'
+ ).toHaveBeenWarnedTimes(1)
+
const Root = {
// local override
components: {
mounted: spy2
})
+ app.directive('BarBaz', {
+ mounted: spy2
+ })
+ expect(
+ 'Directive "BarBaz" has already been registered in target app.'
+ ).toHaveBeenWarnedTimes(1)
+
const Root = {
// local override
directives: {
}
}
const mixinB = {
+ name: 'mixinB',
data() {
return {
b: 2
app.mixin(mixinA)
app.mixin(mixinB)
+ app.mixin(mixinA)
+ app.mixin(mixinB)
+ expect(
+ 'Mixin has already been applied to target app'
+ ).toHaveBeenWarnedTimes(2)
+ expect(
+ 'Mixin has already been applied to target app: mixinB'
+ ).toHaveBeenWarnedTimes(1)
+
const root = nodeOps.createElement('div')
app.mount(Comp, root)
},
mixin(mixin: ComponentOptions) {
- context.mixins.push(mixin)
+ if (__DEV__ && !__FEATURE_OPTIONS__) {
+ warn('Mixins are only available in builds supporting Options API')
+ }
+
+ if (!context.mixins.includes(mixin)) {
+ context.mixins.push(mixin)
+ } else if (__DEV__) {
+ warn(
+ 'Mixin has already been applied to target app' +
+ (mixin.name ? `: ${mixin.name}` : '')
+ )
+ }
+
return app
},
if (!component) {
return context.components[name]
} else {
+ if (__DEV__ && context.components[name]) {
+ warn(
+ `Component "${name}" has already been registered in target app.`
+ )
+ }
context.components[name] = component
return app
}
if (!directive) {
return context.directives[name] as any
} else {
+ if (__DEV__ && context.directives[name]) {
+ warn(
+ `Directive "${name}" has already been registered in target app.`
+ )
+ }
context.directives[name] = directive
return app
}