Merge branch 'master' of github.com:jquery/jquery
This commit is contained in:
commit
72ddc8c645
8 changed files with 50 additions and 55 deletions
|
@ -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() {
|
||||
|
|
29
src/event.js
29
src/event.js
|
@ -275,7 +275,7 @@ jQuery.event = {
|
|||
"changeData": true
|
||||
},
|
||||
|
||||
trigger: function( event, data, elem, bubbling /* For Internal Use Only */ ) {
|
||||
trigger: function( event, data, elem ) {
|
||||
// Event object or event type
|
||||
var type = event.type || event,
|
||||
namespaces = [],
|
||||
|
@ -304,10 +304,11 @@ jQuery.event = {
|
|||
// jQuery.Event object
|
||||
event[ jQuery.expando ] ? event :
|
||||
// Object literal
|
||||
jQuery.extend( jQuery.Event(type), event ) :
|
||||
new jQuery.Event( type, event ) :
|
||||
// Just the event type (string)
|
||||
jQuery.Event(type);
|
||||
new jQuery.Event( type );
|
||||
|
||||
event.type = type;
|
||||
event.namespace = namespaces.join(".");
|
||||
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
|
||||
event.exclusive = exclusive;
|
||||
|
@ -562,26 +563,15 @@ 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 ];
|
||||
}
|
||||
}
|
||||
|
||||
// Always ensure a type has been explicitly set
|
||||
this.type = src.type;
|
||||
|
||||
// Events bubbling up the document may have been marked as prevented
|
||||
|
@ -594,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();
|
||||
|
@ -980,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] );
|
||||
|
|
|
@ -553,6 +553,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'
|
||||
|
@ -630,15 +632,16 @@ 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 ) {
|
||||
var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), function( elem ) {
|
||||
return !elem.type || rscriptType.test( elem.type );
|
||||
});
|
||||
var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
|
||||
|
||||
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
||||
}
|
||||
|
|
|
@ -73,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",
|
||||
|
||||
|
@ -196,7 +196,7 @@ jQuery.support = (function() {
|
|||
marginDiv.style.marginRight = "0";
|
||||
div.appendChild( marginDiv );
|
||||
support.reliableMarginRight =
|
||||
( parseInt( document.defaultView.getComputedStyle( marginDiv ).marginRight, 10 ) || 0 ) === 0;
|
||||
( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0;
|
||||
}
|
||||
|
||||
// Remove the body element we added
|
||||
|
@ -224,9 +224,6 @@ jQuery.support = (function() {
|
|||
}
|
||||
}
|
||||
|
||||
// release memory in IE
|
||||
body = div = all = a = tds = undefined;
|
||||
|
||||
return support;
|
||||
})();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue