|
|
@@ -209,27 +209,6 @@ loop:
|
|
|
p.oe = p.oe[:i+1]
|
|
|
}
|
|
|
|
|
|
-// generateAllImpliedEndTags pops nodes off the stack of open elements as long as
|
|
|
-// the top node has a tag name of caption, colgroup, dd, div, dt, li, optgroup, option, p, rb,
|
|
|
-// rp, rt, rtc, span, tbody, td, tfoot, th, thead or tr.
|
|
|
-func (p *parser) generateAllImpliedEndTags() {
|
|
|
- var i int
|
|
|
- for i = len(p.oe) - 1; i >= 0; i-- {
|
|
|
- n := p.oe[i]
|
|
|
- if n.Type == ElementNode {
|
|
|
- switch n.DataAtom {
|
|
|
- // TODO: remove this divergence from the HTML5 spec
|
|
|
- case a.Caption, a.Colgroup, a.Dd, a.Div, a.Dt, a.Li, a.Optgroup, a.Option, a.P, a.Rb,
|
|
|
- a.Rp, a.Rt, a.Rtc, a.Span, a.Tbody, a.Td, a.Tfoot, a.Th, a.Thead, a.Tr:
|
|
|
- continue
|
|
|
- }
|
|
|
- }
|
|
|
- break
|
|
|
- }
|
|
|
-
|
|
|
- p.oe = p.oe[:i+1]
|
|
|
-}
|
|
|
-
|
|
|
// addChild adds a child node n to the top element, and pushes n onto the stack
|
|
|
// of open elements if it is an element node.
|
|
|
func (p *parser) addChild(n *Node) {
|
|
|
@@ -679,8 +658,16 @@ func inHeadIM(p *parser) bool {
|
|
|
if !p.oe.contains(a.Template) {
|
|
|
return true
|
|
|
}
|
|
|
- p.generateAllImpliedEndTags()
|
|
|
- p.popUntil(defaultScope, a.Template)
|
|
|
+ // TODO: remove this divergence from the HTML5 spec.
|
|
|
+ //
|
|
|
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=829668
|
|
|
+ p.generateImpliedEndTags()
|
|
|
+ for i := len(p.oe) - 1; i >= 0; i-- {
|
|
|
+ if n := p.oe[i]; n.Namespace == "" && n.DataAtom == a.Template {
|
|
|
+ p.oe = p.oe[:i]
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
p.clearActiveFormattingElements()
|
|
|
p.templateStack.pop()
|
|
|
p.resetInsertionMode()
|
|
|
@@ -1342,9 +1329,6 @@ func textIM(p *parser) bool {
|
|
|
// Section 12.2.6.4.9.
|
|
|
func inTableIM(p *parser) bool {
|
|
|
switch p.tok.Type {
|
|
|
- case ErrorToken:
|
|
|
- // Stop parsing.
|
|
|
- return true
|
|
|
case TextToken:
|
|
|
p.tok.Data = strings.Replace(p.tok.Data, "\x00", "", -1)
|
|
|
switch p.oe.top().DataAtom {
|
|
|
@@ -1439,6 +1423,8 @@ func inTableIM(p *parser) bool {
|
|
|
case DoctypeToken:
|
|
|
// Ignore the token.
|
|
|
return true
|
|
|
+ case ErrorToken:
|
|
|
+ return inBodyIM(p)
|
|
|
}
|
|
|
|
|
|
p.fosterParenting = true
|
|
|
@@ -1541,6 +1527,8 @@ func inColumnGroupIM(p *parser) bool {
|
|
|
case a.Template:
|
|
|
return inHeadIM(p)
|
|
|
}
|
|
|
+ case ErrorToken:
|
|
|
+ return inBodyIM(p)
|
|
|
}
|
|
|
if p.oe.top().DataAtom != a.Colgroup {
|
|
|
return true
|
|
|
@@ -1705,9 +1693,6 @@ func inCellIM(p *parser) bool {
|
|
|
// Section 12.2.6.4.16.
|
|
|
func inSelectIM(p *parser) bool {
|
|
|
switch p.tok.Type {
|
|
|
- case ErrorToken:
|
|
|
- // Stop parsing.
|
|
|
- return true
|
|
|
case TextToken:
|
|
|
p.addText(strings.Replace(p.tok.Data, "\x00", "", -1))
|
|
|
case StartTagToken:
|
|
|
@@ -1771,6 +1756,8 @@ func inSelectIM(p *parser) bool {
|
|
|
case DoctypeToken:
|
|
|
// Ignore the token.
|
|
|
return true
|
|
|
+ case ErrorToken:
|
|
|
+ return inBodyIM(p)
|
|
|
}
|
|
|
|
|
|
return true
|
|
|
@@ -1837,15 +1824,26 @@ func inTemplateIM(p *parser) bool {
|
|
|
// Ignore the token.
|
|
|
return true
|
|
|
}
|
|
|
+ case ErrorToken:
|
|
|
+ if !p.oe.contains(a.Template) {
|
|
|
+ // Ignore the token.
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ // TODO: remove this divergence from the HTML5 spec.
|
|
|
+ //
|
|
|
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=829668
|
|
|
+ p.generateImpliedEndTags()
|
|
|
+ for i := len(p.oe) - 1; i >= 0; i-- {
|
|
|
+ if n := p.oe[i]; n.Namespace == "" && n.DataAtom == a.Template {
|
|
|
+ p.oe = p.oe[:i]
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p.clearActiveFormattingElements()
|
|
|
+ p.templateStack.pop()
|
|
|
+ p.resetInsertionMode()
|
|
|
+ return false
|
|
|
}
|
|
|
- if !p.oe.contains(a.Template) {
|
|
|
- // Ignore the token.
|
|
|
- return true
|
|
|
- }
|
|
|
- p.popUntil(defaultScope, a.Template)
|
|
|
- p.clearActiveFormattingElements()
|
|
|
- p.templateStack.pop()
|
|
|
- p.resetInsertionMode()
|
|
|
return false
|
|
|
}
|
|
|
|