Skip to content

Commit

Permalink
Merge pull request #13288 from leettaylor/lt/fix/vue-source
Browse files Browse the repository at this point in the history
Addon-docs: Fix Vue source snippets for function attributes
  • Loading branch information
shilman committed Nov 27, 2020
2 parents 8b29285 + 7589650 commit 813b4dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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

0 comments on commit 813b4dd

Please sign in to comment.