# Yahoo! UI Library

### dom 2.9.0

Yahoo! UI Library > dom > YAHOO.util.Selector
Search:
Filters Show Private Show Protected Show Deprecated

## `static` Class YAHOO.util.Selector

Provides support for using CSS selectors to query the DOM

### Properties

#### attrAliases - `object`

Mapping of attributes to aliases, normally to work around HTMLAttributes that conflict with JS reserved words.

#### document - `object`

Default document for use queries
Default Value: window.document

#### operators - `object`

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

#### PARENT_NODE - `object`

Provides helper methods for collecting and filtering DOM elements.

#### pseudos - `object`

List of pseudo-classes and corresponding boolean functions. These functions are called with the current node, and any value that was parsed with the pseudo regex.

#### shorthand - `object`

Mapping of shorthand tokens to corresponding attribute selector

### Methods

#### _tokenize

`void _tokenize ( )`
Break selector into token units per simple selector. Combinator is attached to the previous token.

#### filter

`static array filter ( nodes , selector )`
Filters a set of nodes based on a given CSS selector.

Parameters:
  `nodes <array>` A set of nodes/ids to filter.
  `selector <string>` The selector used to test each node.

Returns: `array`
  An array of nodes from the supplied array that match the given selector.

#### query

`static Array query ( selector , root , firstOnly )`
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.

#### test

`static boolean test ( node , selector )`
Test if the supplied node matches the supplied selector.

Parameters:
  `node <HTMLElement | String>` An id or node reference to the HTMLElement being tested.
  `selector <string>` The CSS Selector to test the node against.

Returns: `boolean`
  Whether or not the node matches the selector.

Copyright © 2011 Yahoo! Inc. All rights reserved.