1
0
mirror of https://github.com/golang/go synced 2024-11-20 02:14:46 -07:00

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
This commit is contained in:
Andrew Balholm 2011-11-17 10:25:33 +11:00 committed by Nigel Tao
parent 8c6461bcb1
commit 3276afd4d4
2 changed files with 11 additions and 3 deletions

View File

@ -1245,9 +1245,17 @@ func inSelectIM(p *parser) bool {
case EndTagToken: case EndTagToken:
switch p.tok.Data { switch p.tok.Data {
case "option": case "option":
// TODO. if p.top().Data == "option" {
p.oe.pop()
}
case "optgroup": 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": case "select":
endSelect = true endSelect = true
default: default:

View File

@ -134,7 +134,7 @@ func TestParser(t *testing.T) {
}{ }{
// TODO(nigeltao): Process all the test cases from all the .dat files. // TODO(nigeltao): Process all the test cases from all the .dat files.
{"tests1.dat", -1}, {"tests1.dat", -1},
{"tests2.dat", 35}, {"tests2.dat", 42},
{"tests3.dat", 0}, {"tests3.dat", 0},
} }
for _, tf := range testFiles { for _, tf := range testFiles {