Commit 899be509 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

exp/html: don't insert empty text nodes

Pass 1 additional test.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6443048
parent 24ae7e68
...@@ -267,6 +267,9 @@ func (p *parser) fosterParent(n *Node) { ...@@ -267,6 +267,9 @@ func (p *parser) fosterParent(n *Node) {
// addText adds text to the preceding node if it is a text node, or else it // addText adds text to the preceding node if it is a text node, or else it
// calls addChild with a new text node. // calls addChild with a new text node.
func (p *parser) addText(text string) { func (p *parser) addText(text string) {
if text == "" {
return
}
// TODO: distinguish whitespace text from others. // TODO: distinguish whitespace text from others.
t := p.top() t := p.top()
if i := len(t.Child); i > 0 && t.Child[i-1].Type == TextNode { if i := len(t.Child); i > 0 && t.Child[i-1].Type == TextNode {
......
...@@ -4,7 +4,7 @@ PASS "<html> \x00 <frameset></frameset>" ...@@ -4,7 +4,7 @@ PASS "<html> \x00 <frameset></frameset>"
PASS "<html>a\x00a<frameset></frameset>" PASS "<html>a\x00a<frameset></frameset>"
PASS "<html>\x00\x00<frameset></frameset>" PASS "<html>\x00\x00<frameset></frameset>"
PASS "<html>\x00\n <frameset></frameset>" PASS "<html>\x00\n <frameset></frameset>"
FAIL "<html><select>\x00" PASS "<html><select>\x00"
PASS "\x00" PASS "\x00"
PASS "<body>\x00" PASS "<body>\x00"
FAIL "<plaintext>\x00filler\x00text\x00" FAIL "<plaintext>\x00filler\x00text\x00"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment