]> Cypherpunks repositories - gostls13.git/commitdiff
html: parse <optgroup> tags
authorAndrew Balholm <andybalholm@gmail.com>
Wed, 16 Nov 2011 08:25:55 +0000 (19:25 +1100)
committerNigel Tao <nigeltao@golang.org>
Wed, 16 Nov 2011 08:25:55 +0000 (19:25 +1100)
Pass tests2.dat, test 34:
<!DOCTYPE html><select><option><optgroup>

| <!DOCTYPE html>
| <html>
|   <head>
|   <body>
|     <select>
|       <option>
|       <optgroup>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5393045

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

index 2c15d2d31e90aebd48e5aee0fd8b68d60f2373b6..ca3907cc02b91d49ce9f6d49d1eaaa33f1d3887b 100644 (file)
@@ -1226,7 +1226,13 @@ func inSelectIM(p *parser) bool {
                        }
                        p.addElement(p.tok.Data, p.tok.Attr)
                case "optgroup":
-                       // TODO.
+                       if p.top().Data == "option" {
+                               p.oe.pop()
+                       }
+                       if p.top().Data == "optgroup" {
+                               p.oe.pop()
+                       }
+                       p.addElement(p.tok.Data, p.tok.Attr)
                case "select":
                        endSelect = true
                case "input", "keygen", "textarea":
index 3837f34b1916323f457d9f0731a0f28ec008024c..01d1facc1a4e72532808c4b53e816ad37f3893f2 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", 34},
+               {"tests2.dat", 35},
                {"tests3.dat", 0},
        }
        for _, tf := range testFiles {