| pseudos : ObjectObject hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
-two... Object hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
-two parameters:
- A filter function returns an Array of DOM elements which conform to the pseudo class.
- In addition to the provided pseudo classes listed above such as first-child and nth-child ,
-developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.
- For example, to filter <a> elements to only return links to external resources:
-
-Ext.DomQuery.pseudos.external = function(c, v){
- var r = [], ri = -1;
- for(var i = 0, ci; ci = c[i]; i++){
-// Include in result set only if it's a link to an external resource
- if(ci.hostname != location.hostname){
- r[++ri] = ci;
- }
- }
- return r;
-};
-Then external links could be gathered with the following statement:
+Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).
+
+DomQuery supports most of the CSS3 selectors spec, along with some custom selectors and basic XPath.
+
+
+All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example "div.foo:nth-child(odd)[@foo=bar].bar:first" would be a perfectly valid selector. Node filters are processed in the order in which they appear, which allows you to optimize your queries for your document structure.
+
+ Element Selectors:
+
+ - * any element
+ - E an element with the tag E
+ - E F All descendent elements of E that have the tag F
+ - E > F or E/F all direct children elements of E that have the tag F
+ - E + F all elements with the tag F that are immediately preceded by an element with the tag E
+ - E ~ F all elements with the tag F that are preceded by a sibling element with the tag E
+
+ Attribute Selectors:
+ The use of @ and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.
+
+ - E[foo] has an attribute "foo"
+ - E[foo=bar] has an attribute "foo" that equals "bar"
+ - E[foo^=bar] has an attribute "foo" that starts with "bar"
+ - E[foo$=bar] has an attribute "foo" that ends with "bar"
+ - E[foo*=bar] has an attribute "foo" that contains the substring "bar"
+ - E[foo%=2] has an attribute "foo" that is evenly divisible by 2
+ - E[foo!=bar] has an attribute "foo" that does not equal "bar"
+
+ Pseudo Classes:
+
+ - E:first-child E is the first child of its parent
+ - E:last-child E is the last child of its parent
+ - E:nth-child(n) E is the nth child of its parent (1 based as per the spec)
+ - E:nth-child(odd) E is an odd child of its parent
+ - E:nth-child(even) E is an even child of its parent
+ - E:only-child E is the only child of its parent
+ - E:checked E is an element that is has a checked attribute that is true (e.g. a radio or checkbox)
+ - E:first the first E in the resultset
+ - E:last the last E in the resultset
+ - E:nth(n) the nth E in the resultset (1 based)
+ - E:odd shortcut for :nth-child(odd)
+ - E:even shortcut for :nth-child(even)
+ - E:contains(foo) E's innerHTML contains the substring "foo"
+ - E:nodeValue(foo) E contains a textNode with a nodeValue that equals "foo"
+ - E:not(S) an E element that does not match simple selector S
+ - E:has(S) an E element that has a descendent that matches simple selector S
+ - E:next(S) an E element whose next sibling matches simple selector S
+ - E:prev(S) an E element whose previous sibling matches simple selector S
+ - E:any(S1|S2|S2) an E element which matches any of the simple selectors S1, S2 or S3//\\
+
+ CSS Value Selectors:
+
+ - E{display=none} css value "display" that equals "none"
+ - E{display^=none} css value "display" that starts with "none"
+ - E{display$=none} css value "display" that ends with "none"
+ - E{display*=none} css value "display" that contains the substring "none"
+ - E{display%=2} css value "display" that is evenly divisible by 2
+ - E{display!=none} css value "display" that does not equal "none"
+ This class is a singleton and cannot be created directly.Public Properties|
| matchers : ObjectCollection of matching regular expressions and code snippets.
+Each capture group within () will be replace the {} in ... Collection of matching regular expressions and code snippets.
+Each capture group within () will be replace the {} in the select
+statement as specified by their index. | DomQuery | | pseudos : ObjectObject hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
+two ... Object hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
+two parameters:
+ A filter function returns an Array of DOM elements which conform to the pseudo class.
+ In addition to the provided pseudo classes listed above such as first-child and nth-child ,
+developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.
+ For example, to filter <a> elements to only return links to external resources:
+
+Ext.DomQuery.pseudos.external = function(c, v){
+ var r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+// Include in result set only if it's a link to an external resource
+ if(ci.hostname != location.hostname){
+ r[++ri] = ci;
+ }
+ }
+ return r;
+};
+Then external links could be gathered with the following statement:
var externalLinks = Ext.select("a:external");
| DomQuery |
Public Methods|
| compile( String selector , [String type ] )
:
- FunctionCompiles a selector/xpath query into a reusable function. The returned function
-takes one parameter "root" (optional... Compiles a selector/xpath query into a reusable function. The returned function
+ Function Compiles a selector/xpath query into a reusable function. The returned function
+takes one parameter "root" (optional)... Compiles a selector/xpath query into a reusable function. The returned function
takes one parameter "root" (optional), which is the context node from where the query should start. | DomQuery | | filter( Array el , String selector , Boolean nonMatches )
:
- ArrayFilters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child) Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child) Parameters:el : ArrayAn array of elements to filter selector : StringThe simple selector to test nonMatches : BooleanIf true, it returns the elements that DON'T match
-the selector instead of the ones that match Returns:Array An Array of DOM elements which match the selector. If there are
+ Array Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child) Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child) Parameters:el : ArrayAn array of elements to filter selector : StringThe simple selector to test nonMatches : BooleanIf true, it returns the elements that DON'T match
+the selector instead of the ones that match Returns:
| DomQuery | | is( String/HTMLElement/Array el , String selector )
:
BooleanReturns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child) Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child) | DomQuery | | jsSelect( String selector , [Node/String root ] )
:
- ArraySelects a group of elements. Selects a group of elements. Parameters:Returns:Array An Array of DOM elements which match the selector. If there are
+ Array Selects a group of elements. Selects a group of elements.
| DomQuery | | operators()
:
- voidCollection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
-New operato... Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
+ void Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
+New operator... Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
New operators can be added as long as the match the format c= where c is any character other than space, > <. | DomQuery | | selectNode( String selector , [Node root ] )
:
ElementSelects a single element. Selects a single element. | DomQuery | | selectNumber( String selector , [Node root ], Number defaultValue )
|
|