Skip to content

Commit f38648c

Browse files
committed
Added a fix for empty attribute selection values. Fixes jQuery bug jquery#3990.
1 parent 31597b7 commit f38648c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/selector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
(function(){
88

9-
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]+['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g,
9+
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g,
1010
done = 0,
1111
toString = Object.prototype.toString;
1212

test/unit/selector.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ test("child and adjacent", function() {
215215
});
216216

217217
test("attributes", function() {
218-
expect(35);
218+
expect(37);
219219
t( "Attribute Exists", "a[title]", ["google"] );
220220
t( "Attribute Exists", "*[title]", ["google"] );
221221
t( "Attribute Exists", "[title]", ["google"] );
@@ -252,6 +252,9 @@ test("attributes", function() {
252252
t( "Attribute Ends With", "a[href $= 'org/']", ["mark"] );
253253
t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
254254
t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", ["google","groups","anchor1"] );
255+
256+
t("Empty values", "#select1 option[value='']", ["option1a"]);
257+
t("Empty values", "#select1 option[value!='']", ["option1b","option1c","option1d"]);
255258

256259
t("Select options via :selected", "#select1 option:selected", ["option1a"] );
257260
t("Select options via :selected", "#select2 option:selected", ["option2d"] );

0 commit comments

Comments
 (0)