Closed ikatyang closed 4 years ago
Seems there is no attribute info, so will this work?
<template lang="pug">
#container
some-component(tag='<some-tag>')
</template>
I've checked vuejs/vue-next
:
https://github.com/ikatyang/angular-html-parser/issues/11#issuecomment-621613078
And also I've checked that
<template lang="something-else">
is parsed just like normal<template>
s, which means we don't need additional information (e.g., attributes) to distinguish them.
Okay, good know, thanks.
Context: https://github.com/ikatyang/angular-html-parser/issues/11#issuecomment-620560801
This PR adds two parameters for
getTagContentType
so that Vue SFC could be correctly parsed:prefix
: the namespacehasParent
: determine if it's a root elementThe implementation for
hasParent
is a bit hacky, ithasParent
is consideredtrue
if the stack is empty at the moment.The reason why I implemented it this way is that I don't want to duplicate the entire parsing process in the lexer, though there are some drawbacks for the current implementation:
<li>
could be closed by a sibling<li>
but it won't work if it's a root element<tr>
could be closed by a parent</tbody>
but it won't work if it's a root elementhtm
closing tags (<//>
) won't work if they are root elements or their names are the same as the root elementBut I think it should be fine for the Vue SFC parsing since no one would encounter these edge cases in real life IMO.
This PR also contains a test case for Vue SFC parsing.
cc @fisker @thorn0 @sosukesuzuki