Skip to content

Commit

Permalink
馃 (parser) Handle the primitive value
Browse files Browse the repository at this point in the history
Closes #113
  • Loading branch information
HcySunYang committed Oct 9, 2019
1 parent cb02409 commit 6505902
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/parser/__test__/__fixtures__/objectProps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export default {
type: Function,
default () {}
},
'g': String
'g': {
type: String,
default: 'HELLO'
}
}
}
</script>
1 change: 1 addition & 0 deletions packages/parser/__test__/parseJavascript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ test('Props: gets correct name for a quoted property', () => {

expect(mockOnProp.mock.calls.length).toBe(6)
expect(arg.name).toBe('g')
expect(arg.default).toBe('HELLO')
})

test('Get comments as a description', () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/parser/lib/processProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export function processPropValue(propValueNode: bt.Node, result: PropsResult) {
result.default = runFunction(r)
} else if (bt.isFunction(node.value)) {
result.default = runFunction(node.value)
} else if (
bt.isNumberLiteral(node.value) ||
bt.isStringLiteral(node.value)
) {
// Primitive value
result.default = node.value.value
}
} else {
if (bt.isObjectMethod(node)) {
Expand Down

0 comments on commit 6505902

Please sign in to comment.