mirror of
https://github.com/golang/go
synced 2024-11-22 10:44:41 -07:00
html: propagate foreign namespaces only when adding foreign content.
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
This commit is contained in:
parent
dcdc309c7c
commit
aa033c20b3
@ -245,7 +245,6 @@ func (p *parser) addElement(tag string, attr []Attribute) {
|
|||||||
p.addChild(&Node{
|
p.addChild(&Node{
|
||||||
Type: ElementNode,
|
Type: ElementNode,
|
||||||
Data: tag,
|
Data: tag,
|
||||||
Namespace: p.top().Namespace,
|
|
||||||
Attr: attr,
|
Attr: attr,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1736,7 +1735,9 @@ func parseForeignContent(p *parser) bool {
|
|||||||
panic("html: bad parser state: unexpected namespace")
|
panic("html: bad parser state: unexpected namespace")
|
||||||
}
|
}
|
||||||
adjustForeignAttributes(p.tok.Attr)
|
adjustForeignAttributes(p.tok.Attr)
|
||||||
|
namespace := p.top().Namespace
|
||||||
p.addElement(p.tok.Data, p.tok.Attr)
|
p.addElement(p.tok.Data, p.tok.Attr)
|
||||||
|
p.top().Namespace = namespace
|
||||||
case EndTagToken:
|
case EndTagToken:
|
||||||
for i := len(p.oe) - 1; i >= 0; i-- {
|
for i := len(p.oe) - 1; i >= 0; i-- {
|
||||||
if p.oe[i].Namespace == "" {
|
if p.oe[i].Namespace == "" {
|
||||||
|
@ -184,7 +184,7 @@ func TestParser(t *testing.T) {
|
|||||||
{"tests4.dat", -1},
|
{"tests4.dat", -1},
|
||||||
{"tests5.dat", -1},
|
{"tests5.dat", -1},
|
||||||
{"tests6.dat", -1},
|
{"tests6.dat", -1},
|
||||||
{"tests10.dat", 31},
|
{"tests10.dat", 33},
|
||||||
}
|
}
|
||||||
for _, tf := range testFiles {
|
for _, tf := range testFiles {
|
||||||
f, err := os.Open("testdata/webkit/" + tf.filename)
|
f, err := os.Open("testdata/webkit/" + tf.filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user