Skip to content

Commit 573cea4

Browse files
committed
fix(stubs): Pass stubbed function to function props
The original implementation, added in 22c7698, passed a string value to a function prop. This instead passes an actual function, which stringifies to the same string. The problem with the previous approach is that Vue started warning about strings passed to function props in vuejs/core@7ccd453. As a result, this produced excessive noise in the logs that the author can do nothing about.
1 parent 6acbe6f commit 573cea4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/vnodeTransformers/stubComponentsTransformer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ interface StubOptions {
4242
renderStubDefaultSlot?: boolean
4343
}
4444

45+
function stubbedFunctionProp() {}
46+
stubbedFunctionProp.toString = () => '[Function]'
47+
4548
const normalizeStubProps = (props: ComponentPropsOptions) => {
4649
// props are always normalized to object syntax
4750
const $props = props as unknown as ComponentObjectPropsOptions
@@ -51,7 +54,7 @@ const normalizeStubProps = (props: ComponentPropsOptions) => {
5154
return { ...acc, [key]: [value?.toString()] }
5255
}
5356
if (typeof value === 'function') {
54-
return { ...acc, [key]: ['[Function]'] }
57+
return { ...acc, [key]: [stubbedFunctionProp] }
5558
}
5659
return { ...acc, [key]: value }
5760
}, {})

0 commit comments

Comments
 (0)