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

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

Also pass tests through test 41:
<!DOCTYPE html><!-- XXX - XXX - XXX -->

R=nigeltao, rsc
CC=golang-dev
https://golang.org/cl/5395045

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

index ca3907cc02b91d49ce9f6d49d1eaaa33f1d3887b..58b754ef3d080ba4f8c4904b9bcd7752419861ed 100644 (file)
@@ -1245,9 +1245,17 @@ func inSelectIM(p *parser) bool {
        case EndTagToken:
                switch p.tok.Data {
                case "option":
-                       // TODO.
+                       if p.top().Data == "option" {
+                               p.oe.pop()
+                       }
                case "optgroup":
-                       // TODO.
+                       i := len(p.oe) - 1
+                       if p.oe[i].Data == "option" {
+                               i--
+                       }
+                       if p.oe[i].Data == "optgroup" {
+                               p.oe = p.oe[:i]
+                       }
                case "select":
                        endSelect = true
                default:
index 01d1facc1a4e72532808c4b53e816ad37f3893f2..07e84907cfef5ec917898c0ce4018fc0c6e843c7 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", 35},
+               {"tests2.dat", 42},
                {"tests3.dat", 0},
        }
        for _, tf := range testFiles {