mirror of
https://github.com/golang/go
synced 2024-10-01 01:28:32 -06:00
html: correctly parse </html> in <head> element.
Pass tests1.dat, test 92: <head></html><meta><p> | <html> | <head> | <body> | <meta> | <p> Also pass tests through test 98: <p><b><div><marquee></p></b></div> R=nigeltao CC=golang-dev https://golang.org/cl/5359054
This commit is contained in:
parent
929070ee62
commit
820523d091
@ -470,10 +470,15 @@ func inHeadIM(p *parser) (insertionMode, bool) {
|
|||||||
implied = true
|
implied = true
|
||||||
}
|
}
|
||||||
case EndTagToken:
|
case EndTagToken:
|
||||||
if p.tok.Data == "head" {
|
switch p.tok.Data {
|
||||||
|
case "head":
|
||||||
pop = true
|
pop = true
|
||||||
|
case "body", "html", "br":
|
||||||
|
implied = true
|
||||||
|
default:
|
||||||
|
// Ignore the token.
|
||||||
|
return inHeadIM, true
|
||||||
}
|
}
|
||||||
// TODO.
|
|
||||||
case CommentToken:
|
case CommentToken:
|
||||||
p.addChild(&Node{
|
p.addChild(&Node{
|
||||||
Type: CommentNode,
|
Type: CommentNode,
|
||||||
@ -524,7 +529,14 @@ func afterHeadIM(p *parser) (insertionMode, bool) {
|
|||||||
framesetOK = true
|
framesetOK = true
|
||||||
}
|
}
|
||||||
case EndTagToken:
|
case EndTagToken:
|
||||||
// TODO.
|
switch p.tok.Data {
|
||||||
|
case "body", "html", "br":
|
||||||
|
implied = true
|
||||||
|
framesetOK = true
|
||||||
|
default:
|
||||||
|
// Ignore the token.
|
||||||
|
return afterHeadIM, true
|
||||||
|
}
|
||||||
case CommentToken:
|
case CommentToken:
|
||||||
p.addChild(&Node{
|
p.addChild(&Node{
|
||||||
Type: CommentNode,
|
Type: CommentNode,
|
||||||
|
@ -133,7 +133,7 @@ func TestParser(t *testing.T) {
|
|||||||
n int
|
n int
|
||||||
}{
|
}{
|
||||||
// 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", 92},
|
{"tests1.dat", 99},
|
||||||
{"tests2.dat", 0},
|
{"tests2.dat", 0},
|
||||||
{"tests3.dat", 0},
|
{"tests3.dat", 0},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user