From 1a55028f6146a24e9608c454900fa902696a3b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Sat, 3 Feb 2024 02:04:00 +0100 Subject: [PATCH] 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 --- src/jquery/attributes.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jquery/attributes.js b/src/jquery/attributes.js index 7da32b85..c87d7ef5 100644 --- a/src/jquery/attributes.js +++ b/src/jquery/attributes.js @@ -2,6 +2,7 @@ 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 ) { @@ -9,7 +10,7 @@ migratePatchFunc( jQuery.fn, "removeAttr", function( name ) { 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