Commit 7648f61c authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

exp/html: adjust inCellIM to match spec

Clean up flow of control.

Ignore </table>, </tbody>, </tfoot>, </thead>, </tr> if there is not
an appropriate element in table scope.

Pass 3 more tests.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6206093
parent 053e4edd
...@@ -1451,15 +1451,18 @@ func inRowIM(p *parser) bool { ...@@ -1451,15 +1451,18 @@ func inRowIM(p *parser) bool {
// Section 12.2.5.4.15. // Section 12.2.5.4.15.
func inCellIM(p *parser) bool { func inCellIM(p *parser) bool {
var (
closeTheCellAndReprocess bool
)
switch p.tok.Type { switch p.tok.Type {
case StartTagToken: case StartTagToken:
switch p.tok.Data { switch p.tok.Data {
case "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr": case "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr":
// TODO: check for "td" or "th" in table scope. if p.popUntil(tableScope, "td", "th") {
closeTheCellAndReprocess = true // Close the cell and reprocess.
p.clearActiveFormattingElements()
p.im = inRowIM
return false
}
// Ignore the token.
return true
case "select": case "select":
p.reconstructActiveFormattingElements() p.reconstructActiveFormattingElements()
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
...@@ -1478,20 +1481,15 @@ func inCellIM(p *parser) bool { ...@@ -1478,20 +1481,15 @@ func inCellIM(p *parser) bool {
p.im = inRowIM p.im = inRowIM
return true return true
case "body", "caption", "col", "colgroup", "html": case "body", "caption", "col", "colgroup", "html":
// TODO. // Ignore the token.
return true
case "table", "tbody", "tfoot", "thead", "tr": case "table", "tbody", "tfoot", "thead", "tr":
// TODO: check for matching element in table scope. if !p.elementInScope(tableScope, p.tok.Data) {
closeTheCellAndReprocess = true // Ignore the token.
} return true
case CommentToken: }
p.addChild(&Node{ // Close the cell and reprocess.
Type: CommentNode, p.popUntil(tableScope, "td", "th")
Data: p.tok.Data,
})
return true
}
if closeTheCellAndReprocess {
if p.popUntil(tableScope, "td") || p.popUntil(tableScope, "th") {
p.clearActiveFormattingElements() p.clearActiveFormattingElements()
p.im = inRowIM p.im = inRowIM
return false return false
......
...@@ -3,7 +3,7 @@ PASS "<p id=\"status\"><noscript><strong>A</strong></noscript><span>B</span></p> ...@@ -3,7 +3,7 @@ PASS "<p id=\"status\"><noscript><strong>A</strong></noscript><span>B</span></p>
PASS "<div><sarcasm><div></div></sarcasm></div>" PASS "<div><sarcasm><div></div></sarcasm></div>"
FAIL "<html><body><img src=\"\" border=\"0\" alt=\"><div>A</div></body></html>" FAIL "<html><body><img src=\"\" border=\"0\" alt=\"><div>A</div></body></html>"
PASS "<table><td></tbody>A" PASS "<table><td></tbody>A"
FAIL "<table><td></thead>A" PASS "<table><td></thead>A"
FAIL "<table><td></tfoot>A" PASS "<table><td></tfoot>A"
FAIL "<table><thead><td></tbody>A" PASS "<table><thead><td></tbody>A"
PASS "<legend>test</legend>" PASS "<legend>test</legend>"
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