Merge branch 'master' of github.com:jquery/jquery
This commit is contained in:
commit
72ddc8c645
|
@ -14,13 +14,12 @@ jQuery.ajaxSetup({
|
||||||
// Detect, normalize options and install callbacks for jsonp requests
|
// Detect, normalize options and install callbacks for jsonp requests
|
||||||
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
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" ||
|
if ( s.dataTypes[ 0 ] === "jsonp" ||
|
||||||
originalSettings.jsonpCallback ||
|
|
||||||
originalSettings.jsonp != null ||
|
|
||||||
s.jsonp !== false && ( jsre.test( s.url ) ||
|
s.jsonp !== false && ( jsre.test( s.url ) ||
|
||||||
dataIsString && jsre.test( s.data ) ) ) {
|
inspectData && jsre.test( s.data ) ) ) {
|
||||||
|
|
||||||
var responseContainer,
|
var responseContainer,
|
||||||
jsonpCallback = s.jsonpCallback =
|
jsonpCallback = s.jsonpCallback =
|
||||||
|
@ -28,20 +27,12 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
||||||
previous = window[ jsonpCallback ],
|
previous = window[ jsonpCallback ],
|
||||||
url = s.url,
|
url = s.url,
|
||||||
data = s.data,
|
data = s.data,
|
||||||
replace = "$1" + jsonpCallback + "$2",
|
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 ] );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if ( s.jsonp !== false ) {
|
if ( s.jsonp !== false ) {
|
||||||
url = url.replace( jsre, replace );
|
url = url.replace( jsre, replace );
|
||||||
if ( s.url === url ) {
|
if ( s.url === url ) {
|
||||||
if ( dataIsString ) {
|
if ( inspectData ) {
|
||||||
data = data.replace( jsre, replace );
|
data = data.replace( jsre, replace );
|
||||||
}
|
}
|
||||||
if ( s.data === data ) {
|
if ( s.data === data ) {
|
||||||
|
@ -59,8 +50,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
||||||
responseContainer = [ response ];
|
responseContainer = [ response ];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Install cleanUp function
|
// Clean-up function
|
||||||
jqXHR.then( cleanUp, cleanUp );
|
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
|
// Use data converter to retrieve json after script execution
|
||||||
s.converters["script json"] = function() {
|
s.converters["script json"] = function() {
|
||||||
|
|
29
src/event.js
29
src/event.js
|
@ -275,7 +275,7 @@ jQuery.event = {
|
||||||
"changeData": true
|
"changeData": true
|
||||||
},
|
},
|
||||||
|
|
||||||
trigger: function( event, data, elem, bubbling /* For Internal Use Only */ ) {
|
trigger: function( event, data, elem ) {
|
||||||
// Event object or event type
|
// Event object or event type
|
||||||
var type = event.type || event,
|
var type = event.type || event,
|
||||||
namespaces = [],
|
namespaces = [],
|
||||||
|
@ -304,10 +304,11 @@ jQuery.event = {
|
||||||
// jQuery.Event object
|
// jQuery.Event object
|
||||||
event[ jQuery.expando ] ? event :
|
event[ jQuery.expando ] ? event :
|
||||||
// Object literal
|
// Object literal
|
||||||
jQuery.extend( jQuery.Event(type), event ) :
|
new jQuery.Event( type, event ) :
|
||||||
// Just the event type (string)
|
// Just the event type (string)
|
||||||
jQuery.Event(type);
|
new jQuery.Event( type );
|
||||||
|
|
||||||
|
event.type = type;
|
||||||
event.namespace = namespaces.join(".");
|
event.namespace = namespaces.join(".");
|
||||||
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
|
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
|
||||||
event.exclusive = exclusive;
|
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
|
// Allow instantiation without the 'new' keyword
|
||||||
if ( !this.preventDefault ) {
|
if ( !this.preventDefault ) {
|
||||||
return new jQuery.Event( src );
|
return new jQuery.Event( src, props );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event object
|
// Event object
|
||||||
if ( src && src.type ) {
|
if ( src && src.type ) {
|
||||||
this.originalEvent = src;
|
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;
|
this.type = src.type;
|
||||||
|
|
||||||
// Events bubbling up the document may have been marked as prevented
|
// Events bubbling up the document may have been marked as prevented
|
||||||
|
@ -594,6 +584,11 @@ jQuery.Event = function( src ) {
|
||||||
this.type = 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)
|
// timeStamp is buggy for some events on Firefox(#3843)
|
||||||
// So we won't rely on the native value
|
// So we won't rely on the native value
|
||||||
this.timeStamp = jQuery.now();
|
this.timeStamp = jQuery.now();
|
||||||
|
@ -980,7 +975,7 @@ jQuery.fn.extend({
|
||||||
|
|
||||||
triggerHandler: function( type, data ) {
|
triggerHandler: function( type, data ) {
|
||||||
if ( this[0] ) {
|
if ( this[0] ) {
|
||||||
var event = jQuery.Event( type );
|
var event = new jQuery.Event( type );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
jQuery.event.trigger( event, data, this[0] );
|
jQuery.event.trigger( event, data, this[0] );
|
||||||
|
|
|
@ -553,6 +553,8 @@ jQuery.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
clean: function( elems, context, fragment, scripts ) {
|
clean: function( elems, context, fragment, scripts ) {
|
||||||
|
var checkScriptType;
|
||||||
|
|
||||||
context = context || document;
|
context = context || document;
|
||||||
|
|
||||||
// !context.createElement fails in IE with an error but returns typeof 'object'
|
// !context.createElement fails in IE with an error but returns typeof 'object'
|
||||||
|
@ -630,15 +632,16 @@ jQuery.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fragment ) {
|
if ( fragment ) {
|
||||||
|
checkScriptType = function( elem ) {
|
||||||
|
return !elem.type || rscriptType.test( elem.type );
|
||||||
|
};
|
||||||
for ( i = 0; ret[i]; i++ ) {
|
for ( i = 0; ret[i]; i++ ) {
|
||||||
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
|
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] );
|
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( ret[i].nodeType === 1 ) {
|
if ( ret[i].nodeType === 1 ) {
|
||||||
var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), function( elem ) {
|
var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
|
||||||
return !elem.type || rscriptType.test( elem.type );
|
|
||||||
});
|
|
||||||
|
|
||||||
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ jQuery.support = (function() {
|
||||||
marginDiv.style.marginRight = "0";
|
marginDiv.style.marginRight = "0";
|
||||||
div.appendChild( marginDiv );
|
div.appendChild( marginDiv );
|
||||||
support.reliableMarginRight =
|
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
|
// 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;
|
return support;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
@ -109,3 +109,6 @@ div#show-tests * { display: none; }
|
||||||
#nothiddendiv { font-size: 16px; }
|
#nothiddendiv { font-size: 16px; }
|
||||||
#nothiddendivchild.em { font-size: 2em; }
|
#nothiddendivchild.em { font-size: 2em; }
|
||||||
#nothiddendivchild.prct { font-size: 150%; }
|
#nothiddendivchild.prct { font-size: 150%; }
|
||||||
|
|
||||||
|
/* For testing type on vml in IE #7071 */
|
||||||
|
v\:oval { behavior:url(#default#VML); display:inline-block; }
|
|
@ -45,10 +45,6 @@
|
||||||
<script src="unit/effects.js"></script>
|
<script src="unit/effects.js"></script>
|
||||||
<script src="unit/offset.js"></script>
|
<script src="unit/offset.js"></script>
|
||||||
<script src="unit/dimensions.js"></script>
|
<script src="unit/dimensions.js"></script>
|
||||||
|
|
||||||
<!-- For testing http://bugs.jquery.com/ticket/7071 -->
|
|
||||||
<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" />
|
|
||||||
<style>v\:oval { behavior:url(#default#VML); display:inline-block; }</style>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body id="body">
|
<body id="body">
|
||||||
|
@ -151,7 +147,6 @@
|
||||||
<span id="test.foo[5]bar" class="test.foo[5]bar"></span>
|
<span id="test.foo[5]bar" class="test.foo[5]bar"></span>
|
||||||
|
|
||||||
<foo_bar id="foobar">test element</foo_bar>
|
<foo_bar id="foobar">test element</foo_bar>
|
||||||
<v:oval id="oval" style="width:100pt;height:75pt;" fillcolor="red"> </v:oval>
|
|
||||||
</form>
|
</form>
|
||||||
<b id="floatTest">Float test.</b>
|
<b id="floatTest">Float test.</b>
|
||||||
<iframe id="iframe" name="iframe"></iframe>
|
<iframe id="iframe" name="iframe"></iframe>
|
||||||
|
|
|
@ -492,6 +492,7 @@ test("val()", function() {
|
||||||
var testVal = function(valueObj) {
|
var testVal = function(valueObj) {
|
||||||
expect(8);
|
expect(8);
|
||||||
|
|
||||||
|
QUnit.reset();
|
||||||
jQuery("#text1").val(valueObj( "test" ));
|
jQuery("#text1").val(valueObj( "test" ));
|
||||||
equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
|
equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
|
||||||
|
|
||||||
|
@ -504,15 +505,16 @@ var testVal = function(valueObj) {
|
||||||
jQuery("#text1").val(valueObj( null ));
|
jQuery("#text1").val(valueObj( null ));
|
||||||
equals( document.getElementById("text1").value, "", "Check for modified (via val(null)) value of input element" );
|
equals( document.getElementById("text1").value, "", "Check for modified (via val(null)) value of input element" );
|
||||||
|
|
||||||
jQuery("#select1").val(valueObj( "3" ));
|
var $select1 = jQuery("#select1");
|
||||||
equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
|
$select1.val(valueObj( "3" ));
|
||||||
|
equals( $select1.val(), "3", "Check for modified (via val(String)) value of select element" );
|
||||||
|
|
||||||
jQuery("#select1").val(valueObj( 2 ));
|
$select1.val(valueObj( 2 ));
|
||||||
equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
|
equals( $select1.val(), "2", "Check for modified (via val(Number)) value of select element" );
|
||||||
|
|
||||||
jQuery("#select1").append("<option value='4'>four</option>");
|
$select1.append("<option value='4'>four</option>");
|
||||||
jQuery("#select1").val(valueObj( 4 ));
|
$select1.val(valueObj( 4 ));
|
||||||
equals( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" );
|
equals( $select1.val(), "4", "Should be possible to set the val() to a newly created option" );
|
||||||
|
|
||||||
// using contents will get comments regular, text, and comment nodes
|
// using contents will get comments regular, text, and comment nodes
|
||||||
var j = jQuery("#nonnodes").contents();
|
var j = jQuery("#nonnodes").contents();
|
||||||
|
|
|
@ -778,6 +778,8 @@ test("trigger() shortcuts", function() {
|
||||||
elem.remove();
|
elem.remove();
|
||||||
|
|
||||||
// test that special handlers do not blow up with VML elements (#7071)
|
// test that special handlers do not blow up with VML elements (#7071)
|
||||||
|
jQuery('<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" />').appendTo('head');
|
||||||
|
jQuery('<v:oval id="oval" style="width:100pt;height:75pt;" fillcolor="red"> </v:oval>').appendTo('#form');
|
||||||
jQuery("#oval").click().keydown();
|
jQuery("#oval").click().keydown();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -978,11 +980,11 @@ test("trigger(eventObject, [data], [fn])", function() {
|
||||||
$parent.unbind().remove();
|
$parent.unbind().remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("jQuery.Event({ /* props */ })", function() {
|
test("jQuery.Event( type, props )", function() {
|
||||||
|
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
var event = jQuery.Event({ type: "keydown", keyCode: 64 }),
|
var event = jQuery.Event( "keydown", { keyCode: 64 }),
|
||||||
handler = function( event ) {
|
handler = function( event ) {
|
||||||
ok( "keyCode" in event, "Special property 'keyCode' exists" );
|
ok( "keyCode" in event, "Special property 'keyCode' exists" );
|
||||||
equal( event.keyCode, 64, "event.keyCode has explicit value '64'" );
|
equal( event.keyCode, 64, "event.keyCode has explicit value '64'" );
|
||||||
|
|
Loading…
Reference in a new issue