From db5adf698cf5a05f985a034cf775ae6635c14baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Ko=C5=82odziejski?= Date: Fri, 12 Dec 2014 14:09:53 -0700 Subject: [PATCH] servo: Merge #4354 - Don't include the root element when calling Element#getElementsByTagNameNS (from neojski:getElementsByTagNameNS-filter-root); r=Ms2ger This fixes #4349. Source-Repo: https://github.com/servo/servo Source-Revision: 9e83f096a5b61beb7a26c222b1f6d7780b1335b0 --- servo/components/script/dom/htmlcollection.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/servo/components/script/dom/htmlcollection.rs b/servo/components/script/dom/htmlcollection.rs index 3ac4d49151320..91034fd4423d4 100644 --- a/servo/components/script/dom/htmlcollection.rs +++ b/servo/components/script/dom/htmlcollection.rs @@ -62,7 +62,10 @@ impl HTMLCollection { namespace_filter: Option } impl CollectionFilter for AllElementFilter { - fn filter(&self, elem: JSRef, _root: JSRef) -> bool { + fn filter(&self, elem: JSRef, root: JSRef) -> bool { + if NodeCast::from_ref(elem) == root { + return false + } match self.namespace_filter { None => true, Some(ref namespace) => *elem.namespace() == *namespace @@ -119,7 +122,10 @@ impl HTMLCollection { namespace_filter: Option } impl CollectionFilter for TagNameNSFilter { - fn filter(&self, elem: JSRef, _root: JSRef) -> bool { + fn filter(&self, elem: JSRef, root: JSRef) -> bool { + if NodeCast::from_ref(elem) == root { + return false + } let ns_match = match self.namespace_filter { Some(ref namespace) => { *elem.namespace() == *namespace