]> source.dussan.org Git - jquery.git/commitdiff
Selector: Make `selector.js` module depend on `attributes/attr.js`
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Fri, 12 Jan 2024 00:18:03 +0000 (01:18 +0100)
committerGitHub <noreply@github.com>
Fri, 12 Jan 2024 00:18:03 +0000 (01:18 +0100)
This fixes custom builds using the `--include` switch that don't include
the `attributes` module.

Fixes gh-5379
Closes gh-5384

Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
src/attributes/attr.js
src/selector-native.js
src/selector.js
src/selector/var/booleans.js [deleted file]

index ddddcada6af1de02d42a1587f7b397b91cbd9bfe..5a911c7d0cd998edddbec9052691e977f39c9435 100644 (file)
@@ -97,7 +97,15 @@ if ( isIE ) {
        };
 }
 
-jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
+// HTML boolean attributes have special behavior:
+// we consider the lowercase name to be the only valid value, so
+// getting (if the attribute is present) normalizes to that, as does
+// setting to any non-`false` value (and setting to `false` removes the attribute).
+// See https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
+jQuery.each( (
+       "checked selected async autofocus autoplay controls defer disabled " +
+       "hidden ismap loop multiple open readonly required scoped"
+).split( " " ), function( _i, name ) {
        jQuery.attrHooks[ name ] = {
                get: function( elem ) {
                        var ret,
index afb60f2270a1e5c4627fb51e86d2696863739105..b245e33506e7e025e0d11e73303adae669a605d6 100644 (file)
@@ -25,7 +25,6 @@ import { jQuery } from "./core.js";
 import { document } from "./var/document.js";
 import { whitespace } from "./var/whitespace.js";
 import { isIE } from "./var/isIE.js";
-import { booleans } from "./selector/var/booleans.js";
 import { rleadingCombinator } from "./selector/var/rleadingCombinator.js";
 import { rdescend } from "./selector/var/rdescend.js";
 import { rsibling } from "./selector/var/rsibling.js";
@@ -41,7 +40,6 @@ import "./selector/escapeSelector.js";
 import "./selector/uniqueSort.js";
 
 var matchExpr = jQuery.extend( {
-       bool: new RegExp( "^(?:" + booleans + ")$", "i" ),
        needsContext: new RegExp( "^" + whitespace + "*[>+~]" )
 }, filterMatchExpr );
 
index d71e65ad4a99b4c02dec65dcde5559ead8553b49..da535718ed9372480405428d13a249a220d82c2d 100644 (file)
@@ -9,7 +9,6 @@ import { rbuggyQSA } from "./selector/rbuggyQSA.js";
 import { rtrimCSS } from "./var/rtrimCSS.js";
 import { isIE } from "./var/isIE.js";
 import { identifier } from "./selector/var/identifier.js";
-import { booleans } from "./selector/var/booleans.js";
 import { rleadingCombinator } from "./selector/var/rleadingCombinator.js";
 import { rdescend } from "./selector/var/rdescend.js";
 import { rsibling } from "./selector/var/rsibling.js";
@@ -24,6 +23,7 @@ import { tokenize } from "./selector/tokenize.js";
 import { toSelector } from "./selector/toSelector.js";
 
 // The following utils are attached directly to the jQuery object.
+import "./attributes/attr.js"; // jQuery.attr
 import "./selector/escapeSelector.js";
 import "./selector/uniqueSort.js";
 
@@ -50,7 +50,6 @@ var i,
        ridentifier = new RegExp( "^" + identifier + "$" ),
 
        matchExpr = jQuery.extend( {
-               bool: new RegExp( "^(?:" + booleans + ")$", "i" ),
 
                // For use in libraries implementing .is()
                // We use this for POS matching in `select`
diff --git a/src/selector/var/booleans.js b/src/selector/var/booleans.js
deleted file mode 100644 (file)
index bbdc4fd..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-export var booleans = "checked|selected|async|autofocus|autoplay|controls|" +
-       "defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped";