Skip to content

Commit

Permalink
Attributes: Fix compatibility with jQuery 4.x
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mgol committed Feb 3, 2024
1 parent 5136833 commit 7bdb3de
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/jquery/attributes.js
Expand Up @@ -2,14 +2,15 @@ import { migratePatchFunc, migrateWarn } from "../main.js";

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

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

jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) {
if ( jQuery.expr.match.bool.test( attr ) ) {
if ( rbooleans.test( attr ) ) {

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

0 comments on commit 7bdb3de

Please sign in to comment.