aboutsummaryrefslogtreecommitdiffstats
path: root/build/tasks/build.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2022-11-21 23:23:39 +0100
committerGitHub <noreply@github.com>2022-11-21 23:23:39 +0100
commit4c1171f2ed62584211250df0af8302d34c04621a (patch)
treeba1f6a5a977f32ca3dd67396458ca6bca602fe0e /build/tasks/build.js
parentf62d8e2159baf1eabf3b760b85b2dda56d569a09 (diff)
downloadjquery-4c1171f2ed62584211250df0af8302d34c04621a.tar.gz
jquery-4c1171f2ed62584211250df0af8302d34c04621a.zip
Selector: Re-introduce selector-native.js
Re-introduce the `selector-native` similar to the one on the `3.x-stable` branch. One difference is since the `main` branch inlined Sizzle, some selector utils can be shared between the main `selector` module and `selector-native`. The main `selector` module can be disabled in favor of `selector-native` via: grunt custom:-selector Other changes: * Tests: Fix Safari detection - Chrome Headless has a different user agent than Safari and a browser check in selector tests didn't take that into account. * Tests: Run selector-native tests in `npm test` * Selector: Fix querying on document fragments Ref gh-4395 Closes gh-5085
Diffstat (limited to 'build/tasks/build.js')
-rw-r--r--build/tasks/build.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/build/tasks/build.js b/build/tasks/build.js
index e344f991b..61ec670fb 100644
--- a/build/tasks/build.js
+++ b/build/tasks/build.js
@@ -128,11 +128,11 @@ module.exports = function( grunt ) {
* Adds the specified module to the excluded or included list, depending on the flag
* @param {String} flag A module path relative to
* the src directory starting with + or - to indicate
- * whether it should included or excluded
+ * whether it should be included or excluded
*/
const excluder = flag => {
let additional;
- const m = /^(\+|\-|)([\w\/-]+)$/.exec( flag );
+ const m = /^(\+|-|)([\w\/-]+)$/.exec( flag );
const exclude = m[ 1 ] === "-";
const module = m[ 2 ];
@@ -150,10 +150,16 @@ module.exports = function( grunt ) {
// These are the removable dependencies
// It's fine if the directory is not there
try {
- excludeList(
- fs.readdirSync( `${ srcFolder }/${ module }` ),
- module
- );
+
+ // `selector` is a special case as we don't just remove
+ // the module, but we replace it with `selector-native`
+ // which re-uses parts of the `src/selector` folder.
+ if ( module !== "selector" ) {
+ excludeList(
+ fs.readdirSync( `${ srcFolder }/${ module }` ),
+ module
+ );
+ }
} catch ( e ) {
grunt.verbose.writeln( e );
}
@@ -232,14 +238,14 @@ module.exports = function( grunt ) {
// Remove the comma for anonymous defines
setOverride( `${ srcFolder }/exports/amd.js`,
read( "exports/amd.js" )
- .replace( /(\s*)"jquery"(\,\s*)/,
+ .replace( /(\s*)"jquery"(,\s*)/,
amdName ? "$1\"" + amdName + "\"$2" : "" ) );
}
grunt.verbose.writeflags( excluded, "Excluded" );
grunt.verbose.writeflags( included, "Included" );
- // Indicate a Slim build without listing all of the exclusions
+ // Indicate a Slim build without listing all the exclusions
// to save space.
if ( isPureSlim ) {
version += " slim";
@@ -260,7 +266,13 @@ module.exports = function( grunt ) {
// Replace excluded modules with empty sources.
for ( const module of excluded ) {
- setOverride( `${ srcFolder }/${ module }.js`, "" );
+ setOverride(
+ `${ srcFolder }/${ module }.js`,
+
+ // The `selector` module is not removed, but replaced
+ // with `selector-native`.
+ module === "selector" ? read( "selector-native.js" ) : ""
+ );
}
}