up.fragment.matches(fragment, selector, [options])
JavaScript function
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.
Examples
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
Parameters
Comparison
fragment
selector
required
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.
Type: string | Element
Layer
[options.layer]
[options.mode]
Return value
Whether fragment matches the given selector.
Type: boolean