private baseState = State.Text
/** For special parsing behavior inside of script and style tags. */
public inRCDATA = false
+ /** For disabling RCDATA tags handling */
+ public inXML = false
/** Reocrd newline positions for fast line / column calculation */
private newlines: number[] = []
// - everything except <template> is RAWTEXT
// - <template> with lang other than html is also RAWTEXT
this.state = State.InSFCRootTagName
- } else {
+ } else if (!this.inXML) {
// HTML mode
// - <script>, <style> RAWTEXT
// - <title>, <textarea> RCDATA
this.state =
lower === 115 /* s */ ? State.BeforeSpecialS : State.InTagName
}
+ } else {
+ this.state = State.InTagName
}
} else if (c === CharCodes.Slash) {
this.state = State.BeforeClosingTagName
function endOpenTag(end: number) {
addNode(currentElement!)
- const name = currentElement!.tag
- if (currentOptions.isPreTag(name)) {
+ const { tag, ns } = currentElement!
+ if (ns === Namespaces.HTML && currentOptions.isPreTag(tag)) {
inPre++
}
- if (currentOptions.isVoidTag(name)) {
+ if (currentOptions.isVoidTag(tag)) {
onCloseTag(currentElement!, end)
} else {
stack.unshift(currentElement!)
+ if (ns === Namespaces.SVG || ns === Namespaces.MATH_ML) {
+ tokenizer.inXML = true
+ }
}
currentElement = null
}
el.loc.end = tokenizer.getPos(end + offset + 1)
// refine element type
- const tag = el.tag
+ const { tag, ns } = el
if (!inVPre) {
if (tag === 'slot') {
el.tagType = ElementTypes.SLOT
if (!tokenizer.inRCDATA) {
el.children = condenseWhitespace(el.children, el.tag)
}
-
- if (currentOptions.isPreTag(tag)) {
+ if (ns === Namespaces.HTML && currentOptions.isPreTag(tag)) {
inPre--
}
if (currentVPreBoundary === el) {
inVPre = false
currentVPreBoundary = null
}
+ if (
+ tokenizer.inXML &&
+ (stack[0] ? stack[0].ns : currentOptions.ns) === Namespaces.HTML
+ ) {
+ tokenizer.inXML = false
+ }
}
const specialTemplateDir = new Set(['if', 'else', 'else-if', 'for', 'slot'])