]> source.dussan.org Git - jquery.git/commitdiff
Fixes #14450. Remove CommonJS+AMD syntax.
authorTimmy Willison <timmywillisn@gmail.com>
Tue, 15 Oct 2013 14:40:48 +0000 (10:40 -0400)
committerTimmy Willison <timmywillisn@gmail.com>
Tue, 15 Oct 2013 15:59:16 +0000 (11:59 -0400)
- To keep file size unaffected, an extra pragma was added to build.js to remove certain lines when building with special comments.

Conflicts:
src/core.js
src/css.js
src/effects.js
src/event.js
src/manipulation.js
src/offset.js

build/tasks/build.js
src/core.js
src/css.js
src/effects.js
src/event.js
src/manipulation.js
src/offset.js

index 8fde24be9b116b2bc774a03599cfc699a4606150..e329e45e8450b377b14b7ec9c5abd04e94a18019 100644 (file)
@@ -69,13 +69,12 @@ module.exports = function( grunt ) {
                                .replace( /define\([^{]*?{/, "" )
                                .replace( rdefineEnd, "" );
 
-                       // Remove CommonJS-style require calls
-                       // Keep an ending semicolon
+                       // Remove anything wrapped with
+                       // /* ExcludeStart */ /* ExcludeEnd */
+                       // or a single line directly after a // BuildExclude comment
                        contents = contents
-                               .replace( /(\s+\w+ = )?\s*require\(\s*(")[\w\.\/]+\2\s*\)[\.\w]*([,;])/g,
-                                       function( all, isVar, quote, commaSemicolon ) {
-                                               return isVar && commaSemicolon === ";" ? ";" : "";
-                                       });
+                               .replace( /\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig, "" )
+                               .replace( /\/\/\s*BuildExclude\n\r?[\w\W]*?\n\r?/ig, "" );
 
                        // Remove empty definitions
                        contents = contents
index 670d5caddb4848a572b2027dae7546860cdb6824..11ab78b186ccfc97af744a5bd56a574abc8364a4 100644 (file)
@@ -1,17 +1,17 @@
-define(function( require ) {
+define([
+       "./var/deletedIds",
+       "./var/slice",
+       "./var/concat",
+       "./var/push",
+       "./var/indexOf",
+       "./var/class2type",
+       "./var/toString",
+       "./var/hasOwn",
+       "./var/trim",
+       "./var/support"
+], function( deletedIds, slice, concat, push, indexOf, class2type, toString, hasOwn, trim, support ) {
 
 var
-       deletedIds = require( "./var/deletedIds" ),
-       slice = require( "./var/slice" ),
-       concat = require( "./var/concat" ),
-       push = require( "./var/push" ),
-       indexOf = require( "./var/indexOf" ),
-       class2type = require( "./var/class2type" ),
-       toString = require( "./var/toString" ),
-       hasOwn = require( "./var/hasOwn" ),
-       trim = require( "./var/trim" ),
-       support = require( "./var/support" ),
-
        // Map over jQuery in case of overwrite
        _jQuery = window.jQuery,
 
index a4d0b55dfe036ebe915e053948bc13ec6b53c167..09d7891684b53e21d1be27907f54f5ea6d8b8ce0 100644 (file)
@@ -1,22 +1,26 @@
-// Require more than a few needed variables
-// Keep in mind that a dependency array cannot be used with CommonJS+AMD syntax
-define(function( require ) {
+define([
+       "./core",
+       "./var/pnum",
+       "./core/access",
+       "./css/var/rmargin",
+       "./css/var/rnumnonpx",
+       "./css/var/cssExpand",
+       "./css/var/isHidden",
+       "./css/curCSS",
+       "./css/defaultDisplay",
+       "./css/addGetHookIf",
+       "./css/support",
+
+       "./core/init",
+       "./css/swap",
+       "./core/ready",
+       "./selector" // contains
+], function( jQuery, pnum, access, rmargin, rnumnonpx, cssExpand, isHidden,
+       curCSS, defaultDisplay, addGetHookIf, support ) {
 
 var
-       jQuery = require( "./core" ),
-       pnum = require( "./var/pnum" ),
-       access = require( "./core/access" ),
-       rmargin = require( "./css/var/rmargin" ),
-       rnumnonpx = require( "./css/var/rnumnonpx" ),
-       cssExpand = require( "./css/var/cssExpand" ),
-       isHidden = require( "./css/var/isHidden" ),
-       // This format is here to facilitate easy removal when building
-       getStyles = require( "./css/curCSS" ).getStyles,
-       curCSS = require( "./css/curCSS" ).curCSS,
-       support = require( "./css/support" ),
-       defaultDisplay = require( "./css/defaultDisplay" ),
-       addGetHookIf = require( "./css/addGetHookIf" ),
-
+       // BuildExclude
+       getStyles = curCSS.getStyles,
        ralpha = /alpha\([^)]*\)/i,
        ropacity = /opacity\s*=\s*([^)]*)/,
 
@@ -34,11 +38,8 @@ var
 
        cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
 
-// Dependencies not needed as vars
-require( "./core/init" );
-require( "./css/swap" );
-require( "./core/ready" );
-require( "./selector" ); // contains
+// BuildExclude
+curCSS = curCSS.curCSS;
 
 // return a css property mapped to a potentially vendor prefixed property
 function vendorPropName( style, name ) {
index 292f31af656aef650f7563cb36f2f49c5930bbe9..582870fe93543b80bd3379eecfc195e1a8078001 100644 (file)
@@ -1,13 +1,20 @@
-define(function( require ) {
+define([
+       "./core",
+       "./var/pnum",
+       "./css/var/cssExpand",
+       "./css/var/isHidden",
+       "./css/defaultDisplay",
+       "./effects/support",
+
+       "./core/init",
+       "./effects/Tween",
+       "./queue",
+       "./css",
+       "./deferred",
+       "./traversing"
+], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, support ) {
 
 var
-       jQuery = require( "./core" ),
-       pnum = require( "./var/pnum" ),
-       cssExpand = require( "./css/var/cssExpand" ),
-       isHidden = require( "./css/var/isHidden" ),
-       defaultDisplay = require( "./css/defaultDisplay" ),
-       support = require( "./effects/support" ),
-
        fxNow, timerId,
        rfxtypes = /^(?:toggle|show|hide)$/,
        rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
@@ -64,14 +71,6 @@ var
                }]
        };
 
-// Dependencies not needed as vars
-require( "./core/init" );
-require( "./effects/Tween" );
-require( "./queue" );
-require( "./css" );
-require( "./deferred" );
-require( "./traversing" );
-
 // Animations created synchronously will run synchronously
 function createFxNow() {
        setTimeout(function() {
index 3f900e2b434f5fa7628ef740e6d6d642ff1e360e..a6f69f49ff505972c8963941be692302230a7771 100644 (file)
@@ -1,23 +1,22 @@
-define(function( require ) {
-
-var
-       jQuery = require( "./core" ),
-       strundefined = require( "./var/strundefined" ),
-       rnotwhite = require( "./var/rnotwhite" ),
-       hasOwn = require( "./var/hasOwn" ),
-       slice = require( "./var/slice" ),
-       support = require( "./event/support" ),
-       rformElems = /^(?:input|select|textarea)$/i,
+define([
+       "./core",
+       "./var/strundefined",
+       "./var/rnotwhite",
+       "./var/hasOwn",
+       "./var/slice",
+       "./event/support",
+
+       "./core/init",
+       "./data/accepts",
+       "./selector"
+], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support ) {
+
+var rformElems = /^(?:input|select|textarea)$/i,
        rkeyEvent = /^key/,
        rmouseEvent = /^(?:mouse|contextmenu)|click/,
        rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
        rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
 
-// Dependencies not needed as vars
-require( "./core/init" );
-require( "./data/accepts" );
-require( "./selector" );
-
 function returnTrue() {
        return true;
 }
index 30ba484306c0c2359a43acb3f20752bdf6d4f0cc..08a9b7c04c446c16c63fb500db66c1d8027792c3 100644 (file)
@@ -1,6 +1,19 @@
-// Require more than a few needed variables
-// Keep in mind that a dependency array cannot be used with CommonJS+AMD syntax
-define(function( require ){
+define([
+       "./core",
+       "./var/strundefined",
+       "./var/concat",
+       "./var/push",
+       "./var/deletedIds",
+       "./core/access",
+       "./manipulation/var/rcheckableType",
+       "./manipulation/support",
+
+       "./core/init",
+       "./data/accepts",
+       "./traversing",
+       "./selector",
+       "./event"
+], function( jQuery, strundefined, concat, push, deletedIds, access, rcheckableType, support ) {
 
 function createSafeFragment( document ) {
        var list = nodeNames.split( "|" ),
@@ -16,22 +29,11 @@ function createSafeFragment( document ) {
        return safeFrag;
 }
 
-var
-       jQuery = require( "./core" ),
-       strundefined = require( "./var/strundefined" ),
-       concat = require( "./var/concat" ),
-       push = require( "./var/push" ),
-       deletedIds = require( "./var/deletedIds" ),
-       access = require( "./core/access" ),
-       rcheckableType = require( "./manipulation/var/rcheckableType" ),
-       support = require( "./manipulation/support" ),
-
-       nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
+var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
                "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
        rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
        rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
        rleadingWhitespace = /^\s+/,
-
        rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
        rtagName = /<([\w:]+)/,
        rtbody = /<tbody/i,
@@ -65,13 +67,6 @@ wrapMap.optgroup = wrapMap.option;
 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
 wrapMap.th = wrapMap.td;
 
-// Dependencies not needed as variables
-require( "./core/init" );
-require( "./data/accepts" );
-require( "./traversing" );
-require( "./selector" );
-require( "./event" );
-
 function getAll( context, tag ) {
        var elems, elem,
                i = 0,
index 751cbf72a8c100b51c60bc658bf26830072da2eb..8b6bacd3fe27cf2e78bfbfa473cd31bbe0f0d67a 100644 (file)
@@ -1,18 +1,21 @@
-define(function( require ) {
-
-var
-       jQuery = require( "./core" ),
-       strundefined = require( "./var/strundefined" ),
-       access = require( "./core/access" ),
-       rnumnonpx = require( "./css/var/rnumnonpx" ),
-       curCSS = require( "./css/curCSS" ).curCSS,
-       addGetHookIf = require( "./css/addGetHookIf" ),
-       support = require( "./css/support" ),
-       docElem = window.document.documentElement;
-
-require( "./core/init" );
-require( "./css" );
-require( "./selector" ); // contains
+define([
+       "./core",
+       "./var/strundefined",
+       "./core/access",
+       "./css/var/rnumnonpx",
+       "./css/curCSS",
+       "./css/addGetHookIf",
+       "./css/support",
+
+       "./core/init",
+       "./css",
+       "./selector" // contains
+], function( jQuery, strundefined, access, rnumnonpx, curCSS, addGetHookIf, support ) {
+
+// BuildExclude
+curCSS = curCSS.curCSS;
+
+var docElem = window.document.documentElement;
 
 /**
  * Gets a window from an element