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

Addon-docs: Fix Vue source snippets for function attributes #13288

Merged
merged 3 commits into from Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions addons/docs/src/frameworks/vue/sourceDecorator.test.ts
Expand Up @@ -32,7 +32,7 @@ describe('vnodeToString', () => {

it('attributes', () => {
const MyComponent: ComponentOptions<any, any, any> = {
props: ['propA', 'propB', 'propC', 'propD'],
props: ['propA', 'propB', 'propC', 'propD', 'propE', 'propF', 'propG'],
template: '<div/>',
};

Expand All @@ -49,14 +49,21 @@ describe('vnodeToString', () => {
propD: {
foo: 'bar',
},
propE: true,
propF() {
const foo = 'bar';

return foo;
},
propG: undefined,
},
};
},
template: `<my-component v-bind="props"/>`,
})
)
).toMatchInlineSnapshot(
`<my-component :propD='{"foo":"bar"}' :propC="null" :propB="1" propA="propA"/>`
`<my-component propE :propD='{"foo":"bar"}' :propC="null" :propB="1" propA="propA"/>`
);
});

Expand Down
2 changes: 1 addition & 1 deletion addons/docs/src/frameworks/vue/sourceDecorator.ts
Expand Up @@ -123,7 +123,7 @@ export function vnodeToString(vnode: Vue.VNode): string {
}

function stringifyAttr(attrName: string, value?: any): string | null {
if (typeof value === 'undefined') {
if (typeof value === 'undefined' || typeof value === 'function') {
return null;
}

Expand Down