mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
4b1293771d
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92542 467b73ca-7a2a-4603-9d3b-597d59a354a9
33 lines
1.5 KiB
Plaintext
33 lines
1.5 KiB
Plaintext
h1. jQuery Selector
|
|
|
|
h3. Selector tools and reverse mapping for jQuery
|
|
|
|
* Parse and examine the AST for a selector
|
|
* Calculate the specifity of a selector
|
|
* Determine if a single element matches a selector ($().is equivilent) much faster that jQuery
|
|
|
|
h3. Intro
|
|
|
|
jQuery has an excellent CSS 3 selector engine built in called Sizzle. However, it's clear focus is on filtering a set of elements down to the set that matches a selector.
|
|
|
|
jQuery.concrete has a usage pattern quite different from that optimized for by Sizzle. It reuses a small set of selectors (making a more complicated initial parsing step acceptable)
|
|
and checks if a single element matches those selectors. In this case, Sizzle can be quite slow.
|
|
|
|
h3. Usage
|
|
|
|
Usual usage of jQuery selector:
|
|
|
|
var sel = $.selector('#foo');
|
|
sel.matches(element);
|
|
|
|
element must be a raw DOM object, not a jQuery element, sequence of elements or anything else
|
|
|
|
h3. Compatibility
|
|
|
|
jQuery.selector aims to be 100% compatible with Sizzle (except a couple of corner cases, noted below). Sizzle implements most of the CSS 3 spec plus several extensions.
|
|
|
|
One set of extensions Sizzle has is a set of pseudo-classes that filter the currently selected set. These pseudo-classes are ':first', ':last', ':even', ':odd', ':eq', ':nth', ':lt', ':gt'.
|
|
These pseudo-classes are not supported in jQuery.selector, as they don't make sense when the working set is always a single element.
|
|
|
|
jQuery.selector currently passes the jQuery selector unit test suite, with the exception of the psuedo-classes mentioned above
|