1
0
mirror of https://github.com/golang/go synced 2024-11-20 03:34:40 -07:00

html: auto-close <dd> and <dt> elements

Pass tests2.dat, test 8:
<!DOCTYPE html><dt><div><dd>

| <!DOCTYPE html>
| <html>
|   <head>
|   <body>
|     <dt>
|       <div>
|     <dd>

Also pass tests through test 9:
<script></x

R=nigeltao
CC=golang-dev
https://golang.org/cl/5373083
This commit is contained in:
Andrew Balholm 2011-11-13 23:27:20 +11:00 committed by Nigel Tao
parent 631a575fd9
commit 06ef97e15d
2 changed files with 19 additions and 1 deletions

View File

@ -637,6 +637,24 @@ func inBodyIM(p *parser) bool {
}
p.popUntil(buttonScopeStopTags, "p")
p.addElement(p.tok.Data, p.tok.Attr)
case "dd", "dt":
p.framesetOK = false
for i := len(p.oe) - 1; i >= 0; i-- {
node := p.oe[i]
switch node.Data {
case "dd", "dt":
p.oe = p.oe[:i]
case "address", "div", "p":
continue
default:
if !isSpecialElement[node.Data] {
continue
}
}
break
}
p.popUntil(buttonScopeStopTags, "p")
p.addElement(p.tok.Data, p.tok.Attr)
case "optgroup", "option":
if p.top().Data == "option" {
p.oe.pop()

View 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", 0},
{"tests2.dat", 10},
{"tests3.dat", 0},
}
for _, tf := range testFiles {