Closed olegbarabanov closed 7 months ago
You can pass the root node like this
NW.Dom.first(':scope > head', document.documentElement);
in the case of no explicit context. It probably doesn't solve the case of NW.Dom.first(":scope", document)
incorrectly returning null
when it should return the root element.
You can pass the root node like this
NW.Dom.first(':scope > head', document.documentElement);
in the case of no explicit context. It probably doesn't solve the case of
NW.Dom.first(":scope", document)
incorrectly returningnull
when it should return the root element.
@b-fuze, thank you.
A similar solution using document.documentElement
has already been proposed in a pending pull request (#94) to make the behavior of :scope
on document
the same as described in the standard and how it works in browsers.
For now, explicitly passing document.documentElement
is the best workaround when dealing with :scope
and document
.
In the context of a
Document
object (DOCUMENT_NODE
), the:scope
pseudo-class does not refer to the root element, according to the specification details https://drafts.csswg.org/selectors-4/#the-scope-pseudo.Minimal reproduction case:
Live example (in sandbox): https://codepen.io/olegbarabanov/pen/qBQpzxR
Note
nwsapi version: 2.2.7