html: don't emit text token for empty raw text elements.

Pass tests1.dat, test 99:
<script></script></div><title></title><p><p>

| <html>
|   <head>
|     <script>
|     <title>
|   <body>
|     <p>
|     <p>

Also pass tests through test 105:
<ul><li><ul></li><li>a</li></ul></li></ul>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5373043
This commit is contained in:
Andrew Balholm 2011-11-10 08:09:54 +11:00 committed by Nigel Tao
parent 23ffbe611d
commit ddc5ec642d
2 changed files with 6 additions and 3 deletions

View File

@ -133,7 +133,7 @@ func TestParser(t *testing.T) {
n int
}{
// TODO(nigeltao): Process all the test cases from all the .dat files.
{"tests1.dat", 99},
{"tests1.dat", 106},
{"tests2.dat", 0},
{"tests3.dat", 0},
}
@ -213,4 +213,5 @@ var renderTestBlacklist = map[string]bool{
// More cases of <a> being reparented:
`<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe`: true,
`<a><table><a></table><p><a><div><a>`: true,
`<a><table><td><a><table></table><a></tr><a></table><a>`: true,
}

View File

@ -552,8 +552,10 @@ func (z *Tokenizer) Next() TokenType {
z.data.end = z.raw.end
if z.rawTag != "" {
z.readRawOrRCDATA()
z.tt = TextToken
return z.tt
if z.data.end > z.data.start {
z.tt = TextToken
return z.tt
}
}
z.textIsRaw = false