1
0
mirror of https://github.com/golang/go synced 2024-11-25 08:57:58 -07:00

html: handle text nodes in foreign content.

Passes tests10.dat, test 6:
<!DOCTYPE html><body><table><svg><g>foo</g></svg></table>

| <!DOCTYPE html>
| <html>
|   <head>
|   <body>
|     <svg svg>
|       <svg g>
|         "foo"
|     <table>

Also pass tests through test 12:
<!DOCTYPE html><body><table><caption><svg><g>foo</g><g>bar</g></svg><p>baz</caption></table>

R=andybalholm
CC=golang-dev
https://golang.org/cl/5495061
This commit is contained in:
Nigel Tao 2011-12-19 12:20:00 +11:00
parent 5ede9df5a0
commit 18e8441476
2 changed files with 12 additions and 1 deletions

View File

@ -1585,6 +1585,17 @@ func afterAfterFramesetIM(p *parser) bool {
// Section 12.2.5.5.
func inForeignContentIM(p *parser) bool {
switch p.tok.Type {
case TextToken:
// TODO: HTML integration points.
if p.top().Namespace == "" {
inBodyIM(p)
p.resetInsertionMode()
return true
}
if p.framesetOK {
p.framesetOK = strings.TrimLeft(p.tok.Data, whitespace) == ""
}
p.addText(p.tok.Data)
case CommentToken:
p.addChild(&Node{
Type: CommentNode,

View File

@ -173,7 +173,7 @@ func TestParser(t *testing.T) {
{"tests4.dat", -1},
{"tests5.dat", -1},
{"tests6.dat", 36},
{"tests10.dat", 6},
{"tests10.dat", 13},
}
for _, tf := range testFiles {
f, err := os.Open("testdata/webkit/" + tf.filename)