html: don't ignore token when current token is not <template>

Updates golang/go#23071

Change-Id: I36b0ee58f61b7de25730e0fb082eeb7ef2787594
Reviewed-on: https://go-review.googlesource.com/123920
Run-TryBot: Kunpei Sakai <namusyaka@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
diff --git a/html/parse.go b/html/parse.go
index 7e539b1..d5b0aee 100644
--- a/html/parse.go
+++ b/html/parse.go
@@ -680,9 +680,6 @@
 				return true
 			}
 			p.generateAllImpliedEndTags()
-			if n := p.oe.top(); n.DataAtom != a.Template {
-				return true
-			}
 			p.popUntil(defaultScope, a.Template)
 			p.clearActiveFormattingElements()
 			p.templateStack.pop()
diff --git a/html/testdata/webkit/template.dat b/html/testdata/webkit/template.dat
index e25f690..2d6c0a7 100644
--- a/html/testdata/webkit/template.dat
+++ b/html/testdata/webkit/template.dat
@@ -860,6 +860,22 @@
 |         <tfoot>
 
 #data
+<body><template><template><b><template></template></template>text</template>
+#errors
+#document
+| <html>
+|   <head>
+|   <body>
+|     <template>
+|       content
+|         <template>
+|           content
+|             <b>
+|               <template>
+|                 content
+|         "text"
+
+#data
 <body><template><col><colgroup>
 #errors
 #document