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', () => {
const Foo = defineComponent({
render() {},
let hasExtends = false
if (__FEATURE_OPTIONS_API__ && !isFunction(comp)) {
const extendEmits = (raw: ComponentOptions) => {
- hasExtends = true
- extend(normalized, normalizeEmitsOptions(raw, appContext, true))
+ const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true)
+ if (normalizedFromExtend) {
+ hasExtends = true
+ extend(normalized, normalizedFromExtend)
+ }
}
if (!asMixin && appContext.mixins.length) {
appContext.mixins.forEach(extendEmits)