mirror of https://github.com/vuejs/core.git
wip: pass all compiler-dom tests
This commit is contained in:
parent
40f72d5e50
commit
5a44b84cde
|
@ -238,6 +238,8 @@ export default class Tokenizer {
|
||||||
private baseState = State.Text
|
private baseState = State.Text
|
||||||
/** For special parsing behavior inside of script and style tags. */
|
/** For special parsing behavior inside of script and style tags. */
|
||||||
public inRCDATA = false
|
public inRCDATA = false
|
||||||
|
/** For disabling RCDATA tags handling */
|
||||||
|
public inXML = false
|
||||||
/** Reocrd newline positions for fast line / column calculation */
|
/** Reocrd newline positions for fast line / column calculation */
|
||||||
private newlines: number[] = []
|
private newlines: number[] = []
|
||||||
|
|
||||||
|
@ -528,7 +530,7 @@ export default class Tokenizer {
|
||||||
// - everything except <template> is RAWTEXT
|
// - everything except <template> is RAWTEXT
|
||||||
// - <template> with lang other than html is also RAWTEXT
|
// - <template> with lang other than html is also RAWTEXT
|
||||||
this.state = State.InSFCRootTagName
|
this.state = State.InSFCRootTagName
|
||||||
} else {
|
} else if (!this.inXML) {
|
||||||
// HTML mode
|
// HTML mode
|
||||||
// - <script>, <style> RAWTEXT
|
// - <script>, <style> RAWTEXT
|
||||||
// - <title>, <textarea> RCDATA
|
// - <title>, <textarea> RCDATA
|
||||||
|
@ -539,6 +541,8 @@ export default class Tokenizer {
|
||||||
this.state =
|
this.state =
|
||||||
lower === 115 /* s */ ? State.BeforeSpecialS : State.InTagName
|
lower === 115 /* s */ ? State.BeforeSpecialS : State.InTagName
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.state = State.InTagName
|
||||||
}
|
}
|
||||||
} else if (c === CharCodes.Slash) {
|
} else if (c === CharCodes.Slash) {
|
||||||
this.state = State.BeforeClosingTagName
|
this.state = State.BeforeClosingTagName
|
||||||
|
|
|
@ -406,14 +406,17 @@ function getSlice(start: number, end: number) {
|
||||||
|
|
||||||
function endOpenTag(end: number) {
|
function endOpenTag(end: number) {
|
||||||
addNode(currentElement!)
|
addNode(currentElement!)
|
||||||
const name = currentElement!.tag
|
const { tag, ns } = currentElement!
|
||||||
if (currentOptions.isPreTag(name)) {
|
if (ns === Namespaces.HTML && currentOptions.isPreTag(tag)) {
|
||||||
inPre++
|
inPre++
|
||||||
}
|
}
|
||||||
if (currentOptions.isVoidTag(name)) {
|
if (currentOptions.isVoidTag(tag)) {
|
||||||
onCloseTag(currentElement!, end)
|
onCloseTag(currentElement!, end)
|
||||||
} else {
|
} else {
|
||||||
stack.unshift(currentElement!)
|
stack.unshift(currentElement!)
|
||||||
|
if (ns === Namespaces.SVG || ns === Namespaces.MATH_ML) {
|
||||||
|
tokenizer.inXML = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentElement = null
|
currentElement = null
|
||||||
}
|
}
|
||||||
|
@ -458,7 +461,7 @@ function onCloseTag(el: ElementNode, end: number) {
|
||||||
el.loc.end = tokenizer.getPos(end + offset + 1)
|
el.loc.end = tokenizer.getPos(end + offset + 1)
|
||||||
|
|
||||||
// refine element type
|
// refine element type
|
||||||
const tag = el.tag
|
const { tag, ns } = el
|
||||||
if (!inVPre) {
|
if (!inVPre) {
|
||||||
if (tag === 'slot') {
|
if (tag === 'slot') {
|
||||||
el.tagType = ElementTypes.SLOT
|
el.tagType = ElementTypes.SLOT
|
||||||
|
@ -473,14 +476,19 @@ function onCloseTag(el: ElementNode, end: number) {
|
||||||
if (!tokenizer.inRCDATA) {
|
if (!tokenizer.inRCDATA) {
|
||||||
el.children = condenseWhitespace(el.children, el.tag)
|
el.children = condenseWhitespace(el.children, el.tag)
|
||||||
}
|
}
|
||||||
|
if (ns === Namespaces.HTML && currentOptions.isPreTag(tag)) {
|
||||||
if (currentOptions.isPreTag(tag)) {
|
|
||||||
inPre--
|
inPre--
|
||||||
}
|
}
|
||||||
if (currentVPreBoundary === el) {
|
if (currentVPreBoundary === el) {
|
||||||
inVPre = false
|
inVPre = false
|
||||||
currentVPreBoundary = null
|
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'])
|
const specialTemplateDir = new Set(['if', 'else', 'else-if', 'for', 'slot'])
|
||||||
|
|
Loading…
Reference in New Issue