dom-debug.js revision 14dc4f889a7b6c39f10aa490ea3c4c69de5e99bb
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore(function(Y) {
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * The DOM utility provides a cross-browser abtraction layer
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore * normalizing DOM tasks, and adds extra helper functionality
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * for other common tasks.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @module dom
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @submodule dom-base
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * Provides DOM helper methods.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @class DOM
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore COMPARE_DOCUMENT_POSITION = 'compareDocumentPosition',
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore re_tag = /<([a-z]+)/i,
f0a82c6a29c12f3a85bdc740203affbbe75ce665Luke Smith if (!div.firstChild || div.firstChild.tagName !== tag) {
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * Returns the HTMLElement with the given ID (Wrapper for document.getElementById).
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * @method byId
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @param {String} id the id attribute
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @param {Object} doc optional The document to search. Defaults to current document
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @return {HTMLElement | null} The HTMLElement with the id, or null if none found.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore // handle dupe IDs and IE name collision
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * Returns the text content of the HTMLElement.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * @method getText
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * @param {HTMLElement} element The html element.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * @return {String} The text content of the element (includes text of any descending elements).
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore getText: (documentElement.textContent !== undefined) ?
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore } : function(element) {
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore ret = element.innerText || element.nodeValue; // might be a textNode
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * Sets the text content of the HTMLElement.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @method setText
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {HTMLElement} element The html element.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {String} content The content to add.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore setText: (documentElement.textContent !== undefined) ?
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * Finds the ancestor of the element.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @method ancestor
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @param {HTMLElement} element The html element.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @param {Function} fn optional An optional boolean test to apply.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * The optional function is passed the current DOM node being tested as its only argument.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * If no function is given, the parentNode is returned.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {Boolean} testSelf optional Whether or not to include the element in the scan
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @return {HTMLElement | null} The matching DOM node or null if none found.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore return ret || Y_DOM.elementByAxis(element, PARENT_NODE, fn, null);
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * Finds the ancestors of the element.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @method ancestors
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @param {HTMLElement} element The html element.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @param {Function} fn optional An optional boolean test to apply.
057b95e2faede12bf00a82837632ae67e03ad0fcAdam Moore * The optional function is passed the current DOM node being tested as its only argument.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * If no function is given, all ancestors are returned.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {Boolean} testSelf optional Whether or not to include the element in the scan
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @return {Array} An array containing all matching DOM nodes.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore var ancestor = Y_DOM.ancestor.apply(Y_DOM, arguments),
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore while ((ancestor = Y_DOM.ancestor(ancestor, fn))) {
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * Searches the element by the given axis for the first matching element.
057b95e2faede12bf00a82837632ae67e03ad0fcAdam Moore * @method elementByAxis
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * @param {HTMLElement} element The html element.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {String} axis The axis to search (parentNode, nextSibling, previousSibling).
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {Function} fn optional An optional boolean test to apply.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {Boolean} all optional Whether all node types should be returned, or just element nodes.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * The optional function is passed the current HTMLElement being tested as its only argument.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * If no function is given, the first element is returned.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @return {HTMLElement | null} The matching element or null if none found.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore elementByAxis: function(element, axis, fn, all) {
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore while (element && (element = element[axis])) { // NOTE: assignment
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore if ( (all || element[TAG_NAME]) && (!fn || fn(element)) ) {
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore return null;
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * Determines whether or not one HTMLElement is or contains another HTMLElement.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * @method contains
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @param {HTMLElement} element The containing html element.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @param {HTMLElement} needle The html element that may be contained.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore * @return {Boolean} Whether or not the element is or contains the needle.
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore var ret = false;
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore if ( !needle || !element || !needle[NODE_TYPE] || !element[NODE_TYPE]) {
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore if (Y.UA.opera || needle[NODE_TYPE] === 1) { // IE & SAF contains fail if needle not an ELEMENT_NODE
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore } else if (element[COMPARE_DOCUMENT_POSITION]) { // gecko
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore if (element === needle || !!(element[COMPARE_DOCUMENT_POSITION](needle) & 16)) {
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * Determines whether or not the HTMLElement is part of the document.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @method inDoc
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {HTMLElement} element The containing html element.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {HTMLElement} doc optional The document to check.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @return {Boolean} Whether or not the element is attached to the document.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore var ret = false,
e69255aa5a65f8406ba2fabaf69fe4e1d05daf69Adam Moore // contains only works with HTML_ELEMENT
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore if (rootNode && rootNode.contains && element.tagName) {
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore ret = root.querySelectorAll('[id="' + id + '"]');
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore if (nodes && nodes.nodeType) { // root.all may return one or many
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore for (i = 0; node = nodes[i++];) { // check for a match
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore && node.attributes.id.value === id) { // avoid false positive for node.name & form.id
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore * Creates a new dom node using the provided markup string.
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore * @method create
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore * @param {String} html The markup used to create the element
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore * @param {HTMLDocument} doc An optional document context
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore * @return {HTMLElement|DocumentFragment} returns a single HTMLElement
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore * when creating one node, and a documentFragment when creating
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore * multiple nodes.
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore html = Y.Lang.trim(html); // match IE which trims whitespace from innerHTML
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore if (html != undefined) { // not undefined or null
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore if (nodes.length === 1) { // return single node, breaking parentNode ref from "fragment"
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore } else if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected)
d1f171a81a8b50c0f694f3dd1ea7ccc08e86cf55Adam Moore } else { // return multiple nodes as a fragment
6a3faa9e0e4639febffbd7018ce47b861626d0baAdam Moore if (nodes && (nodes.push || nodes.item) && nodes[0]) {
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore if (nodes.item) { // convert live list to static array
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore } // else inline with log for minification
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore else { Y.log('unable to convert ' + nodes + ' to fragment', 'warn', 'dom'); }
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore CUSTOM_ATTRIBUTES: (!documentElement.hasAttribute) ? { // IE < 8
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore } : { // w3c
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * Provides a normalized attribute interface.
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * @method setAttibute
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * @param {String | HTMLElement} el The target element for the attribute.
6a3faa9e0e4639febffbd7018ce47b861626d0baAdam Moore * @param {String} attr The attribute to set.
6a3faa9e0e4639febffbd7018ce47b861626d0baAdam Moore * @param {String} val The value of the attribute.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore else { Y.log('bad input to setAttribute', 'warn', 'dom'); }
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * Provides a normalized attribute interface.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @method getAttibute
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {String | HTMLElement} el The target element for the attribute.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {String} attr The attribute to get.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @return {String} The current value of the attribute.
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore if (ret === null) {
df39d9c816a02c79aa6a3436784de5bba0ef7075Adam Moore else { Y.log('bad input to getAttribute', 'warn', 'dom'); }
2f03ba9e07559709925bfe6cb1b40c83aa810672Adam Moore frag = Y_DOM._fragClones[tag] = doc.createElement(tag);
03f9aefec605c500b64625110a955e65b900b100Adam Moore * Inserts content in a node at the given location
03f9aefec605c500b64625110a955e65b900b100Adam Moore * @method addHTML
2f03ba9e07559709925bfe6cb1b40c83aa810672Adam Moore * @param {HTMLElement} node The node to insert into
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore * @param {String | HTMLElement | Array | HTMLCollection} content The content to be inserted
03f9aefec605c500b64625110a955e65b900b100Adam Moore * @param {String | HTMLElement} where Where to insert the content
03f9aefec605c500b64625110a955e65b900b100Adam Moore * If no "where" is given, content is appended to the node
03f9aefec605c500b64625110a955e65b900b100Adam Moore * Possible values for "where"
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * <dt>HTMLElement</dt>
03f9aefec605c500b64625110a955e65b900b100Adam Moore * <dd>The element to insert before</dd>
03f9aefec605c500b64625110a955e65b900b100Adam Moore * <dt>"replace"</dt>
03f9aefec605c500b64625110a955e65b900b100Adam Moore * <dd>Replaces the existing HTML</dd>
03f9aefec605c500b64625110a955e65b900b100Adam Moore * <dt>"before"</dt>
2f03ba9e07559709925bfe6cb1b40c83aa810672Adam Moore * <dd>Inserts before the existing HTML</dd>
03f9aefec605c500b64625110a955e65b900b100Adam Moore * <dt>"before"</dt>
03f9aefec605c500b64625110a955e65b900b100Adam Moore * <dd>Inserts content before the node</dd>
772f655fcf57e58b97fa46b6a8d3fc772b83f743Adam Moore * <dt>"after"</dt>
f89b4dd628000da1b003539c3c181e6b9880de00Adam Moore * <dd>Inserts content after the node</dd>
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore if (content != undefined) { // not null or undefined (maybe 0)
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore } else if (typeof content == 'string' || typeof content == 'number') {
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore } else if (content[0] && content[0].nodeType) { // array or collection
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore newNode.appendChild(item); // append to fragment for insertion
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore if (where.nodeType) { // insert regardless of relationship to node
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore case 'replace':
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore if (newNode) { // allow empty content to clear node
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore case 'before':
3641f0baf10c9737e4ac6aac1566bfeaca00eeffAdam Moore case 'after':
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore if (node.nextSibling) { // IE errors if refNode is null
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore nodeParent.insertBefore(newNode, node.nextSibling);
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore } else if (newNode) {
bc8660dcb747bedc141ca9061de83f6f32f8018fAdam Moore getter = Y_DOM.VALUE_GETTERS[node[TAG_NAME].toLowerCase()];
5cbcc8e7f5c3e4ad283e5cb76520840300f81a0aAdam Moore // workaround for IE8 JSON stringify bug
5cbcc8e7f5c3e4ad283e5cb76520840300f81a0aAdam Moore // which converts empty string values to null
5cbcc8e7f5c3e4ad283e5cb76520840300f81a0aAdam Moore setter = Y_DOM.VALUE_SETTERS[node[TAG_NAME].toLowerCase()];
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore * Brute force version of contains.
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore * Used for browsers without contains support for non-HTMLElement Nodes (textNodes, etc).
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore * @method _bruteContains
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore * @param {HTMLElement} element The containing html element.
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore * @param {HTMLElement} needle The html element that may be contained.
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore * @return {Boolean} Whether or not the element is or contains the needle.
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore return true;
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore return false;
38ede344a04d04daedd560a485bd38f50e4c0a71Adam Moore// TODO: move to Lang?
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * Memoizes dynamic regular expressions to boost runtime performance.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @method _getRegExp
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @param {String} str The string to convert to a regular expression.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @param {String} flags optional An optinal string of flags.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @return {RegExp} An instance of RegExp
f0a82c6a29c12f3a85bdc740203affbbe75ce665Luke Smith Y_DOM._regexCache[str + flags] = new RegExp(str, flags);
f841387cb4997959ecf710977b259b86f959ba48Luke Smith// TODO: make getDoc/Win true privates?
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * returns the appropriate document.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @method _getDoc
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @param {HTMLElement} element optional Target element.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @return {Object} The document for the given element or the default document.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith doc = (element[NODE_TYPE] === 9) ? element : // element === document
f841387cb4997959ecf710977b259b86f959ba48Luke Smith element[OWNER_DOCUMENT] || // element === DOM node
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * returns the appropriate window.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @method _getWin
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @param {HTMLElement} element optional Target element.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith * @return {Object} The window for the given element or the default window.
f841387cb4997959ecf710977b259b86f959ba48Luke Smith return doc[DEFAULT_VIEW] || doc[PARENT_WINDOW] || Y.config.win;
f841387cb4997959ecf710977b259b86f959ba48Luke Smith _batch: function(nodes, fn, arg1, arg2, arg3, etc) {
f841387cb4997959ecf710977b259b86f959ba48Luke Smith result = result = fn.call(Y_DOM, node, arg1, arg2, arg3, etc);
f841387cb4997959ecf710977b259b86f959ba48Luke Smith return (typeof ret !== 'undefined') ? ret : nodes;
if (parent) {
if (grandparent) {
creators: {}
return frag;
return frag;
if (!attr) {
return create('<select><option class="yui3-big-dummy" selected></option>' + html + '</select>', doc);
return val;
if (add) {
VENDOR_TRANSFORM = [
if (style) {
if (style) {
return val;
}, Y_DOM);
return val;
return val;
return val;
return val;
var pos,
xy = null;
if (node) {
xy = [
return xy;
RE = RegExp;
Y.Color = {
KEYWORDS: {
return val;
val = [
TODO: test inDocument/display?
getXY: function() {
return function(node) {
var xy = null,
box,
mode,
doc,
if (inDoc) {
return xy;
var xy = null,
doc,
if (node) {
if (bCheck) {
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 Selector = {
_foundCache: [],
useNative: true,
return compare;
if (nodes) {
return nodes;
var ret = [],
i, node;
return ret;
* @param {HTMLElement} root optional An HTMLElement to start the query from. Defaults to Y.config.doc
var ret = [],
if (result) {
queries = [],
i, len;
if (node) {
return queries;
(Y.Selector.pseudos && Y.Selector.pseudos.checked)) { // webkit (chrome, safari) fails to find "selected"
//Y.log('native query error; reverting to brute query with: ' + selector, 'info', 'selector-native');
var ret = [],
i, node;
return ret;
var ret = false,
useFrag = false,
item,
frag,
i, j, group;
if (parent) {
useFrag = true;
ret = true;
if (ret) {
return ret;
}, testSelf);
SelectorCSS2 = {
SORT_RESULTS: true,
children = [],
ret = [];
return ret || [];
_re: {
attr: /(\[[^\]]*\])/g,
'': function(node, attr) { return Y.DOM.getAttribute(node, attr) !== ''; }, // Just test for existence of attribute
Y.config.doc.documentElement.getElementsByClassName &&
tagName: null,
id: null,
className: null,
attributes: {},
combinator: null,
tests: []
test,
i, parser;
found = false;
break outer;
} else if (test) {
found = true;
tokens = [];
return tokens;
pseudos = selector.match(Selector._re.pseudos), // pull attributes to avoid false pos on "." and "#"
if (pseudos) {
if (attrs) {
if (attrs) {
if (pseudos) {
return selector;
_attrFilters: {
getters: {