Skip to content

Commit

Permalink
Interim take on cross-module variables, closes jquerygh-817.
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored and dmethvin committed Jun 16, 2012
1 parent 46d6804 commit a101e81
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 69 deletions.
5 changes: 2 additions & 3 deletions src/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var r20 = /%20/g,
rquery = /\?/,
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
rselectTextarea = /^(?:select|textarea)/i,
rspacesAjax = /\s+/,
rts = /([?&])_=[^&]*/,
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,

Expand Down Expand Up @@ -72,7 +71,7 @@ function addToPrefiltersOrTransports( structure ) {
}

if ( jQuery.isFunction( func ) ) {
var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
var dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
i = 0,
length = dataTypes.length,
dataType,
Expand Down Expand Up @@ -613,7 +612,7 @@ jQuery.extend({
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );

// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );

// Determine if a cross-domain request is in order
if ( s.crossDomain == null ) {
Expand Down
9 changes: 4 additions & 5 deletions src/attributes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var rclass = /[\n\t\r]/g,
rspace = /\s+/,
rreturn = /\r/g,
rtype = /^(?:button|input)$/i,
rfocusable = /^(?:button|input|object|select|textarea)$/i,
Expand Down Expand Up @@ -45,7 +44,7 @@ jQuery.fn.extend({
}

if ( value && typeof value === "string" ) {
classNames = value.split( rspace );
classNames = value.split( core_rspace );

for ( i = 0, l = this.length; i < l; i++ ) {
elem = this[ i ];
Expand Down Expand Up @@ -81,7 +80,7 @@ jQuery.fn.extend({
}

if ( (value && typeof value === "string") || value === undefined ) {
classNames = ( value || "" ).split( rspace );
classNames = ( value || "" ).split( core_rspace );

for ( i = 0, l = this.length; i < l; i++ ) {
elem = this[ i ];
Expand Down Expand Up @@ -121,7 +120,7 @@ jQuery.fn.extend({
i = 0,
self = jQuery( this ),
state = stateVal,
classNames = value.split( rspace );
classNames = value.split( core_rspace );

while ( (className = classNames[ i++ ]) ) {
// check each className given, space seperated list
Expand Down Expand Up @@ -359,7 +358,7 @@ jQuery.extend({
value = value.toLowerCase();
}

attrNames = value.split( rspace );
attrNames = value.split( core_rspace );
l = attrNames.length;

for ( ; i < l; i++ ) {
Expand Down
2 changes: 1 addition & 1 deletion src/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var optionsCache = {};
// Convert String-formatted options into Object-formatted ones and store in cache
function createOptions( options ) {
var object = optionsCache[ options ] = {};
jQuery.each( options.split( /\s+/ ), function( _, flag ) {
jQuery.each( options.split( core_rspace ), function( _, flag ) {
object[ flag ] = true;
});
return object;
Expand Down
100 changes: 50 additions & 50 deletions src/core.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,66 @@
// Use the correct document accordingly with window argument (sandbox)
var document = window.document,
navigator = window.navigator,
var
// Use the correct document accordingly with window argument (sandbox)
document = window.document,
location = window.location,
navigator = window.navigator,

// Map over jQuery in case of overwrite
_jQuery = window.jQuery,

// Map over the $ in case of overwrite
_$ = window.$,

// Save a reference to some core methods
toString = Object.prototype.toString,
hasOwn = Object.prototype.hasOwnProperty,
push = Array.prototype.push,
slice = Array.prototype.slice,
trim = String.prototype.trim,
indexOf = Array.prototype.indexOf,
core_push = Array.prototype.push,
core_slice = Array.prototype.slice,
core_indexOf = Array.prototype.indexOf,
core_toString = Object.prototype.toString,
core_hasOwn = Object.prototype.hasOwnProperty,
core_trim = String.prototype.trim,

// Define a local copy of jQuery
jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
},

// Map over jQuery in case of overwrite
_jQuery = window.jQuery,

// Map over the $ in case of overwrite
_$ = window.$,

// A central reference to the root jQuery(document)
rootjQuery,

// A simple way to check for HTML strings or ID strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
// The deferred used on DOM ready
readyList,

// Check if a string has a non-whitespace character in it
rnotwhite = /\S/,
// For matching the engine and version of the browser
browserMatch,

// Used for trimming whitespace
// Used for detecting and trimming whitespace
core_rnotwhite = /\S/,
core_rspace = /\s+/,
trimLeft = /^\s+/,
trimRight = /\s+$/,

// A simple way to check for HTML strings or ID strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,

// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,

// JSON RegExp
rvalidchars = /^[\],:{}\s]*$/,
rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,

// Useragent RegExp
rwebkit = /(webkit)[ \/]([\w.]+)/,
ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
rmsie = /(msie) ([\w.]+)/,
rwebkit = /(webkit)[ \/]([\w.]+)/,
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,

// Matches dashed string for camelizing
rdashAlpha = /-([a-z]|[0-9])/ig,
rmsPrefix = /^-ms-/,
rdashAlpha = /-([\da-z])/gi,

// Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) {
Expand All @@ -64,12 +70,6 @@ var document = window.document,
// Keep a UserAgent string for use with jQuery.browser
userAgent = navigator.userAgent,

// For matching the engine and version of the browser
browserMatch,

// The deferred used on DOM ready
readyList,

// The ready event handler and self cleanup method
DOMContentLoaded = function() {
if ( document.addEventListener ) {
Expand Down Expand Up @@ -200,7 +200,7 @@ jQuery.fn = jQuery.prototype = {
},

toArray: function() {
return slice.call( this );
return core_slice.call( this );
},

// Get the Nth element in the matched element set OR
Expand All @@ -222,7 +222,7 @@ jQuery.fn = jQuery.prototype = {
var ret = this.constructor();

if ( jQuery.isArray( elems ) ) {
push.apply( ret, elems );
core_push.apply( ret, elems );

} else {
jQuery.merge( ret, elems );
Expand Down Expand Up @@ -273,8 +273,8 @@ jQuery.fn = jQuery.prototype = {
},

slice: function() {
return this.pushStack( slice.apply( this, arguments ),
"slice", slice.call(arguments).join(",") );
return this.pushStack( core_slice.apply( this, arguments ),
"slice", core_slice.call(arguments).join(",") );
},

map: function( callback ) {
Expand All @@ -289,7 +289,7 @@ jQuery.fn = jQuery.prototype = {

// For internal use only.
// Behaves like an Array's method, not like a jQuery method.
push: push,
push: core_push,
sort: [].sort,
splice: [].splice
};
Expand Down Expand Up @@ -440,7 +440,7 @@ jQuery.extend({
type: function( obj ) {
return obj == null ?
String( obj ) :
class2type[ toString.call(obj) ] || "object";
class2type[ core_toString.call(obj) ] || "object";
},

isPlainObject: function( obj ) {
Expand All @@ -454,8 +454,8 @@ jQuery.extend({
try {
// Not own constructor property must be Object
if ( obj.constructor &&
!hasOwn.call(obj, "constructor") &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
!core_hasOwn.call(obj, "constructor") &&
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
return false;
}
} catch ( e ) {
Expand All @@ -469,7 +469,7 @@ jQuery.extend({
var key;
for ( key in obj ) {}

return key === undefined || hasOwn.call( obj, key );
return key === undefined || core_hasOwn.call( obj, key );
},

isEmptyObject: function( obj ) {
Expand Down Expand Up @@ -538,7 +538,7 @@ jQuery.extend({
// Workarounds based on findings by Jim Driscoll
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
globalEval: function( data ) {
if ( data && rnotwhite.test( data ) ) {
if ( data && core_rnotwhite.test( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
Expand Down Expand Up @@ -600,11 +600,11 @@ jQuery.extend({
},

// Use native String.trim function wherever possible
trim: trim ?
trim: core_trim ?
function( text ) {
return text == null ?
"" :
trim.call( text );
core_trim.call( text );
} :

// Otherwise use our own trimming functionality
Expand All @@ -624,7 +624,7 @@ jQuery.extend({
var type = jQuery.type( array );

if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
push.call( ret, array );
core_push.call( ret, array );
} else {
jQuery.merge( ret, array );
}
Expand All @@ -637,8 +637,8 @@ jQuery.extend({
var len;

if ( array ) {
if ( indexOf ) {
return indexOf.call( array, elem, i );
if ( core_indexOf ) {
return core_indexOf.call( array, elem, i );
}

len = array.length;
Expand Down Expand Up @@ -743,9 +743,9 @@ jQuery.extend({
}

// Simulated bind
var args = slice.call( arguments, 2 ),
var args = core_slice.call( arguments, 2 ),
proxy = function() {
return fn.apply( context, args.concat( slice.call( arguments ) ) );
return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
};

// Set the guid of unique handler to the same of original handler, so it can be removed
Expand Down Expand Up @@ -910,7 +910,7 @@ if ( jQuery.browser.webkit ) {
}

// IE doesn't match non-breaking spaces with \s
if ( rnotwhite.test( "\xA0" ) ) {
if ( core_rnotwhite.test( "\xA0" ) ) {
trimLeft = /^[\s\xA0]+/;
trimRight = /[\s\xA0]+$/;
}
Expand Down
4 changes: 2 additions & 2 deletions src/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function showHide( elements, show ) {
// for such an element
if ( (elem.style.display === "" && curCSS( elem, "display" ) === "none") ||
!jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
}
} else {
display = curCSS( elem, "display" );
Expand Down Expand Up @@ -434,7 +434,7 @@ function getWidthOrHeight( elem, name, extra ) {


// Try to determine the default display value of an element
function defaultDisplay( nodeName ) {
function css_defaultDisplay( nodeName ) {
if ( elemdisplay[ nodeName ] ) {
return elemdisplay[ nodeName ];
}
Expand Down
7 changes: 2 additions & 5 deletions src/deferred.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
var // Static reference to slice
sliceDeferred = [].slice;

jQuery.extend({

Deferred: function( func ) {
Expand Down Expand Up @@ -93,7 +90,7 @@ jQuery.extend({
// Deferred helper
when: function( subordinate /* , ..., subordinateN */ ) {
var i = 0,
resolveValues = sliceDeferred.call( arguments ),
resolveValues = core_slice.call( arguments ),
length = resolveValues.length,

// the count of uncompleted subordinates
Expand All @@ -106,7 +103,7 @@ jQuery.extend({
updateFunc = function( i, contexts, values ) {
return function( value ) {
contexts[ i ] = this;
values[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments ) : value;
values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
if( values === progressValues ) {
deferred.notifyWith( contexts, values );
} else if ( !( --remaining ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function defaultPrefilter( elem, props, opts ) {

// inline-level elements accept inline-block;
// block-level elements need to be inline with layout
if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
style.display = "inline-block";

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
rtagName = /<([\w:]+)/,
rtbody = /<tbody/i,
rhtml = /<|&#?\w+;/,
Expand Down
2 changes: 1 addition & 1 deletion src/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ jQuery.each({
ret = ret.reverse();
}

return this.pushStack( ret, name, slice.call( arguments ).join(",") );
return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
};
});

Expand Down

0 comments on commit a101e81

Please sign in to comment.