Commit 95e60acb authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

html: copy attributes from extra <html> tags to root element

Pass tests2.dat, test 50:
<!DOCTYPE html><html><body><html id=x>

| <!DOCTYPE html>
| <html>
|   id="x"
|   <head>
|   <body>

Also pass tests through test 56:
<!DOCTYPE html>X<p/x/y/z>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5432045
parent 750de28d
...@@ -457,6 +457,8 @@ func inHeadIM(p *parser) bool { ...@@ -457,6 +457,8 @@ func inHeadIM(p *parser) bool {
implied = true implied = true
case StartTagToken: case StartTagToken:
switch p.tok.Data { switch p.tok.Data {
case "html":
return inBodyIM(p)
case "base", "basefont", "bgsound", "command", "link", "meta": case "base", "basefont", "bgsound", "command", "link", "meta":
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
p.oe.pop() p.oe.pop()
...@@ -581,6 +583,8 @@ func inBodyIM(p *parser) bool { ...@@ -581,6 +583,8 @@ func inBodyIM(p *parser) bool {
p.framesetOK = false p.framesetOK = false
case StartTagToken: case StartTagToken:
switch p.tok.Data { switch p.tok.Data {
case "html":
copyAttributes(p.oe[0], p.tok)
case "address", "article", "aside", "blockquote", "center", "details", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "menu", "nav", "ol", "p", "section", "summary", "ul": 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(buttonScopeStopTags, "p") p.popUntil(buttonScopeStopTags, "p")
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
......
...@@ -134,7 +134,7 @@ func TestParser(t *testing.T) { ...@@ -134,7 +134,7 @@ func TestParser(t *testing.T) {
}{ }{
// TODO(nigeltao): Process all the test cases from all the .dat files. // TODO(nigeltao): Process all the test cases from all the .dat files.
{"tests1.dat", -1}, {"tests1.dat", -1},
{"tests2.dat", 50}, {"tests2.dat", 57},
{"tests3.dat", 0}, {"tests3.dat", 0},
} }
for _, tf := range testFiles { for _, tf := range testFiles {
......
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