selector-native-debug.js revision 93e7d06d2c6eca3a7b6910ad473b09e9dcc0a15c
(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';
var Selector = {
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 = '',
id,
i,
len;
if (node) {
// enforce for element scoping
if (!id) {
}
}
}
}
return queries;
},
(Y.Selector.pseudos && Y.Selector.pseudos.checked)) { // webkit (chrome, safari) fails to pick up "selected" with "checked"
}
try {
//Y.log('trying native query with: ' + selector, 'info', 'selector-native');
} catch(e) { // fallback to brute if available
//Y.log('native query error; reverting to brute query with: ' + selector, 'info', 'selector-native');
}
},
var ret = [],
i, node;
}
}
} else {
}
return ret;
},
var ret = false,
useFrag = false,
item,
frag,
id,
i, j, group;
} else { // test with query
// we need a root if off-doc
if (parent) {
} else { // only use frag when no parent to query
useFrag = true;
}
}
if (!id) {
}
ret = true;
break;
}
}
if (ret) {
break;
}
}
if (useFrag) { // cleanup
}
};
}
return ret;
},
/**
* A convenience function to emulate Y.Node's aNode.ancestor(selector).
* @param {HTMLElement} element An HTMLElement to start the query from.
* @param {String} selector The CSS selector to test the node against.
* @return {HTMLElement} The ancestor node matching the selector, or null.
* @param {Boolean} testSelf optional Whether or not to include the element in the scan
* @static
* @method ancestor
*/
}, testSelf);
}
};
})(Y);