From 4b62a64f59f73840b9ab79204c94fee61cd1ba2c Mon Sep 17 00:00:00 2001 From: Kunpei Sakai Date: Fri, 25 Jan 2019 02:28:59 +0900 Subject: [PATCH] html: make (*nodeStack)contains distinguish namespace By proceeding without distinguishing namespace, inconsistency will occur. This commit makes the method distinguish the HTML namespace. Fixes golang/go#27846 Change-Id: I8269f670240c0fe31162a16fbe1ac23acacec00f Reviewed-on: https://go-review.googlesource.com/c/159397 Run-TryBot: Kunpei Sakai TryBot-Result: Gobot Gobot Reviewed-by: Nigel Tao --- html/node.go | 2 +- html/testdata/go/template.dat | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/html/node.go b/html/node.go index 2c1cade60..633ee15dc 100644 --- a/html/node.go +++ b/html/node.go @@ -177,7 +177,7 @@ func (s *nodeStack) index(n *Node) int { // contains returns whether a is within s. func (s *nodeStack) contains(a atom.Atom) bool { for _, n := range *s { - if n.DataAtom == a { + if n.DataAtom == a && n.Namespace == "" { return true } } diff --git a/html/testdata/go/template.dat b/html/testdata/go/template.dat index 98481b9e6..ceaf02292 100644 --- a/html/testdata/go/template.dat +++ b/html/testdata/go/template.dat @@ -35,3 +35,28 @@ | | +| +| +| +| +| +| + +#data + +#errors +#document +| +| +| +| +| +| +|