Skip to content

Commit a745ac8

Browse files
committed
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
2 parents 9d0b361 + 3e7c04e commit a745ac8

File tree

4 files changed

+144
-30
lines changed

4 files changed

+144
-30
lines changed

src/attributes.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jQuery.fn.extend({
2020
jQuery.removeAttr( this, name );
2121
});
2222
},
23-
23+
2424
prop: function( name, value ) {
2525
return jQuery.access( this, name, value, true, jQuery.prop );
2626
},
27-
27+
2828
removeProp: function( name ) {
2929
name = jQuery.propFix[ name ] || name;
3030
return this.each(function() {
@@ -156,7 +156,7 @@ jQuery.fn.extend({
156156
val: function( value ) {
157157
var hooks, ret,
158158
elem = this[0];
159-
159+
160160
if ( !arguments.length ) {
161161
if ( elem ) {
162162
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@@ -167,9 +167,9 @@ jQuery.fn.extend({
167167

168168
ret = elem.value;
169169

170-
return typeof ret === "string" ?
170+
return typeof ret === "string" ?
171171
// handle most common string cases
172-
ret.replace(rreturn, "") :
172+
ret.replace(rreturn, "") :
173173
// handle cases where value is null/undef or number
174174
ret == null ? "" : ret;
175175
}
@@ -290,15 +290,15 @@ jQuery.extend({
290290
height: true,
291291
offset: true
292292
},
293-
293+
294294
attrFix: {
295295
// Always normalize to ensure hook usage
296296
tabindex: "tabIndex"
297297
},
298-
298+
299299
attr: function( elem, name, value, pass ) {
300300
var nType = elem.nodeType;
301-
301+
302302
// don't get/set attributes on text, comment and attribute nodes
303303
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
304304
return undefined;
@@ -367,7 +367,7 @@ jQuery.extend({
367367
var propName;
368368
if ( elem.nodeType === 1 ) {
369369
name = jQuery.attrFix[ name ] || name;
370-
370+
371371
if ( jQuery.support.getSetAttribute ) {
372372
// Use removeAttribute in browsers that support it
373373
elem.removeAttribute( name );
@@ -431,7 +431,7 @@ jQuery.extend({
431431
frameborder: "frameBorder",
432432
contenteditable: "contentEditable"
433433
},
434-
434+
435435
prop: function( elem, name, value ) {
436436
var nType = elem.nodeType;
437437

@@ -445,7 +445,7 @@ jQuery.extend({
445445

446446
// Try to normalize/fix the name
447447
name = notxml && jQuery.propFix[ name ] || name;
448-
448+
449449
hooks = jQuery.propHooks[ name ];
450450

451451
if ( value !== undefined ) {
@@ -465,7 +465,7 @@ jQuery.extend({
465465
}
466466
}
467467
},
468-
468+
469469
propHooks: {}
470470
});
471471

@@ -522,7 +522,7 @@ if ( !jQuery.support.getSetAttribute ) {
522522

523523
// propFix is more comprehensive and contains all fixes
524524
jQuery.attrFix = jQuery.propFix;
525-
525+
526526
// Use this for any attribute on a form in IE6/7
527527
formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = {
528528
get: function( elem, name ) {

test/abortonunload.php

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php sleep(3) ?><!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>
5+
jQuery Abort-On-Unload Test
6+
</title>
7+
<style>
8+
div { margin-top: 10px; }
9+
.alphalist { list-style-type: upper-alpha; }
10+
</style>
11+
<script src="../src/core.js"></script>
12+
<script src="../src/deferred.js"></script>
13+
<script src="../src/support.js"></script>
14+
<script src="../src/data.js"></script>
15+
<script src="../src/queue.js"></script>
16+
<script src="../src/attributes.js"></script>
17+
<script src="../src/event.js"></script>
18+
<script src="../src/sizzle/sizzle.js"></script>
19+
<script src="../src/sizzle-jquery.js"></script>
20+
<script src="../src/traversing.js"></script>
21+
<script src="../src/manipulation.js"></script>
22+
<script src="../src/css.js"></script>
23+
<script src="../src/ajax.js"></script>
24+
<script src="../src/ajax/jsonp.js"></script>
25+
<script src="../src/ajax/script.js"></script>
26+
<script src="../src/ajax/xhr.js"></script>
27+
<script src="../src/effects.js"></script>
28+
<script src="../src/offset.js"></script>
29+
<script src="../src/dimensions.js"></script>
30+
<script type="text/javascript">
31+
$( function() {
32+
var done = true,
33+
button = $( "button" );
34+
button.click(function() {
35+
jQuery.ajax({
36+
url: "data/name.php?wait=10",
37+
cache: false,
38+
beforeSend: function() {
39+
button.attr( "disabled" , true );
40+
done = false;
41+
},
42+
success: function() {
43+
console.log( "success", arguments );
44+
},
45+
error: function() {
46+
console.log( "error", arguments );
47+
alert( "error" );
48+
},
49+
complete: function() {
50+
button.attr( "disabled" , false );
51+
done = true;
52+
}
53+
});
54+
document.location = document.location.href;
55+
});
56+
jQuery( window ).bind( "beforeunload", function( evt ) {
57+
if ( !done ) {
58+
return evt.returnValue = "Fire unload?";
59+
}
60+
});
61+
});
62+
</script>
63+
</head>
64+
<body>
65+
<h1>
66+
jQuery Abort-On-Unload Test
67+
</h1>
68+
<div>
69+
This page tests a fix that will abort requests on abort so that Internet Explorer
70+
does not keep connections alive.
71+
</div>
72+
<div>
73+
In this situation, no callback should be triggered.
74+
</div>
75+
<div>Take the following steps:</div>
76+
<ol>
77+
<li>
78+
open the console,
79+
</li>
80+
<li>
81+
set it to persistent mode if available,
82+
</li>
83+
<li>
84+
click this
85+
<button>
86+
button
87+
</button>
88+
to make a request and trigger the beforeunload event,
89+
</li>
90+
<li>
91+
then either:
92+
<ol class="alphalist">
93+
<li>
94+
wait for the request to complete then cancel unload,
95+
</li>
96+
<li>
97+
fire unload (you have 10 seconds to do so).
98+
</li>
99+
</ol>
100+
</li>
101+
</ol>
102+
<div>
103+
Test passes if:
104+
<ol class="alphalist">
105+
<li>
106+
you get a "success" logged,
107+
</li>
108+
<li>
109+
you get no "error" log and no alert.
110+
</li>
111+
</ol>
112+
</div>
113+
</body>
114+
</html>

test/delegatetest.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,16 @@ <h2>Submit Tests</h2>
182182
<td id='submitSubmit' class="red">BUTTON</td>
183183
<td id='boundSubmit' class="red">DOCUMENT</td>
184184
</tr>
185-
</table>
186-
185+
</table>
186+
187187
<h1>Mouseleave Tests</h1>
188188

189189
<div class="out" style="margin:20px; border:1px solid #000; background: red;">
190-
<p>Count mouse leave event</p>
191-
<div class="in" style="background: green; margin: 10px auto; width: 50%;">
192-
<p>mouse over here should not trigger the counter.</p>
193-
</div>
194-
<p>0</p>
190+
<p>Count mouse leave event</p>
191+
<div class="in" style="background: green; margin: 10px auto; width: 50%;">
192+
<p>mouse over here should not trigger the counter.</p>
193+
</div>
194+
<p>0</p>
195195
</div>
196196

197197
<ul id="log"></ul>

test/unit/attributes.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var functionReturningObj = function(value) { return (function() { return value;
66

77
test("jQuery.attrFix/jQuery.propFix integrity test", function() {
88
expect(2);
9-
9+
1010
// This must be maintained and equal jQuery.attrFix when appropriate
1111
// Ensure that accidental or erroneous property
1212
// overwrites don't occur
@@ -57,7 +57,7 @@ test("attr(String)", function() {
5757
equals( jQuery("<div value='t'></div>").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
5858
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
5959
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
60-
60+
6161
// [7472] & [3113] (form contains an input with name="action" or name="id")
6262
var extras = jQuery("<input name='id' name='name' /><input id='target' name='target' />").appendTo("#testForm");
6363
equals( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
@@ -67,7 +67,7 @@ test("attr(String)", function() {
6767
// Bug #3685 (form contains input with name="name")
6868
equals( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" );
6969
extras.remove();
70-
70+
7171
equals( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" );
7272
equals( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" );
7373
equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
@@ -248,7 +248,7 @@ test("attr(String, Object)", function() {
248248
commentNode = document.createComment("some comment"),
249249
textNode = document.createTextNode("some text"),
250250
obj = {};
251-
251+
252252
jQuery.each( [commentNode, textNode, attributeNode], function( i, elem ) {
253253
var $elem = jQuery( elem );
254254
$elem.attr( "nonexisting", "foo" );
@@ -288,7 +288,7 @@ test("attr(String, Object)", function() {
288288
j.removeAttr("name");
289289

290290
QUnit.reset();
291-
291+
292292
// Type
293293
var type = jQuery("#check2").attr("type");
294294
var thrown = false;
@@ -450,7 +450,7 @@ test("removeAttr(String)", function() {
450450
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
451451
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
452452
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" );
453-
453+
454454
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
455455
equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
456456
jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
@@ -607,11 +607,11 @@ test("val()", function() {
607607
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
608608
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
609609
equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
610-
610+
611611
equals( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
612612
});
613613

614-
if ( "value" in document.createElement("meter") &&
614+
if ( "value" in document.createElement("meter") &&
615615
"value" in document.createElement("progress") ) {
616616

617617
test("val() respects numbers without exception (Bug #9319)", function() {
@@ -758,7 +758,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
758758
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
759759

760760
jQuery("#kk").remove();
761-
});
761+
});
762762

763763
var testAddClass = function(valueObj) {
764764
expect(5);
@@ -802,7 +802,7 @@ test("addClass(Function) with incoming value", function() {
802802
var div = jQuery("div"), old = div.map(function(){
803803
return jQuery(this).attr("class") || "";
804804
});
805-
805+
806806
div.addClass(function(i, val) {
807807
if ( this.id !== "_firebugConsole") {
808808
equals( val, old[i], "Make sure the incoming value is correct." );

0 commit comments

Comments
 (0)