Commit d26f9f9a authored by Kunpei Sakai's avatar Kunpei Sakai Committed by Nigel Tao

html: update inSelectIM and inSelectInTableIM for the latest spec

Fixes golang/go#27842

Change-Id: I06eb3c0c18be3566bd30a29fca5f3f7e6791d2cc
Reviewed-on: https://go-review.googlesource.com/c/137275
Run-TryBot: Kunpei Sakai <namusyaka@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarNigel Tao <nigeltao@golang.org>
parent 4b62a64f
...@@ -1719,8 +1719,12 @@ func inSelectIM(p *parser) bool { ...@@ -1719,8 +1719,12 @@ func inSelectIM(p *parser) bool {
} }
p.addElement() p.addElement()
case a.Select: case a.Select:
p.tok.Type = EndTagToken if p.popUntil(selectScope, a.Select) {
return false p.resetInsertionMode()
} else {
// Ignore the token.
return true
}
case a.Input, a.Keygen, a.Textarea: case a.Input, a.Keygen, a.Textarea:
if p.elementInScope(selectScope, a.Select) { if p.elementInScope(selectScope, a.Select) {
p.parseImpliedToken(EndTagToken, a.Select, a.Select.String()) p.parseImpliedToken(EndTagToken, a.Select, a.Select.String())
...@@ -1750,6 +1754,9 @@ func inSelectIM(p *parser) bool { ...@@ -1750,6 +1754,9 @@ func inSelectIM(p *parser) bool {
case a.Select: case a.Select:
if p.popUntil(selectScope, a.Select) { if p.popUntil(selectScope, a.Select) {
p.resetInsertionMode() p.resetInsertionMode()
} else {
// Ignore the token.
return true
} }
case a.Template: case a.Template:
return inHeadIM(p) return inHeadIM(p)
...@@ -1775,13 +1782,22 @@ func inSelectInTableIM(p *parser) bool { ...@@ -1775,13 +1782,22 @@ func inSelectInTableIM(p *parser) bool {
case StartTagToken, EndTagToken: case StartTagToken, EndTagToken:
switch p.tok.DataAtom { switch p.tok.DataAtom {
case a.Caption, a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr, a.Td, a.Th: case a.Caption, a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr, a.Td, a.Th:
if p.tok.Type == StartTagToken || p.elementInScope(tableScope, p.tok.DataAtom) { if p.tok.Type == EndTagToken && !p.elementInScope(tableScope, p.tok.DataAtom) {
p.parseImpliedToken(EndTagToken, a.Select, a.Select.String())
return false
} else {
// Ignore the token. // Ignore the token.
return true return true
} }
// This is like p.popUntil(selectScope, a.Select), but it also
// matches <math select>, not just <select>. Matching the MathML
// tag is arguably incorrect (conceptually), but it mimics what
// Chromium does.
for i := len(p.oe) - 1; i >= 0; i-- {
if n := p.oe[i]; n.DataAtom == a.Select {
p.oe = p.oe[:i]
break
}
}
p.resetInsertionMode()
return false
} }
} }
return inSelectIM(p) return inSelectIM(p)
......
...@@ -367,7 +367,8 @@ var renderTestBlacklist = map[string]bool{ ...@@ -367,7 +367,8 @@ var renderTestBlacklist = map[string]bool{
`<script><!--<script </s`: true, `<script><!--<script </s`: true,
// Reconstructing the active formatting elements results in a <plaintext> // Reconstructing the active formatting elements results in a <plaintext>
// element that contains an <a> element. // element that contains an <a> element.
`<!doctype html><p><a><plaintext>b`: true, `<!doctype html><p><a><plaintext>b`: true,
`<table><math><select><mi><select></table>`: true,
} }
func TestNodeConsistency(t *testing.T) { func TestNodeConsistency(t *testing.T) {
......
#data
<table><math><select><mi><select></table>
#errors
#document
| <html>
| <head>
| <body>
| <math math>
| <math select>
| <math mi>
| <select>
| <table>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment