// The second <a> will be reparented to the first <table>'s parent. This
// results in an <a> whose parent is an <a>, which is not 'well-formed'.
`<a><table><td><a><table></table><a></tr><a></table><b>X</b>C<a>Y`: true,
+ // The same thing with a <p>:
+ `<p><table></p>`: true,
// 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,
`<!DOCTYPE html><body><b><nobr>1<table><nobr></b><i><nobr>2<nobr></i>3`: true,
// A <plaintext> element is reparented, putting it before a table.
// A <plaintext> element can't have anything after it in HTML.
- `<table><plaintext><td>`: true,
+ `<table><plaintext><td>`: true,
+ `<!doctype html><table><plaintext></plaintext>`: true,
+ `<!doctype html><table><tbody><plaintext></plaintext>`: true,
+ `<!doctype html><table><tbody><tr><plaintext></plaintext>`: true,
+ // A form inside a table inside a form doesn't work either.
+ `<!doctype html><form><table></form><form></table></form>`: true,
// A script that ends at EOF may escape its own closing tag when rendered.
`<!doctype html><script><!--<script `: true,
+ `<!doctype html><script><!--<script <`: true,
`<!doctype html><script><!--<script <a`: true,
+ `<!doctype html><script><!--<script </`: true,
+ `<!doctype html><script><!--<script </s`: true,
`<!doctype html><script><!--<script </script`: true,
`<!doctype html><script><!--<script </scripta`: true,
`<!doctype html><script><!--<script -`: true,
`<!doctype html><script><!--<script -a`: true,
+ `<!doctype html><script><!--<script -<`: true,
`<!doctype html><script><!--<script --`: true,
`<!doctype html><script><!--<script --a`: true,
+ `<!doctype html><script><!--<script --<`: true,
`<script><!--<script `: true,
`<script><!--<script <a`: true,
`<script><!--<script </script`: true,
`<script><!--<script -a`: true,
`<script><!--<script --`: true,
`<script><!--<script --a`: true,
+ `<script><!--<script <`: true,
+ `<script><!--<script </`: true,
+ `<script><!--<script </s`: true,
+ // Reconstructing the active formatting elements results in a <plaintext>
+ // element that contains an <a> element.
+ `<!doctype html><p><a><plaintext>b`: true,
}
func TestNodeConsistency(t *testing.T) {
switch n.Data {
case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style", "xmp":
for _, c := range n.Child {
- if c.Type != TextNode {
- return fmt.Errorf("html: raw text element <%s> has non-text child node", n.Data)
- }
- if _, err := w.WriteString(c.Data); err != nil {
- return err
+ if c.Type == TextNode {
+ if _, err := w.WriteString(c.Data); err != nil {
+ return err
+ }
+ } else {
+ if err := render1(w, c); err != nil {
+ return err
+ }
}
}
if n.Data == "plaintext" {
// last element in the file, with no closing tag.
return plaintextAbort
}
- case "textarea", "title":
- for _, c := range n.Child {
- if c.Type != TextNode && n.Namespace == "" {
- return fmt.Errorf("html: RCDATA element <%s> has non-text child node", n.Data)
- }
- if err := render1(w, c); err != nil {
- return err
- }
- }
default:
for _, c := range n.Child {
if err := render1(w, c); err != nil {
PASS "<!doctype html><script><!--<s"
PASS "<!doctype html><script><!--<script"
PASS "<!doctype html><script><!--<script "
-PARSE "<!doctype html><script><!--<script <"
+PASS "<!doctype html><script><!--<script <"
PASS "<!doctype html><script><!--<script <a"
-PARSE "<!doctype html><script><!--<script </"
-PARSE "<!doctype html><script><!--<script </s"
+PASS "<!doctype html><script><!--<script </"
+PASS "<!doctype html><script><!--<script </s"
PASS "<!doctype html><script><!--<script </script"
PASS "<!doctype html><script><!--<script </scripta"
PASS "<!doctype html><script><!--<script </script "
PASS "<!doctype html><script><!--<script </script </script>"
PASS "<!doctype html><script><!--<script -"
PASS "<!doctype html><script><!--<script -a"
-PARSE "<!doctype html><script><!--<script -<"
+PASS "<!doctype html><script><!--<script -<"
PASS "<!doctype html><script><!--<script --"
PASS "<!doctype html><script><!--<script --a"
-PARSE "<!doctype html><script><!--<script --<"
+PASS "<!doctype html><script><!--<script --<"
PASS "<!doctype html><script><!--<script -->"
PASS "<!doctype html><script><!--<script --><"
PASS "<!doctype html><script><!--<script --></"
PASS "<script><!--<s"
PASS "<script><!--<script"
PASS "<script><!--<script "
-PARSE "<script><!--<script <"
+PASS "<script><!--<script <"
PASS "<script><!--<script <a"
-PARSE "<script><!--<script </"
-PARSE "<script><!--<script </s"
+PASS "<script><!--<script </"
+PASS "<script><!--<script </s"
PASS "<script><!--<script </script"
PASS "<script><!--<script </scripta"
PASS "<script><!--<script </script "
PASS "<noembed><!--<noembed></noembed>--></noembed>"
PASS "<!doctype html><table>\n"
PASS "<!doctype html><table><td><span><font></span><span>"
-PARSE "<!doctype html><form><table></form><form></table></form>"
+PASS "<!doctype html><form><table></form><form></table></form>"
PASS "<!doctype html><plaintext></plaintext>"
-PARSE "<!doctype html><table><plaintext></plaintext>"
-PARSE "<!doctype html><table><tbody><plaintext></plaintext>"
-PARSE "<!doctype html><table><tbody><tr><plaintext></plaintext>"
-PARSE "<!doctype html><table><tbody><tr><plaintext></plaintext>"
+PASS "<!doctype html><table><plaintext></plaintext>"
+PASS "<!doctype html><table><tbody><plaintext></plaintext>"
+PASS "<!doctype html><table><tbody><tr><plaintext></plaintext>"
+PASS "<!doctype html><table><tbody><tr><plaintext></plaintext>"
PASS "<!doctype html><table><td><plaintext></plaintext>"
PASS "<!doctype html><table><caption><plaintext></plaintext>"
PASS "<!doctype html><table><tr><style></script></style>abc"
PASS "<!doctype html><a><b></a><bgsound>"
PASS "<!doctype html><figcaption><article></figcaption>a"
PASS "<!doctype html><summary><article></summary>a"
-PARSE "<!doctype html><p><a><plaintext>b"
+PASS "<!doctype html><p><a><plaintext>b"
PASS "<!DOCTYPE html><div>a<a></div>b<p>c</p>d"
PASS "<!doctype html><p><button></p>"
PASS "<!doctype html><address><button></address>a"
PASS "<!doctype html><address><button></address>a"
-PARSE "<p><table></p>"
+PASS "<p><table></p>"
PASS "<!doctype html><svg>"
PASS "<!doctype html><p><figcaption>"
PASS "<!doctype html><p><summary>"