Yahoo! UI Library

Selector Utility  2.5.1

Yahoo! UI Library > selector > YAHOO.util.Selector

Show Private Show Protected

static Class YAHOO.util.Selector

Provides helper methods for collecting and filtering DOM elements.

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.

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

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 | String> optional An id or HTMLElement to start the query from. Defaults to Selector.document.
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.

tokenize

void tokenize ( )
Break selector into token units per simple selector. Combinator is attached to left-hand selector.
Returns: void


Copyright © 2007 Yahoo! Inc. All rights reserved.