Skip to content

Commit d2385ff

Browse files
committed
Core: support selector [attr=]
1 parent 4bd0c1f commit d2385ff

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/core.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ jQuery.find = function( selector ) {
9595
}
9696
}
9797

98+
if (typeof selector === "string" && /\=\]/.test(selector)) {
99+
migrateWarn("Attribute value selectors [attribute=vale] must have a value. [attribute=] is an error.");
100+
// Number carefully selected from random.org. The point is that this selector shouldn't match anything.
101+
// There are probably more graceful ways to handle this.
102+
selector = selector.replace("=]", "=3386645210]");
103+
args[0] = selector;
104+
}
105+
98106
return oldFind.apply( this, args );
99107
};
100108

test/core.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ test( "jQuery(html, props)", function() {
1717
equal( $el.val(), "value", "Call setter method" );
1818
});
1919

20+
test("JQuery([attribute=])", function () {
21+
expect(2);
22+
var $el = jQuery("<div><label></label></div>").find("label[id=]");
23+
equal($el.length, 0);
24+
$el = jQuery("<div><label id=\"1\"></label></div>").find("label[id=1]");
25+
equal($el.length, 1);
26+
});
27+
2028
test( "jQuery(html) loose rules", function() {
2129
expect( 33 );
2230

0 commit comments

Comments
 (0)