]> Cypherpunks repositories - gostls13.git/commitdiff
html: handle text nodes in foreign content.
authorNigel Tao <nigeltao@golang.org>
Mon, 19 Dec 2011 01:20:00 +0000 (12:20 +1100)
committerNigel Tao <nigeltao@golang.org>
Mon, 19 Dec 2011 01:20:00 +0000 (12:20 +1100)
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

src/pkg/html/parse.go
src/pkg/html/parse_test.go

index 104adc1b7baf17b7c399b188cf3080d002610013..a69262115c339aa8fedbdd40a16af8958e34b922 100644 (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,
index f501915759d1c28674f54285b19c4813c1c700a8..b938ca71854ca94d80014b208c3087b74208017f 100644 (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)