Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-vapor): properly normalize emits options if emits is an array #12614

Open
wants to merge 3 commits into
base: vapor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions packages/runtime-vapor/__tests__/componentEmits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,17 @@ describe('component: emit', () => {
).not.toHaveBeenWarned()
})

test.todo('validator warning', () => {
// TODO: warning validator
test('validator warning', () => {
define({
emits: {
foo: (arg: number) => arg > 0,
},
setup(_, { emit }) {
emit('foo', -1)
return []
},
}).render()
expect(`event validation failed for event "foo"`).toHaveBeenWarned()
})

test('.once', () => {
Expand Down Expand Up @@ -415,8 +424,4 @@ describe('component: emit', () => {
await nextTick()
expect(fn).not.toHaveBeenCalled()
})

// NOTE: not supported mixins
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are no mixins in vapor mode

// test.todo('merge string array emits', async () => {})
// test.todo('merge object emits', async () => {})
})
2 changes: 1 addition & 1 deletion packages/runtime-vapor/src/componentEmits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function normalizeEmitsOptions(
let normalized: ObjectEmitsOptions
if (isArray(raw)) {
normalized = {}
for (const key in raw) normalized[key] = null
for (const key of raw) normalized[key] = null
} else {
normalized = raw
}
Expand Down
Loading