aboutsummaryrefslogtreecommitdiffstats
path: root/src/var
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2019-11-18 21:15:03 +0100
committerGitHub <noreply@github.com>2019-11-18 21:15:03 +0100
commitd0ce00cdfa680f1f0c38460bc51ea14079ae8b07 (patch)
tree8625b82760f0722443f3901f78d94025d7645463 /src/var
parenta612733be0c68d337647a6fcc8f8e0cabc1fc36b (diff)
downloadjquery-d0ce00cdfa680f1f0c38460bc51ea14079ae8b07.tar.gz
jquery-d0ce00cdfa680f1f0c38460bc51ea14079ae8b07.zip
Core: Migrate from AMD to ES modules 🎉
Migrate all source AMD modules to ECMAScript modules. The final bundle is compiled by a custom build process that uses Rollup under the hood. Test files themselves are still loaded via RequireJS as that has to work in IE 11. Tests can now be run in "Load as modules" mode which replaces the previous "Load with AMD" option. That option of running tests doesn't work in IE and Edge as it requires support for dynamic imports. Some of the changes required by the migration: * check `typeof` of `noGlobal` instead of using the variable directly as it's not available when modules are used * change the nonce module to be an object as ECMASscript module exports are immutable * remove some unused exports * import `./core/parseHTML.js` directly in `jquery.js` so that it's not being cut out when the `ajax` module is excluded in a custom compilation Closes gh-4541
Diffstat (limited to 'src/var')
-rw-r--r--src/var/ObjectFunctionString.js8
-rw-r--r--src/var/arr.js6
-rw-r--r--src/var/class2type.js8
-rw-r--r--src/var/document.js6
-rw-r--r--src/var/documentElement.js8
-rw-r--r--src/var/flat.js10
-rw-r--r--src/var/fnToString.js8
-rw-r--r--src/var/getProto.js6
-rw-r--r--src/var/hasOwn.js8
-rw-r--r--src/var/indexOf.js8
-rw-r--r--src/var/isIE.js8
-rw-r--r--src/var/isWindow.js11
-rw-r--r--src/var/pnum.js6
-rw-r--r--src/var/pop.js8
-rw-r--r--src/var/push.js8
-rw-r--r--src/var/rcheckableType.js6
-rw-r--r--src/var/rcssNum.js10
-rw-r--r--src/var/rnothtmlwhite.js12
-rw-r--r--src/var/slice.js8
-rw-r--r--src/var/sort.js8
-rw-r--r--src/var/support.js8
-rw-r--r--src/var/toString.js8
-rw-r--r--src/var/trim.js6
23 files changed, 43 insertions, 140 deletions
diff --git a/src/var/ObjectFunctionString.js b/src/var/ObjectFunctionString.js
index f9e850fd8..c8fdcd989 100644
--- a/src/var/ObjectFunctionString.js
+++ b/src/var/ObjectFunctionString.js
@@ -1,7 +1,3 @@
-define( [
- "./fnToString"
-], function( fnToString ) {
- "use strict";
+import fnToString from "./fnToString.js";
- return fnToString.call( Object );
-} );
+export default fnToString.call( Object );
diff --git a/src/var/arr.js b/src/var/arr.js
index 84713d838..d6d1738de 100644
--- a/src/var/arr.js
+++ b/src/var/arr.js
@@ -1,5 +1 @@
-define( function() {
- "use strict";
-
- return [];
-} );
+export default [];
diff --git a/src/var/class2type.js b/src/var/class2type.js
index 4365d46a2..758dff6de 100644
--- a/src/var/class2type.js
+++ b/src/var/class2type.js
@@ -1,6 +1,2 @@
-define( function() {
- "use strict";
-
- // [[Class]] -> type pairs
- return {};
-} );
+// [[Class]] -> type pairs
+export default {};
diff --git a/src/var/document.js b/src/var/document.js
index dd3939df4..db89b6875 100644
--- a/src/var/document.js
+++ b/src/var/document.js
@@ -1,5 +1 @@
-define( function() {
- "use strict";
-
- return window.document;
-} );
+export default window.document;
diff --git a/src/var/documentElement.js b/src/var/documentElement.js
index 0e3f8b48c..4bad20e54 100644
--- a/src/var/documentElement.js
+++ b/src/var/documentElement.js
@@ -1,7 +1,3 @@
-define( [
- "./document"
-], function( document ) {
- "use strict";
+import document from "./document.js";
- return document.documentElement;
-} );
+export default document.documentElement;
diff --git a/src/var/flat.js b/src/var/flat.js
index 6c7a27169..172420552 100644
--- a/src/var/flat.js
+++ b/src/var/flat.js
@@ -1,15 +1,9 @@
-define( [
- "./arr"
-], function( arr ) {
-
-"use strict";
+import arr from "./arr.js";
// Support: IE 11+, Edge 18+
// Provide fallback for browsers without Array#flat.
-return arr.flat ? function( array ) {
+export default arr.flat ? function( array ) {
return arr.flat.call( array );
} : function( array ) {
return arr.concat.apply( [], array );
};
-
-} );
diff --git a/src/var/fnToString.js b/src/var/fnToString.js
index 18c43ff30..10042138e 100644
--- a/src/var/fnToString.js
+++ b/src/var/fnToString.js
@@ -1,7 +1,3 @@
-define( [
- "./hasOwn"
-], function( hasOwn ) {
- "use strict";
+import hasOwn from "./hasOwn.js";
- return hasOwn.toString;
-} );
+export default hasOwn.toString;
diff --git a/src/var/getProto.js b/src/var/getProto.js
index 965fab8fb..392cd3973 100644
--- a/src/var/getProto.js
+++ b/src/var/getProto.js
@@ -1,5 +1 @@
-define( function() {
- "use strict";
-
- return Object.getPrototypeOf;
-} );
+export default Object.getPrototypeOf;
diff --git a/src/var/hasOwn.js b/src/var/hasOwn.js
index 44ab6807d..62f2c1852 100644
--- a/src/var/hasOwn.js
+++ b/src/var/hasOwn.js
@@ -1,7 +1,3 @@
-define( [
- "./class2type"
-], function( class2type ) {
- "use strict";
+import class2type from "./class2type.js";
- return class2type.hasOwnProperty;
-} );
+export default class2type.hasOwnProperty;
diff --git a/src/var/indexOf.js b/src/var/indexOf.js
index 8320b98e5..f1342c8f7 100644
--- a/src/var/indexOf.js
+++ b/src/var/indexOf.js
@@ -1,7 +1,3 @@
-define( [
- "./arr"
-], function( arr ) {
- "use strict";
+import arr from "./arr.js";
- return arr.indexOf;
-} );
+export default arr.indexOf;
diff --git a/src/var/isIE.js b/src/var/isIE.js
index e6a37cb5a..a239745ea 100644
--- a/src/var/isIE.js
+++ b/src/var/isIE.js
@@ -1,7 +1,3 @@
-define( [
- "./document"
-], function( document ) {
- "use strict";
+import document from "./document.js";
- return document.documentMode;
-} );
+export default document.documentMode;
diff --git a/src/var/isWindow.js b/src/var/isWindow.js
index 2ba1168dd..fa64581ee 100644
--- a/src/var/isWindow.js
+++ b/src/var/isWindow.js
@@ -1,8 +1,3 @@
-define( function() {
- "use strict";
-
- return function isWindow( obj ) {
- return obj != null && obj === obj.window;
- };
-
-} );
+export default function isWindow( obj ) {
+ return obj != null && obj === obj.window;
+};
diff --git a/src/var/pnum.js b/src/var/pnum.js
index 6f06d73b1..5f6bca473 100644
--- a/src/var/pnum.js
+++ b/src/var/pnum.js
@@ -1,5 +1 @@
-define( function() {
- "use strict";
-
- return ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
-} );
+export default ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
diff --git a/src/var/pop.js b/src/var/pop.js
index 6f1eb903c..b1c9131c5 100644
--- a/src/var/pop.js
+++ b/src/var/pop.js
@@ -1,7 +1,3 @@
-define( [
- "./arr"
-], function( arr ) {
- "use strict";
+import arr from "./arr.js";
- return arr.pop;
-} );
+export default arr.pop;
diff --git a/src/var/push.js b/src/var/push.js
index 94656209a..2758aa587 100644
--- a/src/var/push.js
+++ b/src/var/push.js
@@ -1,7 +1,3 @@
-define( [
- "./arr"
-], function( arr ) {
- "use strict";
+import arr from "./arr.js";
- return arr.push;
-} );
+export default arr.push;
diff --git a/src/var/rcheckableType.js b/src/var/rcheckableType.js
index 25bbcb418..9fc4b55dc 100644
--- a/src/var/rcheckableType.js
+++ b/src/var/rcheckableType.js
@@ -1,5 +1 @@
-define( function() {
- "use strict";
-
- return ( /^(?:checkbox|radio)$/i );
-} );
+export default ( /^(?:checkbox|radio)$/i );
diff --git a/src/var/rcssNum.js b/src/var/rcssNum.js
index 4214b14aa..c96eb65ca 100644
--- a/src/var/rcssNum.js
+++ b/src/var/rcssNum.js
@@ -1,9 +1,3 @@
-define( [
- "../var/pnum"
-], function( pnum ) {
+import pnum from "../var/pnum.js";
-"use strict";
-
-return new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
-
-} );
+export default new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
diff --git a/src/var/rnothtmlwhite.js b/src/var/rnothtmlwhite.js
index 29eebf287..db2a9e360 100644
--- a/src/var/rnothtmlwhite.js
+++ b/src/var/rnothtmlwhite.js
@@ -1,8 +1,4 @@
-define( function() {
- "use strict";
-
- // Only count HTML whitespace
- // Other whitespace should count in values
- // https://infra.spec.whatwg.org/#ascii-whitespace
- return ( /[^\x20\t\r\n\f]+/g );
-} );
+// Only count HTML whitespace
+// Other whitespace should count in values
+// https://infra.spec.whatwg.org/#ascii-whitespace
+export default ( /[^\x20\t\r\n\f]+/g );
diff --git a/src/var/slice.js b/src/var/slice.js
index 915f837be..4d767ac98 100644
--- a/src/var/slice.js
+++ b/src/var/slice.js
@@ -1,7 +1,3 @@
-define( [
- "./arr"
-], function( arr ) {
- "use strict";
+import arr from "./arr.js";
- return arr.slice;
-} );
+export default arr.slice;
diff --git a/src/var/sort.js b/src/var/sort.js
index a943fa77c..031be7706 100644
--- a/src/var/sort.js
+++ b/src/var/sort.js
@@ -1,7 +1,3 @@
-define( [
- "./arr"
-], function( arr ) {
- "use strict";
+import arr from "./arr.js";
- return arr.sort;
-} );
+export default arr.sort;
diff --git a/src/var/support.js b/src/var/support.js
index 094d0aece..cc0a15d15 100644
--- a/src/var/support.js
+++ b/src/var/support.js
@@ -1,6 +1,2 @@
-define( function() {
- "use strict";
-
- // All support tests are defined in their respective modules.
- return {};
-} );
+// All support tests are defined in their respective modules.
+export default {};
diff --git a/src/var/toString.js b/src/var/toString.js
index ff4ecdc72..01682d601 100644
--- a/src/var/toString.js
+++ b/src/var/toString.js
@@ -1,7 +1,3 @@
-define( [
- "./class2type"
-], function( class2type ) {
- "use strict";
+import class2type from "./class2type.js";
- return class2type.toString;
-} );
+export default class2type.toString;
diff --git a/src/var/trim.js b/src/var/trim.js
index a5e75af36..77d925fb0 100644
--- a/src/var/trim.js
+++ b/src/var/trim.js
@@ -1,5 +1 @@
-define( function() {
- "use strict";
-
- return "".trim;
-} );
+export default "".trim;