dom.js revision 7f301ced05415668ede239d3d16fe4a4199754e6
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp(function(Y) {
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * The DOM utility provides a cross-browser abtraction layer
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * normalizing DOM tasks, and adds extra helper functionality
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * for other common tasks.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @module dom
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @submodule dom-base
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Provides DOM helper methods.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @class DOM
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp COMPARE_DOCUMENT_POSITION = 'compareDocumentPosition',
422668e1d4513bb870b8b576fd9d828c8872f074Tripp re_tag = /<([a-z]+)/i;
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Returns the HTMLElement with the given ID (Wrapper for document.getElementById).
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method byId
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {String} id the id attribute
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {Object} doc optional The document to search. Defaults to current document
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @return {HTMLElement | null} The HTMLElement with the id, or null if none found.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp // TODO: IE Name
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Returns the text content of the HTMLElement.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method getText
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} element The html element.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @return {String} The text content of the element (includes text of any descending elements).
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp getText: (document.documentElement.textContent !== undefined) ?
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp function(element) {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp } : function(element) {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Returns the text content of the HTMLElement.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getText
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} element The html element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @return {String} The text content of the element (includes text of any descending elements).
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp setText: (document.documentElement.textContent !== undefined) ?
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp// TODO: pull out sugar (rely on _childBy, byAxis, etc)?
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Finds the firstChild of the given HTMLElement.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method firstChild
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {HTMLElement} element The html element.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {Function} fn optional An optional boolean test to apply.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * The optional function is passed the current HTMLElement being tested as its only argument.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * If no function is given, the first found is returned.
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp * @return {HTMLElement | null} The first matching child html element.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Finds the lastChild of the given HTMLElement.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method lastChild
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp * @param {HTMLElement} element The html element.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {String} tag The tag to search for.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {Function} fn optional An optional boolean test to apply.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * The optional function is passed the current HTMLElement being tested as its only argument.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * If no function is given, the first found is returned.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @return {HTMLElement | null} The first matching child html element.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * Finds all HTMLElement childNodes matching the given tag.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method childrenByTag
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {HTMLElement} element The html element.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {String} tag The tag to search for.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {Function} fn optional An optional boolean test to apply.
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * The optional function is passed the current HTMLElement being tested as its only argument.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * If no function is given, all children with the given tag are collected.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @return {Array} The collection of child elements.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * TODO: deprecate? Webkit children.tags() returns grandchildren
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp _childrenByTag: function() {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return function(element, tag, fn, toArray) { // TODO: keep toArray option?
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp tag = (tag && tag !== '*') ? tag.toUpperCase() : null;
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp if (tag && !Y.UA.webkit) { // children.tags() broken in safari
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return el[TAG_NAME].toUpperCase() === tag && (!fn || fn(el));
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tag = (tag && tag !== '*') ? tag.toUpperCase() : null;
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp if (tag) { // wrap fn and add tag test TODO: allow tag in filterElementsBy?
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return el[TAG_NAME].toUpperCase() === tag && (!fn || fn(el));
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Finds all HTMLElement childNodes.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method children
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} element The html element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Function} fn optional An optional boolean test to apply.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * The optional function is passed the current HTMLElement being tested as its only argument.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * If no function is given, all children are collected.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @return {Array} The collection of child elements.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Finds the previous sibling of the element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method previous
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} element The html element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Function} fn optional An optional boolean test to apply.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * The optional function is passed the current DOM node being tested as its only argument.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * If no function is given, the first sibling is returned.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Boolean} all optional Whether all node types should be scanned, or just element nodes.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @return {HTMLElement | null} The matching DOM node or null if none found.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return Y.DOM.elementByAxis(element, PREVIOUS_SIBLING, fn, all);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Finds the next sibling of the element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method next
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} element The html element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Function} fn optional An optional boolean test to apply.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * The optional function is passed the current DOM node being tested as its only argument.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * If no function is given, the first sibling is returned.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Boolean} all optional Whether all node types should be scanned, or just element nodes.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @return {HTMLElement | null} The matching DOM node or null if none found.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return Y.DOM.elementByAxis(element, NEXT_SIBLING, fn, all);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Finds the ancestor of the element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method ancestor
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} element The html element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Function} fn optional An optional boolean test to apply.
6aa3a8d9176704373c2e24b0530b508f643fe6a0Tripp * The optional function is passed the current DOM node being tested as its only argument.
6aa3a8d9176704373c2e24b0530b508f643fe6a0Tripp * If no function is given, the parentNode is returned.
6aa3a8d9176704373c2e24b0530b508f643fe6a0Tripp * @param {Boolean} all optional Whether all node types should be scanned, or just element nodes.
6aa3a8d9176704373c2e24b0530b508f643fe6a0Tripp * @return {HTMLElement | null} The matching DOM node or null if none found.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp // TODO: optional stopAt node?
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp return Y.DOM.elementByAxis(element, PARENT_NODE, fn, all);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Searches the element by the given axis for the first matching element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method elementByAxis
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} element The html element.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {String} axis The axis to search (parentNode, nextSibling, previousSibling).
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Function} fn optional An optional boolean test to apply.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Boolean} all optional Whether all node types should be returned, or just element nodes.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * The optional function is passed the current HTMLElement being tested as its only argument.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * If no function is given, the first element is returned.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @return {HTMLElement | null} The matching element or null if none found.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp while (element && (element = element[axis])) { // NOTE: assignment
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp if ( (all || element[TAG_NAME]) && (!fn || fn(element)) ) {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return null;
6aa3a8d9176704373c2e24b0530b508f643fe6a0Tripp * Finds all elements with the given tag.
6aa3a8d9176704373c2e24b0530b508f643fe6a0Tripp * @method byTag
6aa3a8d9176704373c2e24b0530b508f643fe6a0Tripp * @param {String} tag The tag being search for.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {HTMLElement} root optional An optional root element to start from.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Function} fn optional An optional boolean test to apply.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * The optional function is passed the current HTMLElement being tested as its only argument.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * If no function is given, all elements with the given tag are returned.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @return {Array} The collection of matching elements.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Finds the first element with the given tag.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method firstByTag
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {String} tag The tag being search for.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} root optional An optional root element to start from.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {Function} fn optional An optional boolean test to apply.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * The optional function is passed the current HTMLElement being tested as its only argument.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * If no function is given, the first match is returned.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @return {HTMLElement} The matching element.
c8497af565e3869417da55c16f0afc9fafb7d79aTripp * Filters a collection of HTMLElements by the given attributes.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method filterElementsBy
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {Array} elements The collection of HTMLElements to filter.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {Function} fn A boolean test to apply.
c8497af565e3869417da55c16f0afc9fafb7d79aTripp * The function is passed the current HTMLElement being tested as its only argument.
c8497af565e3869417da55c16f0afc9fafb7d79aTripp * If no function is given, all HTMLElements are kept.
f4bca85db4b211c6b3afe1f319ae46cebe62992dTripp * @return {Array} The filtered collection of HTMLElements.
f4bca85db4b211c6b3afe1f319ae46cebe62992dTripp if (elements[i][TAG_NAME] && (!fn || fn(elements[i]))) {
c8497af565e3869417da55c16f0afc9fafb7d79aTripp * Determines whether or not one HTMLElement is or contains another HTMLElement.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method contains
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {HTMLElement} element The containing html element.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {HTMLElement} needle The html element that may be contained.
c8497af565e3869417da55c16f0afc9fafb7d79aTripp * @return {Boolean} Whether or not the element is or contains the needle.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var ret = false;
c8497af565e3869417da55c16f0afc9fafb7d79aTripp if ( !needle || !element || !needle[NODE_TYPE] || !element[NODE_TYPE]) {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if (Y.UA.opera || needle[NODE_TYPE] === 1) { // IE & SAF contains fail if needle not an ELEMENT_NODE
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp } else if (element[COMPARE_DOCUMENT_POSITION]) { // gecko
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if (element === needle || !!(element[COMPARE_DOCUMENT_POSITION](needle) & 16)) {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Determines whether or not the HTMLElement is part of the document.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method inDoc
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {HTMLElement} element The containing html element.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {HTMLElement} doc optional The document to check.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @return {Boolean} Whether or not the element is attached to the document.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Inserts the new node as the previous sibling of the reference node
4beb671b9f23325489cc74a7950f2b1f1420b5f3Tripp * @method insertBefore
4beb671b9f23325489cc74a7950f2b1f1420b5f3Tripp * @param {String | HTMLElement} newNode The node to be inserted
4beb671b9f23325489cc74a7950f2b1f1420b5f3Tripp * @param {String | HTMLElement} referenceNode The node to insert the new node before
4beb671b9f23325489cc74a7950f2b1f1420b5f3Tripp * @return {HTMLElement} The node that was inserted (or null if insert fails)
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var ret = null,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp if (newNode && referenceNode && (parent = referenceNode.parentNode)) { // NOTE: assignment
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Inserts the new node as the next sibling of the reference node
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method insertAfter
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {String | HTMLElement} newNode The node to be inserted
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {String | HTMLElement} referenceNode The node to insert the new node after
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @return {HTMLElement} The node that was inserted (or null if insert fails)
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp if (!newNode || !referenceNode || !referenceNode[PARENT_NODE]) {
422668e1d4513bb870b8b576fd9d828c8872f074Tripp return null;
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return referenceNode[PARENT_NODE].insertBefore(newNode, referenceNode[NEXT_SIBLING]);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return referenceNode[PARENT_NODE].appendChild(newNode);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Creates a new dom node using the provided markup string.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method create
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {String} html The markup used to create the element
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @param {HTMLDocument} doc An optional document context
ret = null,
return ret;
if (ret === null) {
return ret;
function(node) {
function(node) {
_fragClones: {
if (frag) {
return frag;
_cloneCache: {},
var scripts,
if (newNode) {
if (where) {
switch (where) {
if (execScripts) {
} else if (content.nodeType || content.indexOf('<script') > -1) { // prevent any scripts from being injected
return newNode;
VALUE_SETTERS: {},
VALUE_GETTERS: {},
if (getter) {
var setter;
if (setter) {
i, script;
var newScript,
i, script;
setTimeout(function() {
while (needle) {
var ret = null,
if (element) {
if (rev) {
return ret;
var result,
ret = [];
creators: {},
return frag;
return frag;
if (!attr) {
return val;
if (style) {
if (val === null) {
if (style) {
return val;
}, Y.DOM);
return val;
return val;
return val;
RE = RegExp;
Y.Color = {
KEYWORDS: {
return val;
val = [
ComputedStyle = {
CUSTOM_STYLES: {},
if (el) {
return value;
if (!el.style[pixel] && !el.style[prop]) { // need to map style.width to currentStyle (no currentStyle.pixelWidth)
// clientHeight/Width = paddingBox (e.g. offsetWidth - borderWidth)
var value = null;
switch(property) {
case BORDER_TOP_WIDTH:
case BORDER_BOTTOM_WIDTH:
case BORDER_LEFT_WIDTH:
case BORDER_RIGHT_WIDTH:
var val = null,
return val;
var val,
var current;
IEComputed = {};
} catch(err) {
var current,
TODO: test inDocument/display
getXY: function() {
return function(node) {
var xy = null,
box,
mode,
doc;
if (node) {
return xy;
var xy = null,
if (node) {
if (bCheck) {
return xy;
var pos,
xy = null;
if (node) {
xy = [
return xy;
* The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
pos,
if (!noRetry) {
* Set the X position of an html element in page coordinates, regardless of how the element is positioned.
* The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
* Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
* The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
return xy2;
ret = {};
return ret;
@return {Object} Object literal containing the following about this element: (top, right, bottom, left)
ret = false;
return ret;
* @param {Object} altRegion An object literal containing the region for the first element if we already have the data (for performance i.e. DragDrop)
@return {Object} Object literal containing the following intersection data: (top, right, bottom, left, area, yoff, xoff, inRegion)
n = node2,
off;
if (n.tagName) {
* @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance i.e. DragDrop)
var region = {},
n = node2,
off;
if (n.tagName) {
if (all) {
* @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance i.e. DragDrop)
_getRegion: function(t, r, b, l) {
var region = {};
return region;
* Returns an Object literal containing the following about the visible region of viewport: (top, right, bottom, left)
@return {Object} Object literal containing the following about the visible region of the viewport: (top, right, bottom, left)
var ret = false,
if (node) {
return ret;
var NativeSelector = {
_reUnSupported: /!./,
_foundCache: [],
_supportsNative: function() {
i, len;
ret = [];
return ret;
_clearFoundCache: function() {
i, len;
foundCache = [];
if (nodes) {
return nodes;
var ret = [],
i, node;
return ret;
queries = [],
i, len;
if (root) {
if (!isDocRoot) {
return queries;
i, query;
if (selector) {
ret = [];
return ret;
var ret = [],
i, node;
return ret;
var ret = false,
id,
item,
i, group;
if (ret) {
return ret;
SelectorCSS2 = {
SORT_RESULTS: true,
ret = [];
if (n.tagName) {
return ret || [];
_regexCache: {},
_re: {
attr: /(\[.*\])/g,
shorthand: {
operators: {
'': function(node, m) { return Y.DOM.getAttribute(node, m[0]) !== ''; }, // Just test for existence of attribute
pseudos: {
_brute: {
* @param {HTMLElement} root optional An HTMLElement to start the query from. Defaults to Y.config.doc
var ret = [];
if (selector) {
_cleanup: function() {
_childCache = [];
var ret = [],
nodes = [],
i, len;
if (token) {
if (deDupe) {
if (firstOnly) {
return ret;
test,
attr;
combinators: {
_parsers: [