mirror of
https://github.com/golang/go
synced 2024-11-20 05:14:41 -07:00
exp/html: start making inBodyIM match the spec
Reorder some start tags. Improve handling of </body>. Handle </html>. Pass 2 additional tests (by handling </html>). R=golang-dev, nigeltao CC=golang-dev https://golang.org/cl/6082043
This commit is contained in:
parent
6791057296
commit
eea5a432cb
@ -640,6 +640,29 @@ func inBodyIM(p *parser) bool {
|
||||
switch p.tok.Data {
|
||||
case "html":
|
||||
copyAttributes(p.oe[0], p.tok)
|
||||
case "base", "basefont", "bgsound", "command", "link", "meta", "noframes", "script", "style", "title":
|
||||
return inHeadIM(p)
|
||||
case "body":
|
||||
if len(p.oe) >= 2 {
|
||||
body := p.oe[1]
|
||||
if body.Type == ElementNode && body.Data == "body" {
|
||||
p.framesetOK = false
|
||||
copyAttributes(body, p.tok)
|
||||
}
|
||||
}
|
||||
case "frameset":
|
||||
if !p.framesetOK || len(p.oe) < 2 || p.oe[1].Data != "body" {
|
||||
// Ignore the token.
|
||||
return true
|
||||
}
|
||||
body := p.oe[1]
|
||||
if body.Parent != nil {
|
||||
body.Parent.Remove(body)
|
||||
}
|
||||
p.oe = p.oe[:1]
|
||||
p.addElement(p.tok.Data, p.tok.Attr)
|
||||
p.im = inFramesetIM
|
||||
return true
|
||||
case "address", "article", "aside", "blockquote", "center", "details", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "menu", "nav", "ol", "p", "section", "summary", "ul":
|
||||
p.popUntil(buttonScope, "p")
|
||||
p.addElement(p.tok.Data, p.tok.Attr)
|
||||
@ -758,29 +781,6 @@ func inBodyIM(p *parser) bool {
|
||||
}
|
||||
p.reconstructActiveFormattingElements()
|
||||
p.addElement(p.tok.Data, p.tok.Attr)
|
||||
case "body":
|
||||
if len(p.oe) >= 2 {
|
||||
body := p.oe[1]
|
||||
if body.Type == ElementNode && body.Data == "body" {
|
||||
p.framesetOK = false
|
||||
copyAttributes(body, p.tok)
|
||||
}
|
||||
}
|
||||
case "frameset":
|
||||
if !p.framesetOK || len(p.oe) < 2 || p.oe[1].Data != "body" {
|
||||
// Ignore the token.
|
||||
return true
|
||||
}
|
||||
body := p.oe[1]
|
||||
if body.Parent != nil {
|
||||
body.Parent.Remove(body)
|
||||
}
|
||||
p.oe = p.oe[:1]
|
||||
p.addElement(p.tok.Data, p.tok.Attr)
|
||||
p.im = inFramesetIM
|
||||
return true
|
||||
case "base", "basefont", "bgsound", "command", "link", "meta", "noframes", "script", "style", "title":
|
||||
return inHeadIM(p)
|
||||
case "image":
|
||||
p.tok.Data = "img"
|
||||
return false
|
||||
@ -847,8 +847,14 @@ func inBodyIM(p *parser) bool {
|
||||
case EndTagToken:
|
||||
switch p.tok.Data {
|
||||
case "body":
|
||||
// TODO: autoclose the stack of open elements.
|
||||
if p.elementInScope(defaultScope, "body") {
|
||||
p.im = afterBodyIM
|
||||
}
|
||||
case "html":
|
||||
if p.elementInScope(defaultScope, "body") {
|
||||
p.parseImpliedToken(EndTagToken, "body", nil)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
case "p":
|
||||
if !p.elementInScope(buttonScope, "p") {
|
||||
|
@ -2,7 +2,7 @@ PASS "<!DOCTYPE html><p><b><i><u></p> <p>X"
|
||||
PASS "<p><b><i><u></p>\n<p>X"
|
||||
PASS "<!doctype html></html> <head>"
|
||||
PASS "<!doctype html></body><meta>"
|
||||
FAIL "<html></html><!-- foo -->"
|
||||
PASS "<html></html><!-- foo -->"
|
||||
PASS "<!doctype html></body><title>X</title>"
|
||||
PASS "<!doctype html><table> X<meta></table>"
|
||||
PASS "<!doctype html><table> x</table>"
|
||||
|
@ -21,7 +21,7 @@ PASS "<body></body></br foo=\"bar\">"
|
||||
PASS "<bdy></body><br foo=\"bar\">"
|
||||
PASS "<html><body></body></html><!-- Hi there -->"
|
||||
PASS "<html><body></body></html>x<!-- Hi there -->"
|
||||
FAIL "<html><body></body></html>x<!-- Hi there --></html><!-- Again -->"
|
||||
PASS "<html><body></body></html>x<!-- Hi there --></html><!-- Again -->"
|
||||
PASS "<html><body></body></html>x<!-- Hi there --></body></html><!-- Again -->"
|
||||
FAIL "<html><body><ruby><div><rp>xx</rp></div></ruby></body></html>"
|
||||
FAIL "<html><body><ruby><div><rt>xx</rt></div></ruby></body></html>"
|
||||
|
Loading…
Reference in New Issue
Block a user