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.
This commit is contained in:
parent
37ee2df8a8
commit
c20924818c
2
src/jquery/coreTest.js
vendored
2
src/jquery/coreTest.js
vendored
|
@ -396,7 +396,7 @@ test("expressions - attributes", function() {
|
||||||
t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
|
t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
|
||||||
t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
|
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]", "#select2 option[@selected]", ["option2d"] );
|
||||||
t("Select options via [@selected]", "#select3 option[@selected]", ["option3b", "option3c"] );
|
t("Select options via [@selected]", "#select3 option[@selected]", ["option3b", "option3c"] );
|
||||||
|
|
||||||
|
|
12
src/jquery/jquery.js
vendored
12
src/jquery/jquery.js
vendored
|
@ -1473,7 +1473,11 @@ jQuery.extend({
|
||||||
"^=": "z && !z.indexOf(m[4])",
|
"^=": "z && !z.indexOf(m[4])",
|
||||||
"$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
|
"$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
|
||||||
"*=": "z && z.indexOf(m[4])>=0",
|
"*=": "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"
|
"[": "jQuery.find(m[2],a).length"
|
||||||
},
|
},
|
||||||
|
@ -1806,8 +1810,8 @@ jQuery.extend({
|
||||||
|
|
||||||
if ( m ) {
|
if ( m ) {
|
||||||
// Re-organize the first match
|
// Re-organize the first match
|
||||||
if ( !i )
|
if ( jQuery.expr[ m[1] ]._resort )
|
||||||
m = ["",m[1], m[3], m[2], m[5]];
|
m = jQuery.expr[ m[1] ]._resort( m );
|
||||||
|
|
||||||
// Remove what we just matched
|
// Remove what we just matched
|
||||||
t = t.replace( re, "" );
|
t = t.replace( re, "" );
|
||||||
|
@ -1838,7 +1842,7 @@ jQuery.extend({
|
||||||
|
|
||||||
// Build a custom macro to enclose it
|
// Build a custom macro to enclose it
|
||||||
eval("f = function(a,i){" +
|
eval("f = function(a,i){" +
|
||||||
( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
|
( jQuery.expr[ m[1] ]._prefix || "" ) +
|
||||||
"return " + f + "}");
|
"return " + f + "}");
|
||||||
|
|
||||||
// Execute it against the current filter
|
// Execute it against the current filter
|
||||||
|
|
Loading…
Reference in a new issue