Merge branch '1.7/callbacks' of github.com:jquery/jquery into 1.7/callbacks
Conflicts: src/callbacks.js test/index.html test/unit/callbacks.js
This commit is contained in:
commit
a745ac8c03
|
@ -20,11 +20,11 @@ jQuery.fn.extend({
|
|||
jQuery.removeAttr( this, name );
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
prop: function( name, value ) {
|
||||
return jQuery.access( this, name, value, true, jQuery.prop );
|
||||
},
|
||||
|
||||
|
||||
removeProp: function( name ) {
|
||||
name = jQuery.propFix[ name ] || name;
|
||||
return this.each(function() {
|
||||
|
@ -156,7 +156,7 @@ jQuery.fn.extend({
|
|||
val: function( value ) {
|
||||
var hooks, ret,
|
||||
elem = this[0];
|
||||
|
||||
|
||||
if ( !arguments.length ) {
|
||||
if ( elem ) {
|
||||
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
|
||||
|
@ -167,9 +167,9 @@ jQuery.fn.extend({
|
|||
|
||||
ret = elem.value;
|
||||
|
||||
return typeof ret === "string" ?
|
||||
return typeof ret === "string" ?
|
||||
// handle most common string cases
|
||||
ret.replace(rreturn, "") :
|
||||
ret.replace(rreturn, "") :
|
||||
// handle cases where value is null/undef or number
|
||||
ret == null ? "" : ret;
|
||||
}
|
||||
|
@ -290,15 +290,15 @@ jQuery.extend({
|
|||
height: true,
|
||||
offset: true
|
||||
},
|
||||
|
||||
|
||||
attrFix: {
|
||||
// Always normalize to ensure hook usage
|
||||
tabindex: "tabIndex"
|
||||
},
|
||||
|
||||
|
||||
attr: function( elem, name, value, pass ) {
|
||||
var nType = elem.nodeType;
|
||||
|
||||
|
||||
// don't get/set attributes on text, comment and attribute nodes
|
||||
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
||||
return undefined;
|
||||
|
@ -367,7 +367,7 @@ jQuery.extend({
|
|||
var propName;
|
||||
if ( elem.nodeType === 1 ) {
|
||||
name = jQuery.attrFix[ name ] || name;
|
||||
|
||||
|
||||
if ( jQuery.support.getSetAttribute ) {
|
||||
// Use removeAttribute in browsers that support it
|
||||
elem.removeAttribute( name );
|
||||
|
@ -431,7 +431,7 @@ jQuery.extend({
|
|||
frameborder: "frameBorder",
|
||||
contenteditable: "contentEditable"
|
||||
},
|
||||
|
||||
|
||||
prop: function( elem, name, value ) {
|
||||
var nType = elem.nodeType;
|
||||
|
||||
|
@ -445,7 +445,7 @@ jQuery.extend({
|
|||
|
||||
// Try to normalize/fix the name
|
||||
name = notxml && jQuery.propFix[ name ] || name;
|
||||
|
||||
|
||||
hooks = jQuery.propHooks[ name ];
|
||||
|
||||
if ( value !== undefined ) {
|
||||
|
@ -465,7 +465,7 @@ jQuery.extend({
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
propHooks: {}
|
||||
});
|
||||
|
||||
|
@ -522,7 +522,7 @@ if ( !jQuery.support.getSetAttribute ) {
|
|||
|
||||
// propFix is more comprehensive and contains all fixes
|
||||
jQuery.attrFix = jQuery.propFix;
|
||||
|
||||
|
||||
// Use this for any attribute on a form in IE6/7
|
||||
formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = {
|
||||
get: function( elem, name ) {
|
||||
|
|
114
test/abortonunload.php
Normal file
114
test/abortonunload.php
Normal file
|
@ -0,0 +1,114 @@
|
|||
<?php sleep(3) ?><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
jQuery Abort-On-Unload Test
|
||||
</title>
|
||||
<style>
|
||||
div { margin-top: 10px; }
|
||||
.alphalist { list-style-type: upper-alpha; }
|
||||
</style>
|
||||
<script src="../src/core.js"></script>
|
||||
<script src="../src/deferred.js"></script>
|
||||
<script src="../src/support.js"></script>
|
||||
<script src="../src/data.js"></script>
|
||||
<script src="../src/queue.js"></script>
|
||||
<script src="../src/attributes.js"></script>
|
||||
<script src="../src/event.js"></script>
|
||||
<script src="../src/sizzle/sizzle.js"></script>
|
||||
<script src="../src/sizzle-jquery.js"></script>
|
||||
<script src="../src/traversing.js"></script>
|
||||
<script src="../src/manipulation.js"></script>
|
||||
<script src="../src/css.js"></script>
|
||||
<script src="../src/ajax.js"></script>
|
||||
<script src="../src/ajax/jsonp.js"></script>
|
||||
<script src="../src/ajax/script.js"></script>
|
||||
<script src="../src/ajax/xhr.js"></script>
|
||||
<script src="../src/effects.js"></script>
|
||||
<script src="../src/offset.js"></script>
|
||||
<script src="../src/dimensions.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( function() {
|
||||
var done = true,
|
||||
button = $( "button" );
|
||||
button.click(function() {
|
||||
jQuery.ajax({
|
||||
url: "data/name.php?wait=10",
|
||||
cache: false,
|
||||
beforeSend: function() {
|
||||
button.attr( "disabled" , true );
|
||||
done = false;
|
||||
},
|
||||
success: function() {
|
||||
console.log( "success", arguments );
|
||||
},
|
||||
error: function() {
|
||||
console.log( "error", arguments );
|
||||
alert( "error" );
|
||||
},
|
||||
complete: function() {
|
||||
button.attr( "disabled" , false );
|
||||
done = true;
|
||||
}
|
||||
});
|
||||
document.location = document.location.href;
|
||||
});
|
||||
jQuery( window ).bind( "beforeunload", function( evt ) {
|
||||
if ( !done ) {
|
||||
return evt.returnValue = "Fire unload?";
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
jQuery Abort-On-Unload Test
|
||||
</h1>
|
||||
<div>
|
||||
This page tests a fix that will abort requests on abort so that Internet Explorer
|
||||
does not keep connections alive.
|
||||
</div>
|
||||
<div>
|
||||
In this situation, no callback should be triggered.
|
||||
</div>
|
||||
<div>Take the following steps:</div>
|
||||
<ol>
|
||||
<li>
|
||||
open the console,
|
||||
</li>
|
||||
<li>
|
||||
set it to persistent mode if available,
|
||||
</li>
|
||||
<li>
|
||||
click this
|
||||
<button>
|
||||
button
|
||||
</button>
|
||||
to make a request and trigger the beforeunload event,
|
||||
</li>
|
||||
<li>
|
||||
then either:
|
||||
<ol class="alphalist">
|
||||
<li>
|
||||
wait for the request to complete then cancel unload,
|
||||
</li>
|
||||
<li>
|
||||
fire unload (you have 10 seconds to do so).
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
<div>
|
||||
Test passes if:
|
||||
<ol class="alphalist">
|
||||
<li>
|
||||
you get a "success" logged,
|
||||
</li>
|
||||
<li>
|
||||
you get no "error" log and no alert.
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -182,16 +182,16 @@
|
|||
<td id='submitSubmit' class="red">BUTTON</td>
|
||||
<td id='boundSubmit' class="red">DOCUMENT</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</table>
|
||||
|
||||
<h1>Mouseleave Tests</h1>
|
||||
|
||||
<div class="out" style="margin:20px; border:1px solid #000; background: red;">
|
||||
<p>Count mouse leave event</p>
|
||||
<div class="in" style="background: green; margin: 10px auto; width: 50%;">
|
||||
<p>mouse over here should not trigger the counter.</p>
|
||||
</div>
|
||||
<p>0</p>
|
||||
<p>Count mouse leave event</p>
|
||||
<div class="in" style="background: green; margin: 10px auto; width: 50%;">
|
||||
<p>mouse over here should not trigger the counter.</p>
|
||||
</div>
|
||||
<p>0</p>
|
||||
</div>
|
||||
|
||||
<ul id="log"></ul>
|
||||
|
|
|
@ -6,7 +6,7 @@ var functionReturningObj = function(value) { return (function() { return value;
|
|||
|
||||
test("jQuery.attrFix/jQuery.propFix integrity test", function() {
|
||||
expect(2);
|
||||
|
||||
|
||||
// This must be maintained and equal jQuery.attrFix when appropriate
|
||||
// Ensure that accidental or erroneous property
|
||||
// overwrites don't occur
|
||||
|
@ -57,7 +57,7 @@ test("attr(String)", function() {
|
|||
equals( jQuery("<div value='t'></div>").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
|
||||
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
|
||||
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
|
||||
|
||||
|
||||
// [7472] & [3113] (form contains an input with name="action" or name="id")
|
||||
var extras = jQuery("<input name='id' name='name' /><input id='target' name='target' />").appendTo("#testForm");
|
||||
equals( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
|
||||
|
@ -67,7 +67,7 @@ test("attr(String)", function() {
|
|||
// Bug #3685 (form contains input with name="name")
|
||||
equals( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" );
|
||||
extras.remove();
|
||||
|
||||
|
||||
equals( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" );
|
||||
equals( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" );
|
||||
equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
|
||||
|
@ -248,7 +248,7 @@ test("attr(String, Object)", function() {
|
|||
commentNode = document.createComment("some comment"),
|
||||
textNode = document.createTextNode("some text"),
|
||||
obj = {};
|
||||
|
||||
|
||||
jQuery.each( [commentNode, textNode, attributeNode], function( i, elem ) {
|
||||
var $elem = jQuery( elem );
|
||||
$elem.attr( "nonexisting", "foo" );
|
||||
|
@ -288,7 +288,7 @@ test("attr(String, Object)", function() {
|
|||
j.removeAttr("name");
|
||||
|
||||
QUnit.reset();
|
||||
|
||||
|
||||
// Type
|
||||
var type = jQuery("#check2").attr("type");
|
||||
var thrown = false;
|
||||
|
@ -450,7 +450,7 @@ test("removeAttr(String)", function() {
|
|||
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
|
||||
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
|
||||
equals( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" );
|
||||
|
||||
|
||||
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
|
||||
equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
|
||||
jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
|
||||
|
@ -607,11 +607,11 @@ test("val()", function() {
|
|||
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
|
||||
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
|
||||
equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
|
||||
|
||||
|
||||
equals( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
|
||||
});
|
||||
|
||||
if ( "value" in document.createElement("meter") &&
|
||||
if ( "value" in document.createElement("meter") &&
|
||||
"value" in document.createElement("progress") ) {
|
||||
|
||||
test("val() respects numbers without exception (Bug #9319)", function() {
|
||||
|
@ -758,7 +758,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
|
|||
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
|
||||
|
||||
jQuery("#kk").remove();
|
||||
});
|
||||
});
|
||||
|
||||
var testAddClass = function(valueObj) {
|
||||
expect(5);
|
||||
|
@ -802,7 +802,7 @@ test("addClass(Function) with incoming value", function() {
|
|||
var div = jQuery("div"), old = div.map(function(){
|
||||
return jQuery(this).attr("class") || "";
|
||||
});
|
||||
|
||||
|
||||
div.addClass(function(i, val) {
|
||||
if ( this.id !== "_firebugConsole") {
|
||||
equals( val, old[i], "Make sure the incoming value is correct." );
|
||||
|
|
Loading…
Reference in a new issue