Skip to content

Commit d973de6

Browse files
committed
feat: remove warn intercept
1 parent 431452e commit d973de6

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

src/emitMixin.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,11 @@ function createDevTools(events) {
2929
}
3030

3131
function recordEvent(events, event, args) {
32+
// Record the event message sent by the emit
33+
// Stored by a vm
34+
// emitted by a subsequent wrapper.emitted
35+
// An event object and a vm.__emitted is a reference
3236
events[event]
3337
? (events[event] = [...events[event], [...args]])
3438
: (events[event] = [[...args]])
3539
}
36-
37-
// Vue will warn you if you emit an event that is not declared in `emits` and
38-
// if the parent is not listening for that event.
39-
// since we intercept the event, we are never listening for it explicitly on the
40-
// Parent component. Swallow those events then restore the console.warn.
41-
// TODO: find out if this is doable using `app.config.warnHandler` (does not appear
42-
// work right now). https://github.com/vuejs/vue-test-utils-next/issues/197
43-
function wrapperWarn() {
44-
const consoleWarnSave = console.warn
45-
console.warn = (msg: string, ...rest: unknown[]) => {
46-
if (msg.includes('[Vue warn]: Component emitted event')) {
47-
return
48-
} else {
49-
consoleWarnSave(msg, ...rest)
50-
}
51-
}
52-
console.warn = consoleWarnSave
53-
}

tests/mountingOptions/props.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ describe('mountingOptions.props', () => {
7272

7373
test('assigns event listeners', async () => {
7474
const Component = {
75+
emits: ['customEvent'],
7576
template: '<button @click="$emit(\'customEvent\', true)">Click</button>'
7677
}
7778
const onCustomEvent = jest.fn()

tests/setValue.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ describe('setValue', () => {
180180

181181
describe('on component instance', () => {
182182
const PlainInputComponent = defineComponent({
183-
props: ['modelValue'],
183+
props: ['modelValue', 'onUpdate:modelValue'],
184184
template: '<div>{{ modelValue }}</div>'
185185
})
186186

187187
const MultiInputComponent = defineComponent({
188-
props: ['foo', 'bar'],
188+
props: ['foo', 'bar', 'onUpdate:bar', 'onUpdate:foo'],
189189
template: '<div>{{ foo }} {{ bar }}</div>'
190190
})
191191

0 commit comments

Comments
 (0)