parent
d5824b97c5
commit
60d777d228
@ -175,6 +175,21 @@ describe('component: emit', () => {
|
|||||||
expect(`event validation failed for event "foo"`).toHaveBeenWarned()
|
expect(`event validation failed for event "foo"`).toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #2651
|
||||||
|
test('should not attach normalized object when mixins do not contain emits', () => {
|
||||||
|
const Foo = defineComponent({
|
||||||
|
mixins: [{}],
|
||||||
|
render() {},
|
||||||
|
created() {
|
||||||
|
this.$emit('foo')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
render(h(Foo), nodeOps.createElement('div'))
|
||||||
|
expect(
|
||||||
|
`Component emitted event "foo" but it is neither declared`
|
||||||
|
).not.toHaveBeenWarned()
|
||||||
|
})
|
||||||
|
|
||||||
test('.once', () => {
|
test('.once', () => {
|
||||||
const Foo = defineComponent({
|
const Foo = defineComponent({
|
||||||
render() {},
|
render() {},
|
||||||
|
@ -165,8 +165,11 @@ export function normalizeEmitsOptions(
|
|||||||
let hasExtends = false
|
let hasExtends = false
|
||||||
if (__FEATURE_OPTIONS_API__ && !isFunction(comp)) {
|
if (__FEATURE_OPTIONS_API__ && !isFunction(comp)) {
|
||||||
const extendEmits = (raw: ComponentOptions) => {
|
const extendEmits = (raw: ComponentOptions) => {
|
||||||
hasExtends = true
|
const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true)
|
||||||
extend(normalized, normalizeEmitsOptions(raw, appContext, true))
|
if (normalizedFromExtend) {
|
||||||
|
hasExtends = true
|
||||||
|
extend(normalized, normalizedFromExtend)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!asMixin && appContext.mixins.length) {
|
if (!asMixin && appContext.mixins.length) {
|
||||||
appContext.mixins.forEach(extendEmits)
|
appContext.mixins.forEach(extendEmits)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user