]> Cypherpunks repositories - gostls13.git/commitdiff
html: copy attributes from extra <html> tags to root element
authorAndrew Balholm <andybalholm@gmail.com>
Tue, 22 Nov 2011 01:08:22 +0000 (12:08 +1100)
committerNigel Tao <nigeltao@golang.org>
Tue, 22 Nov 2011 01:08:22 +0000 (12:08 +1100)
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

src/pkg/html/parse.go
src/pkg/html/parse_test.go

index b74831b34e540c70eabea78989b7b269ccd69c4e..36204895b9c55a6158541a905a0d52d7a7713625 100644 (file)
@@ -457,6 +457,8 @@ func inHeadIM(p *parser) bool {
                implied = true
        case StartTagToken:
                switch p.tok.Data {
+               case "html":
+                       return inBodyIM(p)
                case "base", "basefont", "bgsound", "command", "link", "meta":
                        p.addElement(p.tok.Data, p.tok.Attr)
                        p.oe.pop()
@@ -581,6 +583,8 @@ func inBodyIM(p *parser) bool {
                p.framesetOK = false
        case StartTagToken:
                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":
                        p.popUntil(buttonScopeStopTags, "p")
                        p.addElement(p.tok.Data, p.tok.Attr)
index 808300a289140c6cae15e7aa19e4cff67e4f0400..3566f9f9417eaeb99e96e3bf94a60e767828553d 100644 (file)
@@ -134,7 +134,7 @@ func TestParser(t *testing.T) {
        }{
                // TODO(nigeltao): Process all the test cases from all the .dat files.
                {"tests1.dat", -1},
-               {"tests2.dat", 50},
+               {"tests2.dat", 57},
                {"tests3.dat", 0},
        }
        for _, tf := range testFiles {