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') // result: true
up.fragment.matches(element, 'span') // result: false
up.fragment.matches(element, ':main') // result: true
up.fragment.matches(element, element) // result: true
The selector that the fragment
should match.
When an Element
is passed as this selector
argument, this functions tests whether fragment
matches
a target derived from selector
.
Whether fragment
matches the given selector
.