selector-native.js revision 4b3422f596d413a5998e791e1927c050691ce27e
(function(Y) {
/**
* The selector-native module provides support for native querySelector
* @module dom
* @submodule selector-native
* @for Selector
*/
/**
* Provides support for using CSS selectors to query the DOM
* @class Selector
* @static
* @for Selector
*/
var COMPARE_DOCUMENT_POSITION = 'compareDocumentPosition',
OWNER_DOCUMENT = 'ownerDocument',
TMP_PREFIX = 'yui-tmp-',
g_counter = 0;
var Selector = {
_foundCache: [],
useNative: true,
var a = nodeA.sourceIndex,
b = nodeB.sourceIndex;
if (a === b) {
return 0;
} else if (a > b) {
return 1;
}
return -1;
return -1;
} else {
return 1;
}
} :
}
return compare;
}),
if (nodes) {
}
}
return nodes;
},
var ret = [],
i, node;
}
}
}
return ret;
},
/**
* Retrieves a set of nodes based on a given CSS selector.
* @method query
*
* @param {string} selector The CSS Selector to test the node against.
* @param {HTMLElement} root optional An HTMLElement to start the query from. Defaults to Y.config.doc
* @param {Boolean} firstOnly optional Whether or not to return only the first match.
* @return {Array} An array of nodes that match the given selector.
* @static
*/
var ret = [],
i,
// split group into seperate queries
if (!skipNative && // already done if skipping
}
if (!firstOnly) { // coerce DOM Collection to Array
}
if (result) {
}
}
}
}
},
// allows element scoped queries to begin with combinator
// e.g. query('> p', document.body) === query('body > p')
queries = [],
prefix = '',
i, len;
if (node) {
// enforce for element scoping
}
}
}
return queries;
},
try {
} catch(e) { // fallback to brute if available
}
},
var ret = [],
i, node;
}
}
} else {
}
return ret;
},
var ret = false,
item,
i, group;
}
//group += '#' + node.id; // add ID for uniqueness
if (ret) {
break;
}
}
}
return ret;
}
};
})(Y);