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