feat: add isCustomElement option (#299)

This commit is contained in:
月迷津渡
2019-10-16 05:30:47 +08:00
committed by Evan You
parent b60355d857
commit f71bf2f1d3
5 changed files with 36 additions and 1 deletions

View File

@@ -616,6 +616,25 @@ describe('compiler: parse', () => {
})
})
test('custom element', () => {
const ast = parse('<div></div><comp></comp>', {
isNativeTag: tag => tag === 'div',
isCustomElement: tag => tag === 'comp'
})
expect(ast.children[0]).toMatchObject({
type: NodeTypes.ELEMENT,
tag: 'div',
tagType: ElementTypes.ELEMENT
})
expect(ast.children[1]).toMatchObject({
type: NodeTypes.ELEMENT,
tag: 'comp',
tagType: ElementTypes.ELEMENT
})
})
test('attribute with no value', () => {
const ast = parse('<div id></div>')
const element = ast.children[0] as ElementNode