aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2006-12-23 16:37:49 +0000
committerJohn Resig <jeresig@gmail.com>2006-12-23 16:37:49 +0000
commitc20924818c560f1afd9c60f188c8bc616583217b (patch)
treec1e3bdd7818f8023d3f880e690b41c6b8794d771 /src
parent37ee2df8a81fa4e9fba49dbc166c4e89820f9152 (diff)
downloadjquery-c20924818c560f1afd9c60f188c8bc616583217b.tar.gz
jquery-c20924818c560f1afd9c60f188c8bc616583217b.zip
Added Yehuda's selector engine improvements (it's now trivial to add in your own parse expressions). Additionally, I fixed a bug in the test suite.
Diffstat (limited to 'src')
-rw-r--r--src/jquery/coreTest.js2
-rw-r--r--src/jquery/jquery.js18
2 files changed, 12 insertions, 8 deletions
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
index 31fe8387b..ada71959e 100644
--- a/src/jquery/coreTest.js
+++ b/src/jquery/coreTest.js
@@ -396,7 +396,7 @@ test("expressions - attributes", function() {
t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
- t("Select options via [@selected]", "#select1 option[@selected]", [] );
+ t("Select options via [@selected]", "#select1 option[@selected]", ["option1a"] );
t("Select options via [@selected]", "#select2 option[@selected]", ["option2d"] );
t("Select options via [@selected]", "#select3 option[@selected]", ["option3b", "option3c"] );
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 3d2bf4886..d22d136f7 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -1473,20 +1473,24 @@ jQuery.extend({
"^=": "z && !z.indexOf(m[4])",
"$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
"*=": "z && z.indexOf(m[4])>=0",
- "": "z"
+ "": "z",
+ _resort: function(m){
+ return ["", m[1], m[3], m[2], m[5]];
+ },
+ _prefix: "z=jQuery.attr(a,m[3]);"
},
"[": "jQuery.find(m[2],a).length"
},
- /**
+ /**
* All elements on a specified axis.
*
* @private
* @name $.sibling
* @type Array
* @param Element elem The element to find all the siblings of (including itself).
- * @cat DOM/Traversing
- */
+ * @cat DOM/Traversing
+ */
sibling: function( n, elem ) {
var r = [];
@@ -1806,8 +1810,8 @@ jQuery.extend({
if ( m ) {
// Re-organize the first match
- if ( !i )
- m = ["",m[1], m[3], m[2], m[5]];
+ if ( jQuery.expr[ m[1] ]._resort )
+ m = jQuery.expr[ m[1] ]._resort( m );
// Remove what we just matched
t = t.replace( re, "" );
@@ -1838,7 +1842,7 @@ jQuery.extend({
// Build a custom macro to enclose it
eval("f = function(a,i){" +
- ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
+ ( jQuery.expr[ m[1] ]._prefix || "" ) +
"return " + f + "}");
// Execute it against the current filter