diff options
author | Andrew Balholm <andybalholm@gmail.com> | 2011-11-17 10:25:33 +1100 |
---|---|---|
committer | Nigel Tao <nigeltao@golang.org> | 2011-11-17 10:25:33 +1100 |
commit | 3276afd4d4ae45afee834c7455abbb9be1906540 (patch) | |
tree | ab4e054403880cb47157f8984ff38dd637f75bc5 | |
parent | 8c6461bcb166cf9234be2e61eeab882f5856521b (diff) | |
download | go-3276afd4d4ae45afee834c7455abbb9be1906540.tar.gz go-3276afd4d4ae45afee834c7455abbb9be1906540.zip |
html: parse </optgroup> and </option>
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
-rw-r--r-- | src/pkg/html/parse.go | 12 | ||||
-rw-r--r-- | src/pkg/html/parse_test.go | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go index ca3907cc02..58b754ef3d 100644 --- a/src/pkg/html/parse.go +++ b/src/pkg/html/parse.go @@ -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: diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go index 01d1facc1a..07e84907cf 100644 --- a/src/pkg/html/parse_test.go +++ b/src/pkg/html/parse_test.go @@ -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 { |