#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# Selector Class

Defined in: `dom/js/selector-native.js:9`
Module: selector-native
Parent Module: dom

Provides support for using CSS selectors to query the DOM

- Index
- Methods
- Properties

## Item Index

### Methods

- ancestor static
- query static

### Properties

- operators
- shorthand

## Methods

### `ancestor`

(

- `element`
- `selector`
- `testSelf`

)
HTMLElement static

Defined in `dom/js/selector-native.js:332`

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

#### Parameters:

- `element` HTMLElement

  An HTMLElement to start the query from.

- `selector` String

  The CSS selector to test the node against.

- `testSelf` Boolean

  optional Whether or not to include the element in the scan

#### Returns:

HTMLElement: The ancestor node matching the selector, or null.

### `query`

(

- `selector`
- `root`
- `firstOnly`

)
Array static

Defined in `dom/js/selector-native.js:113`

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

#### Parameters:

- `selector` String

  The CSS Selector to test the node against.

- `root` HTMLElement

  optional An HTMLElement to start the query from. Defaults to Y.config.doc

- `firstOnly` Boolean

  optional Whether or not to return only the first match.

#### Returns:

Array: An array of nodes that match the given 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