Fixes #14450. Remove CommonJS+AMD syntax.

- 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
This commit is contained in:
Timmy Willison 2013-10-15 10:40:48 -04:00
parent 03dd51494f
commit 62900a9edb
7 changed files with 101 additions and 105 deletions

View File

@ -69,13 +69,12 @@ module.exports = function( grunt ) {
.replace( /define\([^{]*?{/, "" ) .replace( /define\([^{]*?{/, "" )
.replace( rdefineEnd, "" ); .replace( rdefineEnd, "" );
// Remove CommonJS-style require calls // Remove anything wrapped with
// Keep an ending semicolon // /* ExcludeStart */ /* ExcludeEnd */
// or a single line directly after a // BuildExclude comment
contents = contents contents = contents
.replace( /(\s+\w+ = )?\s*require\(\s*(")[\w\.\/]+\2\s*\)[\.\w]*([,;])/g, .replace( /\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig, "" )
function( all, isVar, quote, commaSemicolon ) { .replace( /\/\/\s*BuildExclude\n\r?[\w\W]*?\n\r?/ig, "" );
return isVar && commaSemicolon === ";" ? ";" : "";
});
// Remove empty definitions // Remove empty definitions
contents = contents contents = contents

View 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 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 // Map over jQuery in case of overwrite
_jQuery = window.jQuery, _jQuery = window.jQuery,

View File

@ -1,22 +1,26 @@
// Require more than a few needed variables define([
// Keep in mind that a dependency array cannot be used with CommonJS+AMD syntax "./core",
define(function( require ) { "./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 var
jQuery = require( "./core" ), // BuildExclude
pnum = require( "./var/pnum" ), getStyles = curCSS.getStyles,
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" ),
ralpha = /alpha\([^)]*\)/i, ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity\s*=\s*([^)]*)/, ropacity = /opacity\s*=\s*([^)]*)/,
@ -34,11 +38,8 @@ var
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
// Dependencies not needed as vars // BuildExclude
require( "./core/init" ); curCSS = curCSS.curCSS;
require( "./css/swap" );
require( "./core/ready" );
require( "./selector" ); // contains
// return a css property mapped to a potentially vendor prefixed property // return a css property mapped to a potentially vendor prefixed property
function vendorPropName( style, name ) { function vendorPropName( style, name ) {

31
src/effects.js vendored
View 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 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, fxNow, timerId,
rfxtypes = /^(?:toggle|show|hide)$/, rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), 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 // Animations created synchronously will run synchronously
function createFxNow() { function createFxNow() {
setTimeout(function() { setTimeout(function() {

View File

@ -1,23 +1,22 @@
define(function( require ) { define([
"./core",
"./var/strundefined",
"./var/rnotwhite",
"./var/hasOwn",
"./var/slice",
"./event/support",
var "./core/init",
jQuery = require( "./core" ), "./data/accepts",
strundefined = require( "./var/strundefined" ), "./selector"
rnotwhite = require( "./var/rnotwhite" ), ], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support ) {
hasOwn = require( "./var/hasOwn" ),
slice = require( "./var/slice" ), var rformElems = /^(?:input|select|textarea)$/i,
support = require( "./event/support" ),
rformElems = /^(?:input|select|textarea)$/i,
rkeyEvent = /^key/, rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/, rmouseEvent = /^(?:mouse|contextmenu)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
// Dependencies not needed as vars
require( "./core/init" );
require( "./data/accepts" );
require( "./selector" );
function returnTrue() { function returnTrue() {
return true; return true;
} }

View File

@ -1,6 +1,19 @@
// Require more than a few needed variables define([
// Keep in mind that a dependency array cannot be used with CommonJS+AMD syntax "./core",
define(function( require ){ "./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 ) { function createSafeFragment( document ) {
var list = nodeNames.split( "|" ), var list = nodeNames.split( "|" ),
@ -16,22 +29,11 @@ function createSafeFragment( document ) {
return safeFrag; return safeFrag;
} }
var var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
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|" +
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
rleadingWhitespace = /^\s+/, rleadingWhitespace = /^\s+/,
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
rtagName = /<([\w:]+)/, rtagName = /<([\w:]+)/,
rtbody = /<tbody/i, rtbody = /<tbody/i,
@ -65,13 +67,6 @@ wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td; 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 ) { function getAll( context, tag ) {
var elems, elem, var elems, elem,
i = 0, i = 0,

View File

@ -1,18 +1,21 @@
define(function( require ) { define([
"./core",
"./var/strundefined",
"./core/access",
"./css/var/rnumnonpx",
"./css/curCSS",
"./css/addGetHookIf",
"./css/support",
var "./core/init",
jQuery = require( "./core" ), "./css",
strundefined = require( "./var/strundefined" ), "./selector" // contains
access = require( "./core/access" ), ], function( jQuery, strundefined, access, rnumnonpx, curCSS, addGetHookIf, support ) {
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" ); // BuildExclude
require( "./css" ); curCSS = curCSS.curCSS;
require( "./selector" ); // contains
var docElem = window.document.documentElement;
/** /**
* Gets a window from an element * Gets a window from an element