Skip to content

Commit 7bdb3de

Browse files
authored
Attributes: Fix compatibility with jQuery 4.x
In jquery/jquery#5384, `jQuery.expr.match.bool` stopped being defined and the regex matching boolean attributes is no longer exposed. Inline it in Migrate to avoid it crashing on jQuery 4.x. Fixes gh-495 Closes gh-496
1 parent 5136833 commit 7bdb3de

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/jquery/attributes.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { migratePatchFunc, migrateWarn } from "../main.js";
22

33
var oldRemoveAttr = jQuery.fn.removeAttr,
44
oldToggleClass = jQuery.fn.toggleClass,
5+
rbooleans = /^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i,
56
rmatchNonSpace = /\S+/g;
67

78
migratePatchFunc( jQuery.fn, "removeAttr", function( name ) {
89
var self = this,
910
patchNeeded = false;
1011

1112
jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) {
12-
if ( jQuery.expr.match.bool.test( attr ) ) {
13+
if ( rbooleans.test( attr ) ) {
1314

1415
// Only warn if at least a single node had the property set to
1516
// something else than `false`. Otherwise, this Migrate patch

0 commit comments

Comments
 (0)