This feature is experimental. It may be changed or removed in a future version.
Returns whether the given element matches the given CSS selector or other element.
Other than Element#matches()
this function supports non-standard selectors like :main
or :layer
.
Instead of a selector you may also pass a second element. In that case the function returns whether both elements match the same derived target.
let element = document.querySelector('div[up-main]')
up.fragment.matches(element, 'div') // => true
up.fragment.matches(element, 'span') // => false
up.fragment.matches(element, ':main') // => true
up.fragment.matches(element, element) // => true
The selector or element to match.
When an element is passed, returns whether element
matches
the target derived from selector
.
The layer for which to match.
Pseudo-selectors like :main
may expand to different selectors
in different layers.
Required if { layer: 'new' }
is passed.