Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/jquery/jquery into bug_2773
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Mar 23, 2011
2 parents 9e5ec37 + 7705c35 commit d2eafa0
Show file tree
Hide file tree
Showing 28 changed files with 537 additions and 448 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -4,7 +4,5 @@ dist
*~
*.diff
*.patch
test/qunit
src/sizzle
/*.html
.DS_Store
6 changes: 6 additions & 0 deletions .gitmodules
@@ -0,0 +1,6 @@
[submodule "src/sizzle"]
path = src/sizzle
url = git://github.com/jeresig/sizzle.git
[submodule "test/qunit"]
path = test/qunit
url = git://github.com/jquery/qunit.git
63 changes: 28 additions & 35 deletions Makefile
@@ -1,5 +1,3 @@
V ?= 0

SRC_DIR = src
TEST_DIR = test
BUILD_DIR = build
Expand All @@ -12,6 +10,7 @@ COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js

BASE_FILES = ${SRC_DIR}/core.js\
${SRC_DIR}/deferred.js\
${SRC_DIR}/support.js\
${SRC_DIR}/data.js\
${SRC_DIR}/queue.js\
Expand All @@ -37,48 +36,21 @@ JQ = ${DIST_DIR}/jquery.js
JQ_MIN = ${DIST_DIR}/jquery.min.js

SIZZLE_DIR = ${SRC_DIR}/sizzle
QUNIT_DIR = ${TEST_DIR}/qunit

JQ_VER = $(shell cat version.txt)
VER = sed "s/@VERSION/${JQ_VER}/"

DATE=$(shell git log -1 --pretty=format:%ad)

all: jquery min lint
all: update_submodules core

core: jquery min lint
@@echo "jQuery build complete."

${DIST_DIR}:
@@mkdir -p ${DIST_DIR}

ifeq ($(strip $(V)),0)
verbose = --quiet
else ifeq ($(strip $(V)),1)
verbose =
else
verbose = --verbose
endif

define clone_or_pull
-@@if test ! -d $(strip ${1})/.git; then \
echo "Cloning $(strip ${1})..."; \
git clone $(strip ${verbose}) --depth=1 $(strip ${2}) $(strip ${1}); \
else \
echo "Pulling $(strip ${1})..."; \
git --git-dir=$(strip ${1})/.git pull $(strip ${verbose}) origin master; \
fi

endef

${QUNIT_DIR}:
$(call clone_or_pull, ${QUNIT_DIR}, git://github.com/jquery/qunit.git)

${SIZZLE_DIR}:
$(call clone_or_pull, ${SIZZLE_DIR}, git://github.com/jeresig/sizzle.git)

init: ${QUNIT_DIR} ${SIZZLE_DIR}

jquery: init ${JQ}
jq: init ${JQ}
jquery: ${JQ}

${JQ}: ${MODULES} | ${DIST_DIR}
@@echo "Building" ${JQ}
Expand Down Expand Up @@ -121,7 +93,28 @@ clean:
@@echo "Removing built copy of Sizzle"
@@rm -f src/selector.js

@@echo "Removing cloned directories"
distclean: clean
@@echo "Removing submodules"
@@rm -rf test/qunit src/sizzle

.PHONY: all jquery lint min init jq clean
# change pointers for submodules and update them to what is specified in jQuery
# --merge doesn't work when doing an initial clone, thus test if we have non-existing
# submodules, then do an real update
update_submodules:
@@if [ -d .git ]; then \
if git submodule status | grep -q -E '^-'; then \
git submodule update --init --recursive; \
else \
git submodule update --init --recursive --merge; \
fi; \
fi;

# update the submodules to the latest at the most logical branch
pull_submodules:
@@git submodule foreach "git pull origin \$$(git branch --no-color --contains \$$(git rev-parse HEAD) | grep -v \( | head -1)"
@@git submodule summary

pull: pull_submodules
@@git pull ${REMOTE} ${BRANCH}

.PHONY: all jquery lint min clean distclean update_submodules pull_submodules pull core
6 changes: 3 additions & 3 deletions src/ajax.js
Expand Up @@ -7,7 +7,7 @@ var r20 = /%20/g,
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
// #7653, #8125, #8152: local protocol detection
rlocalProtocol = /(?:^file|^widget|\-extension):$/,
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/,
rnoContent = /^(?:GET|HEAD)$/,
rprotocol = /^\/\//,
rquery = /\?/,
Expand All @@ -19,7 +19,7 @@ var r20 = /%20/g,
rucHeadersFunc = function( _, $1, $2 ) {
return $1 + $2.toUpperCase();
},
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?|\/[^\/])/,
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,

// Keep a copy of the old load method
_load = jQuery.fn.load,
Expand Down Expand Up @@ -61,7 +61,7 @@ try {
}

// Segment location into parts
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() );
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];

// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) {
Expand Down
11 changes: 6 additions & 5 deletions src/ajax/xhr.js
Expand Up @@ -92,11 +92,12 @@ if ( jQuery.support.ajax ) {
xhr.overrideMimeType( s.mimeType );
}

// Requested-With header
// Not set for crossDomain requests with no content
// (see why at http://trac.dojotoolkit.org/ticket/9486)
// Won't change header if already provided
if ( !( s.crossDomain && !s.hasContent ) && !headers["X-Requested-With"] ) {
// X-Requested-With header
// For cross-domain requests, seeing as conditions for a preflight are
// akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided.
if ( !s.crossDomain && !headers["X-Requested-With"] ) {
headers[ "X-Requested-With" ] = "XMLHttpRequest";
}

Expand Down
172 changes: 2 additions & 170 deletions src/core.js
Expand Up @@ -50,15 +50,9 @@ var jQuery = function( selector, context ) {
// For matching the engine and version of the browser
browserMatch,

// Has the ready events already been bound?
readyBound = false,

// The deferred used on DOM ready
readyList,

// Promise methods
promiseMethods = "then done fail isResolved isRejected promise".split( " " ),

// The ready event handler
DOMContentLoaded,

Expand Down Expand Up @@ -408,11 +402,11 @@ jQuery.extend({
},

bindReady: function() {
if ( readyBound ) {
if ( readyList ) {
return;
}

readyBound = true;
readyList = jQuery._Deferred();

// Catch cases where $(document).ready() is called after the
// browser event has already occurred.
Expand Down Expand Up @@ -792,165 +786,6 @@ jQuery.extend({
return (new Date()).getTime();
},

// Create a simple deferred (one callbacks list)
_Deferred: function() {
var // callbacks list
callbacks = [],
// stored [ context , args ]
fired,
// to avoid firing when already doing so
firing,
// flag to know if the deferred has been cancelled
cancelled,
// the deferred itself
deferred = {

// done( f1, f2, ...)
done: function() {
if ( !cancelled ) {
var args = arguments,
i,
length,
elem,
type,
_fired;
if ( fired ) {
_fired = fired;
fired = 0;
}
for ( i = 0, length = args.length; i < length; i++ ) {
elem = args[ i ];
type = jQuery.type( elem );
if ( type === "array" ) {
deferred.done.apply( deferred, elem );
} else if ( type === "function" ) {
callbacks.push( elem );
}
}
if ( _fired ) {
deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
}
}
return this;
},

// resolve with given context and args
resolveWith: function( context, args ) {
if ( !cancelled && !fired && !firing ) {
firing = 1;
try {
while( callbacks[ 0 ] ) {
callbacks.shift().apply( context, args );
}
}
finally {
fired = [ context, args ];
firing = 0;
}
}
return this;
},

// resolve with this as context and given arguments
resolve: function() {
deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
return this;
},

// Has this deferred been resolved?
isResolved: function() {
return !!( firing || fired );
},

// Cancel
cancel: function() {
cancelled = 1;
callbacks = [];
return this;
}
};

return deferred;
},

// Full fledged deferred (two callbacks list)
Deferred: function( func ) {
var deferred = jQuery._Deferred(),
failDeferred = jQuery._Deferred(),
promise;
// Add errorDeferred methods, then and promise
jQuery.extend( deferred, {
then: function( doneCallbacks, failCallbacks ) {
deferred.done( doneCallbacks ).fail( failCallbacks );
return this;
},
fail: failDeferred.done,
rejectWith: failDeferred.resolveWith,
reject: failDeferred.resolve,
isRejected: failDeferred.isResolved,
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
promise: function( obj ) {
if ( obj == null ) {
if ( promise ) {
return promise;
}
promise = obj = {};
}
var i = promiseMethods.length;
while( i-- ) {
obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
}
return obj;
}
} );
// Make sure only one callback list will be used
deferred.done( failDeferred.cancel ).fail( deferred.cancel );
// Unexpose cancel
delete deferred.cancel;
// Call given func if any
if ( func ) {
func.call( deferred, deferred );
}
return deferred;
},

// Deferred helper
when: function( object ) {
var lastIndex = arguments.length,
deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
object :
jQuery.Deferred(),
promise = deferred.promise();

if ( lastIndex > 1 ) {
var array = slice.call( arguments, 0 ),
count = lastIndex,
iCallback = function( index ) {
return function( value ) {
array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
if ( !( --count ) ) {
deferred.resolveWith( promise, array );
}
};
};
while( ( lastIndex-- ) ) {
object = array[ lastIndex ];
if ( object && jQuery.isFunction( object.promise ) ) {
object.promise().then( iCallback(lastIndex), deferred.reject );
} else {
--count;
}
}
if ( !count ) {
deferred.resolveWith( promise, array );
}
} else if ( deferred !== object ) {
deferred.resolve( object );
}
return promise;
},

// Use of jQuery.browser is frowned upon.
// More details: http://docs.jquery.com/Utilities/jQuery.browser
uaMatch: function( ua ) {
Expand Down Expand Up @@ -989,9 +824,6 @@ jQuery.extend({
browser: {}
});

// Create readyList deferred
readyList = jQuery._Deferred();

// Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
class2type[ "[object " + name + "]" ] = name.toLowerCase();
Expand Down

0 comments on commit d2eafa0

Please sign in to comment.