From d60e847522acc16d4a6aa86a071e28fde81e5e9c Mon Sep 17 00:00:00 2001 From: Momoko Sumida Date: Fri, 7 Sep 2018 00:26:31 -0700 Subject: [PATCH] Fix :scope selector matching in the case of DocumentFragment/ShadowRoot When used in querySelector and querySelectorAll, :scope should match the element or the DocumentFragment/ShadowRoot the querySelector is called on. However, WPT adeed in crrev.com/c/1158445 shows that :scope matches nothing when querySelector is called on shadow root, while it works fine when querySelector is called on true element. This CL fixes :scope selector matching process so that :scope itself matches DocumentFragment/ShadowRoot when querySelector is called on DocumentFragment/ShadowRoot. Tests for DocumentFragment are also added in this CL. Link to the spec: https://drafts.csswg.org/selectors-4/#the-scope-pseudo Link to related issue: https://github.com/w3c/csswg-drafts/issues/3016 Link to related CL: crrev.com/c/1158445 Bug: 859692 Change-Id: If20fc4b122d93a553dc478be0ee958958340a34f --- css/selectors/scope-selector.html | 81 ++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 12 deletions(-) diff --git a/css/selectors/scope-selector.html b/css/selectors/scope-selector.html index bda0aed602aa691..3db6d1c0c5fd6b7 100644 --- a/css/selectors/scope-selector.html +++ b/css/selectors/scope-selector.html @@ -6,29 +6,86 @@