Skip to content

Commit b0e1e83

Browse files
committed
Ensure that unquoted attribute selectors are quoted (allowing them to go into qSA/matchesSelector properly). Fixes #7216.
1 parent 983548f commit b0e1e83

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/unit/selector.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ test("child and adjacent", function() {
237237
});
238238

239239
test("attributes", function() {
240-
expect(35);
240+
expect(39);
241241
t( "Attribute Exists", "a[title]", ["google"] );
242242
t( "Attribute Exists", "*[title]", ["google"] );
243243
t( "Attribute Exists", "[title]", ["google"] );
@@ -275,8 +275,16 @@ test("attributes", function() {
275275
t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
276276
t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", ["google","groups","anchor1"] );
277277

278-
var opt = document.getElementById("option1a");
279-
ok( (window.Sizzle || window.jQuery.find).matchesSelector( opt, "[id*=option1][type!=checkbox]" ), "Attribute Is Not Equal Matches" );
278+
var opt = document.getElementById("option1a"),
279+
match = (window.Sizzle || window.jQuery.find).matchesSelector;
280+
281+
opt.setAttribute("test", "");
282+
283+
ok( match( opt, "[id*=option1][type!=checkbox]" ), "Attribute Is Not Equal Matches" );
284+
ok( match( opt, "[id*=option1]" ), "Attribute With No Quotes Contains Matches" );
285+
ok( match( opt, "[test=]" ), "Attribute With No Quotes No Content Matches" );
286+
ok( match( opt, "[id=option1a]" ), "Attribute With No Quotes Equals Matches" );
287+
ok( match( document.getElementById("simon1"), "a[href*=#]" ), "Attribute With No Quotes Href Contains Matches" );
280288

281289
t("Empty values", "#select1 option[value='']", ["option1a"]);
282290
t("Empty values", "#select1 option[value!='']", ["option1b","option1c","option1d"]);

0 commit comments

Comments
 (0)