aboutsummaryrefslogtreecommitdiffstats
path: root/src/selector
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/selector
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/selector')
-rw-r--r--src/selector/contains.js8
-rw-r--r--src/selector/escapeSelector.js8
-rw-r--r--src/selector/rbuggyQSA.js12
-rw-r--r--src/selector/support.js12
-rw-r--r--src/selector/uniqueSort.js12
5 files changed, 11 insertions, 41 deletions
diff --git a/src/selector/contains.js b/src/selector/contains.js
index 0d6273c28..a62b97ab5 100644
--- a/src/selector/contains.js
+++ b/src/selector/contains.js
@@ -1,8 +1,4 @@
-define( [
- "../core"
-], function( jQuery ) {
-
-"use strict";
+import jQuery from "../core.js";
// Note: an element does not contain itself
jQuery.contains = function( a, b ) {
@@ -18,5 +14,3 @@ jQuery.contains = function( a, b ) {
a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
) );
};
-
-} );
diff --git a/src/selector/escapeSelector.js b/src/selector/escapeSelector.js
index 1d89c2f00..bc61355fa 100644
--- a/src/selector/escapeSelector.js
+++ b/src/selector/escapeSelector.js
@@ -1,8 +1,4 @@
-define( [
- "../core"
-], function( jQuery ) {
-
-"use strict";
+import jQuery from "../core.js";
// CSS string/identifier serialization
// https://drafts.csswg.org/cssom/#common-serializing-idioms
@@ -27,5 +23,3 @@ function fcssescape( ch, asCodePoint ) {
jQuery.escapeSelector = function( sel ) {
return ( sel + "" ).replace( rcssescape, fcssescape );
};
-
-} );
diff --git a/src/selector/rbuggyQSA.js b/src/selector/rbuggyQSA.js
index eee151afb..f638fc429 100644
--- a/src/selector/rbuggyQSA.js
+++ b/src/selector/rbuggyQSA.js
@@ -1,9 +1,5 @@
-define( [
- "../var/document",
- "../var/isIE"
-], function( document, isIE ) {
-
-"use strict";
+import document from "../var/document.js";
+import isIE from "../var/isIE.js";
var rbuggyQSA = [],
testEl = document.createElement( "div" );
@@ -25,6 +21,4 @@ if ( isIE ) {
rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
-return rbuggyQSA;
-
-} );
+export default rbuggyQSA;
diff --git a/src/selector/support.js b/src/selector/support.js
index 86cd2d9ae..cc584bf66 100644
--- a/src/selector/support.js
+++ b/src/selector/support.js
@@ -1,9 +1,5 @@
-define( [
- "../var/document",
- "../var/support"
-], function( document, support ) {
-
-"use strict";
+import document from "../var/document.js";
+import support from "../var/support.js";
// Support: IE 9 - 11+, Edge 12 - 18+
// IE/Edge don't support the :scope pseudo-class.
@@ -12,6 +8,4 @@ try {
support.scope = true;
} catch ( e ) {}
-return support;
-
-} );
+export default support;
diff --git a/src/selector/uniqueSort.js b/src/selector/uniqueSort.js
index ec97de849..d0bf69198 100644
--- a/src/selector/uniqueSort.js
+++ b/src/selector/uniqueSort.js
@@ -1,10 +1,6 @@
-define( [
- "../core",
- "../var/document",
- "../var/sort"
-], function( jQuery, document, sort ) {
-
-"use strict";
+import jQuery from "../core.js";
+import document from "../var/document.js";
+import sort from "../var/sort.js";
var hasDuplicate;
@@ -90,5 +86,3 @@ jQuery.uniqueSort = function( results ) {
return results;
};
-
-} );