diff options
author | Andrew Balholm <andybalholm@gmail.com> | 2011-11-16 19:25:55 +1100 |
---|---|---|
committer | Nigel Tao <nigeltao@golang.org> | 2011-11-16 19:25:55 +1100 |
commit | 3307597069f533a1f34beadb735af804d47ef6de (patch) | |
tree | d4622d562b944d7682c4e3211275a9e310bac508 | |
parent | 28546ed56a37c7d4a384c1e9ae69c61d16e4ea94 (diff) | |
download | go-3307597069f533a1f34beadb735af804d47ef6de.tar.gz go-3307597069f533a1f34beadb735af804d47ef6de.zip |
html: parse <optgroup> tags
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
-rw-r--r-- | src/pkg/html/parse.go | 8 | ||||
-rw-r--r-- | src/pkg/html/parse_test.go | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go index 2c15d2d31e..ca3907cc02 100644 --- a/src/pkg/html/parse.go +++ b/src/pkg/html/parse.go @@ -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": diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go index 3837f34b19..01d1facc1a 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", 34}, + {"tests2.dat", 35}, {"tests3.dat", 0}, } for _, tf := range testFiles { |