Can @vue/compiler-sfc support parsing html5 self closing tags to a AST node with isSelfClosing = true?
What problem does this feature solve?
I have a project that use @vue/compiler-sfc
to parse vue sfc component and transform some nonstandard code and regenerate them. But @vue/compiler-sfc
will parse html5 self closing tags to a AST node with isSelfClosing = false
, such as img
:
<img :src="icon.url">
the isSelfClosing
attribute in AST is false
, so that it will be transformed incorrectly when regenerate new code like that:
<img :src="plan.icon"></img>
According to the HTML5 spec, tags that cannot have any contents (known as void elements) can be self-closing*. This includes the following tags:
area, base, br, col, embed, hr, img, input,
keygen, link, meta, param, source, track, wbr
What does the proposed API look like?
The isSelfClosing
attribute in AST to be true
when parse html5 self closing tags.