Version 3.18.1
Show:

Selector Class

Module: selector-native
Parent Module: dom

Provides support for using CSS selectors to query the DOM

Item Index

Methods

Properties

Methods

ancestor

(
  • node
  • selector
  • testSelf
)
HTMLElement static

A convenience method to emulate Y.Node's aNode.ancestor(selector).

Parameters:

  • node HTMLElement

    A node to start the query from.

  • selector String

    A CSS selector to test the node against.

  • testSelf Boolean

    optional Whether or not to include the node in the scan.

Returns:

HTMLElement:

The ancestor node matching the selector, or null.

filter

(
  • nodes
  • selector
)
HTMLElement[] static

Filters out nodes that do not match the given CSS selector.

Parameters:

  • nodes HTMLElement[]

    An array of nodes.

  • selector String

    A CSS selector to test each node against.

Returns:

HTMLElement[]:

The nodes that matched the given CSS selector.

query

(
  • selector
  • root
  • firstOnly
)
HTMLElement[] static

Retrieves a set of nodes based on a given CSS selector.

Parameters:

  • selector String

    A CSS selector.

  • root HTMLElement

    optional A node to start the query from. Defaults to Y.config.doc.

  • firstOnly Boolean

    optional Whether or not to return only the first match.

Returns:

HTMLElement[]:

The array of nodes that matched the given selector.

test

(
  • node
  • selector
  • root
)
Boolean static

Determines whether or not the given node matches the given CSS selector.

Parameters:

  • node HTMLElement

    A node to test.

  • selector String

    A CSS selector to test the node against.

  • root HTMLElement

    optional A node to start the query from. Defaults to the parent document of the node.

Returns:

Boolean:

Whether or not the given node matched the given CSS selector.

Properties

operators

Object

Provided by the selector-css2 module.

Defined in dom/js/selector-css2.js:40

List of operators and corresponding boolean functions. These functions are passed the attribute and the current node's value of the attribute.

shorthand

Object

Provided by the selector-css2 module.

Defined in dom/js/selector-css2.js:30

Mapping of shorthand tokens to corresponding attribute selector

useNative

Unknown static

Use the native version of querySelectorAll, if it exists.

Default: true