]> Cypherpunks repositories - gostls13.git/commitdiff
html: propagate foreign namespaces only when adding foreign content.
authorNigel Tao <nigeltao@golang.org>
Tue, 10 Jan 2012 23:15:40 +0000 (10:15 +1100)
committerNigel Tao <nigeltao@golang.org>
Tue, 10 Jan 2012 23:15:40 +0000 (10:15 +1100)
Pass tests10.dat, test 31:
<div><svg><path><foreignObject><p></div>a

| <html>
|   <head>
|   <body>
|     <div>
|       <svg svg>
|         <svg path>
|           <svg foreignObject>
|             <p>
|               "a"

Also pass test 32:
<!DOCTYPE html><svg><desc><div><svg><ul>a

R=andybalholm
CC=golang-dev
https://golang.org/cl/5527064

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

index 7077612e7a16d353ef81e736c31625eae7c6fb7c..43c04727ab83d7adfdbbab3372d54d1c9e2427b5 100644 (file)
@@ -243,10 +243,9 @@ func (p *parser) addText(text string) {
 // addElement calls addChild with an element node.
 func (p *parser) addElement(tag string, attr []Attribute) {
        p.addChild(&Node{
-               Type:      ElementNode,
-               Data:      tag,
-               Namespace: p.top().Namespace,
-               Attr:      attr,
+               Type: ElementNode,
+               Data: tag,
+               Attr: attr,
        })
 }
 
@@ -1736,7 +1735,9 @@ func parseForeignContent(p *parser) bool {
                        panic("html: bad parser state: unexpected namespace")
                }
                adjustForeignAttributes(p.tok.Attr)
+               namespace := p.top().Namespace
                p.addElement(p.tok.Data, p.tok.Attr)
+               p.top().Namespace = namespace
        case EndTagToken:
                for i := len(p.oe) - 1; i >= 0; i-- {
                        if p.oe[i].Namespace == "" {
index 91c8388b3a2a3ccfa82073050c08ab48621d5967..c929c257727f2e27fbdef26bd2645d18b3b7083a 100644 (file)
@@ -184,7 +184,7 @@ func TestParser(t *testing.T) {
                {"tests4.dat", -1},
                {"tests5.dat", -1},
                {"tests6.dat", -1},
-               {"tests10.dat", 31},
+               {"tests10.dat", 33},
        }
        for _, tf := range testFiles {
                f, err := os.Open("testdata/webkit/" + tf.filename)