Commit 8806435a authored by louisremi's avatar louisremi

Merge branch 'master' of http://github.com/jquery/jquery into effectsCleanup

parents 780b7983 38d6d9f6
......@@ -111,7 +111,7 @@ update_submodules:
# 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 foreach "git pull \$$(git config remote.origin.url)"
@@git submodule summary
pull: pull_submodules
......
......@@ -63,7 +63,7 @@ As the source code is handled by the version control system Git, it's useful to
### Submodules ###
The repository uses submodules, which normally are handles directly by the Makefile, but sometimes you want to
The repository uses submodules, which normally are handled directly by the Makefile, but sometimes you want to
be able to work with them manually.
Following are the steps to manually get the submodules:
......@@ -86,7 +86,7 @@ If you want to work inside a submodule, it is possible, but first you need to ch
1. `cd src/sizzle`
2. `git checkout master`
After you've commited your changes to the submodule, you'll update the jquery project to point to the new commit,
After you've committed your changes to the submodule, you'll update the jquery project to point to the new commit,
but remember to push the submodule changes before pushing the new jquery commit:
1. `cd src/sizzle`
......@@ -99,12 +99,12 @@ The makefile has some targets to simplify submodule handling:
#### `make update_submodules` ####
checks out the commit pointed to byu jquery, but merges your local changes, if any. This target is executed
checks out the commit pointed to by jquery, but merges your local changes, if any. This target is executed
when you are doing a normal `make`.
#### `make pull_submodules` ####
updates the content of the submoduels to what is probably the latest upstream code
updates the content of the submodules to what is probably the latest upstream code.
#### `make pull` ####
......
......@@ -14,13 +14,12 @@ jQuery.ajaxSetup({
// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
var dataIsString = ( typeof s.data === "string" );
var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
( typeof s.data === "string" );
if ( s.dataTypes[ 0 ] === "jsonp" ||
originalSettings.jsonpCallback ||
originalSettings.jsonp != null ||
s.jsonp !== false && ( jsre.test( s.url ) ||
dataIsString && jsre.test( s.data ) ) ) {
inspectData && jsre.test( s.data ) ) ) {
var responseContainer,
jsonpCallback = s.jsonpCallback =
......@@ -28,20 +27,12 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
previous = window[ jsonpCallback ],
url = s.url,
data = s.data,
replace = "$1" + jsonpCallback + "$2",
cleanUp = function() {
// Set callback back to previous value
window[ jsonpCallback ] = previous;
// Call if it was a function and we have a response
if ( responseContainer && jQuery.isFunction( previous ) ) {
window[ jsonpCallback ]( responseContainer[ 0 ] );
}
};
replace = "$1" + jsonpCallback + "$2";
if ( s.jsonp !== false ) {
url = url.replace( jsre, replace );
if ( s.url === url ) {
if ( dataIsString ) {
if ( inspectData ) {
data = data.replace( jsre, replace );
}
if ( s.data === data ) {
......@@ -59,8 +50,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
responseContainer = [ response ];
};
// Install cleanUp function
jqXHR.then( cleanUp, cleanUp );
// Clean-up function
jqXHR.always(function() {
// Set callback back to previous value
window[ jsonpCallback ] = previous;
// Call if it was a function and we have a response
if ( responseContainer && jQuery.isFunction( previous ) ) {
window[ jsonpCallback ]( responseContainer[ 0 ] );
}
});
// Use data converter to retrieve json after script execution
s.converters["script json"] = function() {
......
......@@ -479,7 +479,7 @@ jQuery.each([ "selected", "checked", "readOnly", "disabled" ], function( i, name
// Some attributes require a special call on IE
if ( !jQuery.support.hrefNormalized ) {
jQuery.each([ "href", "src", "width", "height", "list" ], function( i, name ) {
jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
get: function( elem ) {
var ret = elem.getAttribute( name, 2 );
......
......@@ -358,9 +358,11 @@ jQuery.extend = jQuery.fn.extend = function() {
jQuery.extend({
noConflict: function( deep ) {
window.$ = _$;
if ( window.$ === jQuery ) {
window.$ = _$;
}
if ( deep ) {
if ( deep && window.jQuery === jQuery ) {
window.jQuery = _jQuery;
}
......@@ -436,7 +438,7 @@ jQuery.extend({
} else if ( document.attachEvent ) {
// ensure firing before onload,
// maybe late but safe also for iframes
document.attachEvent("onreadystatechange", DOMContentLoaded);
document.attachEvent( "onreadystatechange", DOMContentLoaded );
// A fallback to window.onload, that will always work
window.attachEvent( "onload", jQuery.ready );
......@@ -587,7 +589,7 @@ jQuery.extend({
each: function( object, callback, args ) {
var name, i = 0,
length = object.length,
isObj = length === undefined || jQuery.isFunction(object);
isObj = length === undefined || jQuery.isFunction( object );
if ( args ) {
if ( isObj ) {
......@@ -613,8 +615,11 @@ jQuery.extend({
}
}
} else {
for ( var value = object[0];
i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
for ( ; i < length; ) {
if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
break;
}
}
}
}
......@@ -645,7 +650,7 @@ jQuery.extend({
// The extra typeof function check is to prevent crashes
// in Safari 2 (See: #3039)
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
var type = jQuery.type(array);
var type = jQuery.type( array );
if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
push.call( ret, array );
......@@ -841,24 +846,24 @@ jQuery.extend({
},
sub: function() {
function jQuerySubclass( selector, context ) {
return new jQuerySubclass.fn.init( selector, context );
}
jQuery.extend( true, jQuerySubclass, this );
jQuerySubclass.superclass = this;
jQuerySubclass.fn = jQuerySubclass.prototype = this();
jQuerySubclass.fn.constructor = jQuerySubclass;
jQuerySubclass.subclass = this.subclass;
jQuerySubclass.fn.init = function init( selector, context ) {
if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
context = jQuerySubclass(context);
function jQuerySub( selector, context ) {
return new jQuerySub.fn.init( selector, context );
}
jQuery.extend( true, jQuerySub, this );
jQuerySub.superclass = this;
jQuerySub.fn = jQuerySub.prototype = this();
jQuerySub.fn.constructor = jQuerySub;
jQuerySub.sub = this.sub;
jQuerySub.fn.init = function init( selector, context ) {
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
context = jQuerySub( context );
}
return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
};
jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
var rootjQuerySubclass = jQuerySubclass(document);
return jQuerySubclass;
jQuerySub.fn.init.prototype = jQuerySub.fn;
var rootjQuerySub = jQuerySub(document);
return jQuerySub;
},
browser: {}
......
......@@ -93,7 +93,7 @@ jQuery.extend({
// convert relative number strings (+= or -=) to relative numbers. #7345
if ( type === "string" && rrelNum.test( value ) ) {
value = +value.replace( rrelNumFilter, '' ) + parseFloat( jQuery.css( elem, name ) );
value = +value.replace( rrelNumFilter, "" ) + parseFloat( jQuery.css( elem, name ) );
}
// If a number was passed in, add 'px' to the (except for certain CSS properties)
......@@ -122,11 +122,17 @@ jQuery.extend({
},
css: function( elem, name, extra ) {
var ret, hooks;
// Make sure that we're working with the right name
var ret, origName = jQuery.camelCase( name ),
hooks = jQuery.cssHooks[ origName ];
name = jQuery.camelCase( name );
hooks = jQuery.cssHooks[ name ];
name = jQuery.cssProps[ name ] || name;
name = jQuery.cssProps[ origName ] || origName;
// cssFloat needs a special treatment
if ( name === "cssFloat" ) {
name = "float";
}
// If a hook was provided get the computed value from there
if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
......@@ -134,7 +140,7 @@ jQuery.extend({
// Otherwise, if a way to get the computed value exists, use that
} else if ( curCSS ) {
return curCSS( elem, name, origName );
return curCSS( elem, name );
}
},
......@@ -225,27 +231,28 @@ if ( !jQuery.support.opacity ) {
jQuery.cssHooks.opacity = {
get: function( elem, computed ) {
// IE uses filters for opacity
return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
(parseFloat(RegExp.$1) / 100) + "" :
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
( parseFloat( RegExp.$1 ) / 100 ) + "" :
computed ? "1" : "";
},
set: function( elem, value ) {
var style = elem.style;
var style = elem.style,
currentStyle = elem.currentStyle;
// IE has trouble with opacity if it does not have layout
// Force it by setting the zoom level
style.zoom = 1;
// Set the alpha filter to set the opacity
var opacity = jQuery.isNaN(value) ?
var opacity = jQuery.isNaN( value ) ?
"" :
"alpha(opacity=" + value * 100 + ")",
filter = style.filter || "";
filter = currentStyle && currentStyle.filter || style.filter || "";
style.filter = ralpha.test(filter) ?
filter.replace(ralpha, opacity) :
style.filter + ' ' + opacity;
style.filter = ralpha.test( filter ) ?
filter.replace( ralpha, opacity ) :
filter + " " + opacity;
}
};
}
......@@ -273,7 +280,7 @@ jQuery(function() {
});
if ( document.defaultView && document.defaultView.getComputedStyle ) {
getComputedStyle = function( elem, newName, name ) {
getComputedStyle = function( elem, name ) {
var ret, defaultView, computedStyle;
name = name.replace( rupper, "-$1" ).toLowerCase();
......
......@@ -152,13 +152,17 @@ jQuery.fn.extend({
var optall = jQuery.speed(speed, easing, callback);
if ( jQuery.isEmptyObject( prop ) ) {
return this.each( optall.complete );
return this.each( optall.complete, [ false ] );
}
return this[ optall.queue === false ? "each" : "queue" ](function() {
// XXX 'this' does not always have a nodeName when running the
// test suite
if ( optall.queue === false ) {
jQuery._mark( this );
}
var opt = jQuery.extend({}, optall), p,
isElement = this.nodeType === 1,
hidden = isElement && jQuery(this).is(":hidden"),
......@@ -268,6 +272,10 @@ jQuery.fn.extend({
}
this.each(function() {
// clear marker counters if we know they won't be
if ( !gotoEnd ) {
jQuery._unmark( true, this );
}
// go in reverse order so anything added to the queue during the loop is ignored
for ( var i = timers.length - 1; i >= 0; i-- ) {
if ( timers[i].elem === this ) {
......@@ -319,10 +327,13 @@ jQuery.extend({
// Queueing
opt.old = opt.complete;
opt.complete = function() {
opt.complete = function( noUnmark ) {
if ( opt.queue !== false ) {
jQuery(this).dequeue();
jQuery.dequeue( this );
} else if ( noUnmark !== false ) {
jQuery._unmark( this );
}
if ( jQuery.isFunction( opt.old ) ) {
opt.old.call( this );
}
......
......@@ -24,17 +24,6 @@ jQuery.event = {
return;
}
// TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
// Minor release fix for bug #8018
try {
// For whatever reason, IE has trouble passing the window object
// around, causing it to be cloned in the process
if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
elem = window;
}
}
catch ( e ) {}
if ( handler === false ) {
handler = returnFalse;
} else if ( !handler ) {
......@@ -277,34 +266,53 @@ jQuery.event = {
}
}
},
// Events that are safe to short-circuit if no handlers are attached.
// Native DOM events should not be added, they may have inline handlers.
customEvent: {
"getData": true,
"setData": true,
"changeData": true
},
trigger: function( event, data, elem ) {
// Event object or event type
var type = event.type || event,
namespaces = [];
event = typeof event === "object" ?
// jQuery.Event object
event[ jQuery.expando ] ? event :
// Object literal
jQuery.extend( jQuery.Event(type), event ) :
// Just the event type (string)
jQuery.Event(type);
namespaces = [],
exclusive;
if ( type.indexOf("!") >= 0 ) {
// Exclusive events trigger only for the bare event type (no namespaces)
event.type = type = type.slice(0, -1);
event.exclusive = true;
// Exclusive events trigger only for the exact event (no namespaces)
type = type.slice(0, -1);
exclusive = true;
}
if ( type.indexOf(".") >= 0 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split(".");
event.type = type = namespaces.shift();
type = namespaces.shift();
namespaces.sort();
}
if ( jQuery.event.customEvent[ type ] && !jQuery.event.global[ type ] ) {
// No jQuery handlers for this event type, and it can't have inline handlers
return;
}
// Caller can pass in an Event, Object, or just an event type string
event = typeof event === "object" ?
// jQuery.Event object
event[ jQuery.expando ] ? event :
// Object literal
new jQuery.Event( type, event ) :
// Just the event type (string)
new jQuery.Event( type );
event.type = type;
event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
event.exclusive = exclusive;
// Handle a global trigger
if ( !elem ) {
// Don't bubble custom events when global (to avoid too much overhead)
......@@ -338,12 +346,12 @@ jQuery.event = {
event.target = elem;
// Clone any incoming data and prepend the event, creating the handler arg list
data = jQuery.makeArray( data );
data = data ? jQuery.makeArray( data ) : [];
data.unshift( event );
var cur = elem,
// IE doesn't like method names with a colon (#3533, #8272)
ontype = type.indexOf(":") < 0? "on" + type : "";
ontype = type.indexOf(":") < 0 ? "on" + type : "";
// Fire event on the current element, then bubble up the DOM tree
do {
......@@ -355,7 +363,7 @@ jQuery.event = {
}
// Trigger an inline bound script
if ( ontype &&jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
event.result = false;
event.preventDefault();
}
......@@ -403,7 +411,7 @@ jQuery.event = {
// Snapshot the handlers list since a called handler may add/remove events.
var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
run_all = !event.exclusive && !event.namespace,
args = jQuery.makeArray( arguments );
args = Array.prototype.slice.call( arguments, 0 );
// Use the fix-ed Event rather than the (read-only) native event
args[0] = event;
......@@ -555,24 +563,16 @@ jQuery.removeEvent = document.removeEventListener ?
}
};
jQuery.Event = function( src ) {
jQuery.Event = function( src, props ) {
// Allow instantiation without the 'new' keyword
if ( !this.preventDefault ) {
return new jQuery.Event( src );
return new jQuery.Event( src, props );
}
// Event object
if ( src && src.type ) {
this.originalEvent = src;
// Push explicitly provided properties onto the event object
for ( var prop in src ) {
// Ensure we don't clobber jQuery.Event prototype
// with own properties.
if ( hasOwn.call( src, prop ) ) {
this[ prop ] = src[ prop ];
}
}
this.type = src.type;
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
......@@ -584,6 +584,11 @@ jQuery.Event = function( src ) {
this.type = src;
}
// Put explicitly provided properties onto the event object
if ( props ) {
jQuery.extend( this, props );
}
// timeStamp is buggy for some events on Firefox(#3843)
// So we won't rely on the native value
this.timeStamp = jQuery.now();
......@@ -790,7 +795,7 @@ if ( !jQuery.support.changeBubbles ) {
beforedeactivate: testChange,
click: function( e ) {
var elem = e.target, type = elem.type;
var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
testChange.call( this, e );
......@@ -800,7 +805,7 @@ if ( !jQuery.support.changeBubbles ) {
// Change has to be called before submit
// Keydown will be called before keypress, which is used in submit-event delegation
keydown: function( e ) {
var elem = e.target, type = elem.type;
var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
......@@ -955,7 +960,7 @@ jQuery.fn.extend({
undelegate: function( selector, types, fn ) {
if ( arguments.length === 0 ) {
return this.unbind( "live" );
return this.unbind( "live" );
} else {
return this.die( types, null, fn, selector );
......@@ -970,7 +975,7 @@ jQuery.fn.extend({
triggerHandler: function( type, data ) {
if ( this[0] ) {
var event = jQuery.Event( type );
var event = new jQuery.Event( type );
event.preventDefault();
event.stopPropagation();
jQuery.event.trigger( event, data, this[0] );
......@@ -1030,10 +1035,18 @@ jQuery.each(["live", "die"], function( i, name ) {
return this;
}
if ( name === "die" && !types &&
origSelector && origSelector.charAt(0) === "." ) {
context.unbind( origSelector );
return this;
}
if ( data === false || jQuery.isFunction( data ) ) {
fn = data || returnFalse;
data = undefined;
}
}
types = (types || "").split(" ");
......
......@@ -9,6 +9,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rnocache = /<(?:script|object|embed|option|style)/i,
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptType = /\/(java|ecma)script/i,
wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ],
legend: [ 1, "<fieldset>", "</fieldset>" ],
......@@ -387,11 +388,15 @@ function cloneFixAttributes( src, dest ) {
// clearAttributes removes the attributes, which we don't want,
// but also removes the attachEvent events, which we *do* want
dest.clearAttributes();
if ( dest.clearAttributes ) {
dest.clearAttributes();
}
// mergeAttributes, in contrast, only merges back on the
// original attributes, not the events
dest.mergeAttributes(src);
if ( dest.mergeAttributes ) {
dest.mergeAttributes( src );
}
// IE6-8 fail to clone children inside object elements that use
// the proprietary classid attribute value (rather than the type
......@@ -552,6 +557,8 @@ jQuery.extend({
},
clean: function( elems, context, fragment, scripts ) {
var checkScriptType;
context = context || document;
// !context.createElement fails in IE with an error but returns typeof 'object'
......@@ -629,13 +636,18 @@ jQuery.extend({
}
if ( fragment ) {
checkScriptType = function( elem ) {
return !elem.type || rscriptType.test( elem.type );
};
for ( i = 0; ret[i]; i++ ) {
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
} else {
if ( ret[i].nodeType === 1 ) {
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
}
fragment.appendChild( ret[i] );
}
......
......@@ -180,17 +180,19 @@ jQuery.offset = {
curOffset = curElem.offset(),
curCSSTop = jQuery.css( elem, "top" ),
curCSSLeft = jQuery.css( elem, "left" ),
calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1,
calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
props = {}, curPosition = {}, curTop, curLeft;
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
if ( calculatePosition ) {
curPosition = curElem.position();
curTop = curPosition.top;
curLeft = curPosition.left;
} else {
curTop = parseFloat( curCSSTop ) || 0;
curLeft = parseFloat( curCSSLeft ) || 0;
}
curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
if ( jQuery.isFunction( options ) ) {
options = options.call( elem, i, curOffset );
}
......@@ -259,29 +261,16 @@ jQuery.fn.extend({
jQuery.each( ["Left", "Top"], function( i, name ) {
var method = "scroll" + name;
jQuery.fn[ method ] = function(val) {
var elem = this[0], win;
jQuery.fn[ method ] = function( val ) {
var elem, win;
if ( !elem ) {
return null;
}
if ( val === undefined ) {
elem = this[ 0 ];
if ( val !== undefined ) {
// Set the scroll offset
return this.each(function() {
win = getWindow( this );
if ( win ) {
win.scrollTo(
!i ? val : jQuery(win).scrollLeft(),
i ? val : jQuery(win).scrollTop()
);
if ( !elem ) {
return null;
}
} else {
this[ method ] = val;
}
});
} else {
win = getWindow( elem );
// Return the scroll offset
......@@ -290,6 +279,21 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
win.document.body[ method ] :
elem[ method ];
}
// Set the scroll offset
return this.each(function() {
win = getWindow( this );
if ( win ) {
win.scrollTo(
!i ? val : jQuery( win ).scrollLeft(),
i ? val : jQuery( win ).scrollTop()
);
} else {
this[ method ] = val;
}
});
};
});
......
(function( jQuery ) {
jQuery.extend({
queue: function( elem, type, data ) {
if ( !elem ) {
return;
}
function handleQueueMarkDefer( elem, type, src ) {
var deferDataKey = type + "defer",
queueDataKey = type + "queue",
markDataKey = type + "mark",
defer = jQuery.data( elem, deferDataKey, undefined, true );
if ( defer &&
( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
// Give room for hard-coded callbacks to fire first
// and eventually mark/queue something else on the element
setTimeout( function() {
if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
!jQuery.data( elem, markDataKey, undefined, true ) ) {
jQuery.removeData( elem, deferDataKey, true );
defer.resolve();
}
}, 0 );
}
}
type = (type || "fx") + "queue";
var q = jQuery._data( elem, type );
jQuery.extend({
// Speed up dequeue by getting out quickly if this is just a lookup
if ( !data ) {
return q || [];
_mark: function( elem, type ) {
if ( elem ) {
type = (type || "fx") + "mark";
jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
}
},
if ( !q || jQuery.isArray(data) ) {
q = jQuery._data( elem, type, jQuery.makeArray(data) );
} else {
q.push( data );
_unmark: function( force, elem, type ) {
if ( force !== true ) {
type = elem;
elem = force;
force = false;
}
if ( elem ) {
type = type || "fx";
var key = type + "mark",
count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
if ( count ) {
jQuery.data( elem, key, count, true );
} else {
jQuery.removeData( elem, key, true );
handleQueueMarkDefer( elem, type, "mark" );
}
}
},
return q;
queue: function( elem, type, data ) {
if ( elem ) {
type = (type || "fx") + "queue";
var q = jQuery.data( elem, type, undefined, true );
// Speed up dequeue by getting out quickly if this is just a lookup
if ( data ) {
if ( !q || jQuery.isArray(data) ) {
q = jQuery.data( elem, type, jQuery.makeArray(data), true );
} else {
q.push( data );
}
}
return q || [];
}
},
dequeue: function( elem, type ) {
......@@ -50,17 +90,7 @@ jQuery.extend({
if ( !queue.length ) {
jQuery.removeData( elem, type + "queue", true );
// Look if we have observers and resolve if needed
if (( defer = jQuery.data( elem, type + "defer", undefined, true ) )) {
// Give room for hard-coded callbacks to fire first
// and eventually add another animation on the element
setTimeout( function() {
if ( !jQuery.data( elem, type + "queue", undefined, true ) ) {
jQuery.removeData( elem, type + "defer", true );
defer.resolve();
}
}, 0 );
}
handleQueueMarkDefer( elem, type, "queue" );
}
}
});
......@@ -75,7 +105,7 @@ jQuery.fn.extend({
if ( data === undefined ) {
return jQuery.queue( this[0], type );
}
return this.each(function( i ) {
return this.each(function() {
var queue = jQuery.queue( this, type, data );
if ( type === "fx" && queue[0] !== "inprogress" ) {
......@@ -88,7 +118,6 @@ jQuery.fn.extend({
jQuery.dequeue( this, type );
});
},
// Based off of the plugin by Clint Helfers, with permission.
// http://blindsignals.com/index.php/2009/07/jquery-delay/
delay: function( time, type ) {
......@@ -102,11 +131,9 @@ jQuery.fn.extend({
}, time );
});
},
clearQueue: function( type ) {
return this.queue( type || "fx", [] );
},
// Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default)
promise: function( type, object ) {
......@@ -120,7 +147,8 @@ jQuery.fn.extend({
i = elements.length,
count = 1,
deferDataKey = type + "defer",
queueDataKey = type + "queue";
queueDataKey = type + "queue",
markDataKey = type + "mark";
function resolve() {
if ( !( --count ) ) {
defer.resolveWith( elements, [ elements ] );
......@@ -128,7 +156,8 @@ jQuery.fn.extend({
}
while( i-- ) {
if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
jQuery.data( elements[ i ], queueDataKey, undefined, true ) &&
( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
count++;
tmp.done( resolve );
......
Subproject commit c50b0cddec48494ba882606d03e14cce647d243b
Subproject commit 69ecd019852c1421cbd81fe6ceb4e22a81022ea7
......@@ -8,6 +8,7 @@ jQuery.support = (function() {
select,
opt,
input,
marginDiv,
support,
fragment,
body,
......@@ -72,7 +73,7 @@ jQuery.support = (function() {
// Make sure that a selected-by-default option has a working selected property.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
optSelected: opt.selected,
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
getSetAttribute: div.className !== "t",
......@@ -190,10 +191,12 @@ jQuery.support = (function() {
// Fails in WebKit before Feb 2011 nightlies
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
if ( document.defaultView && document.defaultView.getComputedStyle ) {
div.style.width = "1px";
div.style.marginRight = "0";
marginDiv = document.createElement('div');
marginDiv.style.width = "0";
marginDiv.style.marginRight = "0";
div.appendChild( marginDiv );
support.reliableMarginRight =
( parseInt( document.defaultView.getComputedStyle(div).marginRight, 10 ) || 0 ) === 0;
( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0;
}
// Remove the body element we added
......@@ -221,9 +224,6 @@ jQuery.support = (function() {
}
}
// release memory in IE
body = div = all = a = tds = undefined;
return support;
})();
......
......@@ -73,9 +73,9 @@ jQuery.fn.extend({
},
is: function( selector ) {
return !!selector && (typeof selector === "string" ?
return !!selector && ( typeof selector === "string" ?
jQuery.filter( selector, this ).length > 0 :
this.filter( selector ).length > 0);
this.filter( selector ).length > 0 );
},
closest: function( selectors, context ) {
......@@ -298,13 +298,18 @@ jQuery.extend({
// Implement the identical functionality for filter and not
function winnow( elements, qualifier, keep ) {
// Can't pass null or undefined to indexOf in Firefox 4
// Set to 0 to skip string check
qualifier = qualifier || 0;
if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep(elements, function( elem, i ) {
var retVal = !!qualifier.call( elem, i, elem );
return retVal === keep;
});
} else if ( qualifier && qualifier.nodeType ) {
} else if ( qualifier.nodeType ) {
return jQuery.grep(elements, function( elem, i ) {
return (elem === qualifier) === keep;
});
......
/* for testing opacity set in styles in IE */
ol#empty { opacity: 0; filter:Alpha(opacity=0); }
ol#empty { opacity: 0; filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff'); }
div#fx-tests h4 {
background: red;
......@@ -109,3 +109,6 @@ div#show-tests * { display: none; }
#nothiddendiv { font-size: 16px; }
#nothiddendivchild.em { font-size: 2em; }
#nothiddendivchild.prct { font-size: 150%; }
/* For testing type on vml in IE #7071 */
v\:oval { behavior:url(#default#VML); display:inline-block; }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -283,11 +283,11 @@ test(".data(String) and .data(String, Object)", function() {
// #3748
var $elem = jQuery({exists:true});
equals( $elem.data('nothing'), undefined, "Non-existent data returns undefined");
equals( $elem.data('null',null).data('null'), null, "null's are preserved");
equals( $elem.data('emptyString','').data('emptyString'), '', "Empty strings are preserved");
equals( $elem.data('false',false).data('false'), false, "false's are preserved");
equals( $elem.data('exists'), undefined, "Existing data is not returned" );
equals( $elem.data("nothing"), undefined, "Non-existent data returns undefined");
equals( $elem.data("null", null).data("null"), null, "null's are preserved");
equals( $elem.data("emptyString", "").data("emptyString"), "", "Empty strings are preserved");
equals( $elem.data("false", false).data("false"), false, "false's are preserved");
equals( $elem.data("exists"), undefined, "Existing data is not returned" );
// Clean up
$elem.removeData();
......@@ -316,7 +316,7 @@ test("data-* attributes", function() {
div.remove();
child.appendTo('#main');
child.appendTo("#main");
equals( child.data("myobj"), "old data", "Value accessed from data-* attribute");
child.data("myobj", "replaced");
......@@ -365,19 +365,19 @@ test("data-* attributes", function() {
.attr("data-null", "null")
.attr("data-string", "test");
strictEqual( child.data('true'), true, "Primitive true read from attribute");
strictEqual( child.data('false'), false, "Primitive false read from attribute");
strictEqual( child.data('five'), 5, "Primitive number read from attribute");
strictEqual( child.data('point'), 5.5, "Primitive number read from attribute");
strictEqual( child.data('pointe'), 5500, "Primitive number read from attribute");
strictEqual( child.data('pointbad'), "5..5", "Bad number read from attribute");
strictEqual( child.data('pointbad2'), "-.", "Bad number read from attribute");
strictEqual( child.data('badjson'), "{123}", "Bad number read from attribute");
strictEqual( child.data('badjson2'), "[abc]", "Bad number read from attribute");
strictEqual( child.data('empty'), "", "Empty string read from attribute");
strictEqual( child.data('space'), " ", "Empty string read from attribute");
strictEqual( child.data('null'), null, "Primitive null read from attribute");
strictEqual( child.data('string'), "test", "Typical string read from attribute");
strictEqual( child.data("true"), true, "Primitive true read from attribute");
strictEqual( child.data("false"), false, "Primitive false read from attribute");
strictEqual( child.data("five"), 5, "Primitive number read from attribute");
strictEqual( child.data("point"), 5.5, "Primitive number read from attribute");
strictEqual( child.data("pointe"), 5500, "Primitive number read from attribute");
strictEqual( child.data("pointbad"), "5..5", "Bad number read from attribute");
strictEqual( child.data("pointbad2"), "-.", "Bad number read from attribute");
strictEqual( child.data("badjson"), "{123}", "Bad number read from attribute");
strictEqual( child.data("badjson2"), "[abc]", "Bad number read from attribute");
strictEqual( child.data("empty"), "", "Empty string read from attribute");
strictEqual( child.data("space"), " ", "Empty string read from attribute");
strictEqual( child.data("null"), null, "Primitive null read from attribute");
strictEqual( child.data("string"), "test", "Typical string read from attribute");
child.remove();
......@@ -401,12 +401,12 @@ test("data-* attributes", function() {
same(jQuery(elem).data("stuff"), [2,8], "Check stuff property");
break;
default:
ok(false, ["Assertion failed on index ", index, ", with data ", data].join(''));
ok(false, ["Assertion failed on index ", index, ", with data ", data].join(""));
}
}
var metadata = '<ol><li class="test test2" data-foo="bar" data-bar="baz" data-arr="[1,2]">Some stuff</li><li class="test test2" data-test="bar" data-bar="baz">Some stuff</li><li class="test test2" data-zoooo="bar" data-bar=\'{"test":"baz"}\'>Some stuff</li><li class="test test2" data-number=true data-stuff="[2,8]">Some stuff</li></ol>',
elem = jQuery(metadata).appendTo('#main');
var metadata = "<ol><li class='test test2' data-foo='bar' data-bar='baz' data-arr='[1,2]'>Some stuff</li><li class='test test2' data-test='bar' data-bar='baz'>Some stuff</li><li class='test test2' data-zoooo='bar' data-bar='{\"test\":\"baz\"}'>Some stuff</li><li class='test test2' data-number=true data-stuff='[2,8]'>Some stuff</li></ol>",
elem = jQuery(metadata).appendTo("#main");
elem.find("li").each(testData);
elem.remove();
......@@ -483,7 +483,7 @@ if (window.JSON && window.JSON.stringify) {
var obj = { foo: "bar" };
jQuery.data(obj, "hidden", true);
equals( JSON.stringify(obj), '{"foo":"bar"}', "Expando is hidden from JSON.stringify" );
equals( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
});
}
......
......@@ -34,7 +34,7 @@ function testWidth( val ) {
equals( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
equals( blah.width(), null, "Make sure 'null' is returned on an empty set");
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
}
test("width()", function() {
......@@ -83,7 +83,7 @@ function testHeight( val ) {
equals( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
equals( blah.height(), null, "Make sure 'null' is returned on an empty set");
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
}
test("height()", function() {
......@@ -132,7 +132,7 @@ test("innerWidth()", function() {
equals( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
});
test("innerHeight()", function() {
......@@ -161,7 +161,7 @@ test("innerHeight()", function() {
equals( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
});
test("outerWidth()", function() {
......@@ -191,7 +191,7 @@ test("outerWidth()", function() {
equals( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
});
test("outerHeight()", function() {
......@@ -220,5 +220,5 @@ test("outerHeight()", function() {
equals( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment