Commit ddc5ec64 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

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
parent 23ffbe61
...@@ -133,7 +133,7 @@ func TestParser(t *testing.T) { ...@@ -133,7 +133,7 @@ func TestParser(t *testing.T) {
n int n int
}{ }{
// TODO(nigeltao): Process all the test cases from all the .dat files. // TODO(nigeltao): Process all the test cases from all the .dat files.
{"tests1.dat", 99}, {"tests1.dat", 106},
{"tests2.dat", 0}, {"tests2.dat", 0},
{"tests3.dat", 0}, {"tests3.dat", 0},
} }
...@@ -213,4 +213,5 @@ var renderTestBlacklist = map[string]bool{ ...@@ -213,4 +213,5 @@ var renderTestBlacklist = map[string]bool{
// More cases of <a> being reparented: // More cases of <a> being reparented:
`<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe`: true, `<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><a></table><p><a><div><a>`: true,
`<a><table><td><a><table></table><a></tr><a></table><a>`: true,
} }
...@@ -552,8 +552,10 @@ func (z *Tokenizer) Next() TokenType { ...@@ -552,8 +552,10 @@ func (z *Tokenizer) Next() TokenType {
z.data.end = z.raw.end z.data.end = z.raw.end
if z.rawTag != "" { if z.rawTag != "" {
z.readRawOrRCDATA() z.readRawOrRCDATA()
z.tt = TextToken if z.data.end > z.data.start {
return z.tt z.tt = TextToken
return z.tt
}
} }
z.textIsRaw = false z.textIsRaw = false
......
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