Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch '1.7/callbacks' of github.com:jquery/jquery into 1.7/cal…

…lbacks

Conflicts:
	src/callbacks.js
	test/index.html
	test/unit/callbacks.js
  • Loading branch information...
commit a745ac8c038bf06089473869e40c0e10b5101b7b 2 parents 9d0b361 + 3e7c04e
Julian Aubourg jaubourg authored
26 src/attributes.js
@@ -20,11 +20,11 @@ jQuery.fn.extend({
20 20 jQuery.removeAttr( this, name );
21 21 });
22 22 },
23   -
  23 +
24 24 prop: function( name, value ) {
25 25 return jQuery.access( this, name, value, true, jQuery.prop );
26 26 },
27   -
  27 +
28 28 removeProp: function( name ) {
29 29 name = jQuery.propFix[ name ] || name;
30 30 return this.each(function() {
@@ -156,7 +156,7 @@ jQuery.fn.extend({
156 156 val: function( value ) {
157 157 var hooks, ret,
158 158 elem = this[0];
159   -
  159 +
160 160 if ( !arguments.length ) {
161 161 if ( elem ) {
162 162 hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@@ -167,9 +167,9 @@ jQuery.fn.extend({
167 167
168 168 ret = elem.value;
169 169
170   - return typeof ret === "string" ?
  170 + return typeof ret === "string" ?
171 171 // handle most common string cases
172   - ret.replace(rreturn, "") :
  172 + ret.replace(rreturn, "") :
173 173 // handle cases where value is null/undef or number
174 174 ret == null ? "" : ret;
175 175 }
@@ -290,15 +290,15 @@ jQuery.extend({
290 290 height: true,
291 291 offset: true
292 292 },
293   -
  293 +
294 294 attrFix: {
295 295 // Always normalize to ensure hook usage
296 296 tabindex: "tabIndex"
297 297 },
298   -
  298 +
299 299 attr: function( elem, name, value, pass ) {
300 300 var nType = elem.nodeType;
301   -
  301 +
302 302 // don't get/set attributes on text, comment and attribute nodes
303 303 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
304 304 return undefined;
@@ -367,7 +367,7 @@ jQuery.extend({
367 367 var propName;
368 368 if ( elem.nodeType === 1 ) {
369 369 name = jQuery.attrFix[ name ] || name;
370   -
  370 +
371 371 if ( jQuery.support.getSetAttribute ) {
372 372 // Use removeAttribute in browsers that support it
373 373 elem.removeAttribute( name );
@@ -431,7 +431,7 @@ jQuery.extend({
431 431 frameborder: "frameBorder",
432 432 contenteditable: "contentEditable"
433 433 },
434   -
  434 +
435 435 prop: function( elem, name, value ) {
436 436 var nType = elem.nodeType;
437 437
@@ -445,7 +445,7 @@ jQuery.extend({
445 445
446 446 // Try to normalize/fix the name
447 447 name = notxml && jQuery.propFix[ name ] || name;
448   -
  448 +
449 449 hooks = jQuery.propHooks[ name ];
450 450
451 451 if ( value !== undefined ) {
@@ -465,7 +465,7 @@ jQuery.extend({
465 465 }
466 466 }
467 467 },
468   -
  468 +
469 469 propHooks: {}
470 470 });
471 471
@@ -522,7 +522,7 @@ if ( !jQuery.support.getSetAttribute ) {
522 522
523 523 // propFix is more comprehensive and contains all fixes
524 524 jQuery.attrFix = jQuery.propFix;
525   -
  525 +
526 526 // Use this for any attribute on a form in IE6/7
527 527 formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = {
528 528 get: function( elem, name ) {
114 test/abortonunload.php
... ... @@ -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>
14 test/delegatetest.html
@@ -182,16 +182,16 @@
182 182 <td id='submitSubmit' class="red">BUTTON</td>
183 183 <td id='boundSubmit' class="red">DOCUMENT</td>
184 184 </tr>
185   - </table>
186   -
  185 + </table>
  186 +
187 187 <h1>Mouseleave Tests</h1>
188 188
189 189 <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>
195 195 </div>
196 196
197 197 <ul id="log"></ul>
20 test/unit/attributes.js
@@ -6,7 +6,7 @@ var functionReturningObj = function(value) { return (function() { return value;
6 6
7 7 test("jQuery.attrFix/jQuery.propFix integrity test", function() {
8 8 expect(2);
9   -
  9 +
10 10 // This must be maintained and equal jQuery.attrFix when appropriate
11 11 // Ensure that accidental or erroneous property
12 12 // overwrites don't occur
@@ -57,7 +57,7 @@ test("attr(String)", function() {
57 57 equals( jQuery("<div value='t'></div>").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
58 58 equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
59 59 equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
60   -
  60 +
61 61 // [7472] & [3113] (form contains an input with name="action" or name="id")
62 62 var extras = jQuery("<input name='id' name='name' /><input id='target' name='target' />").appendTo("#testForm");
63 63 equals( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
@@ -67,7 +67,7 @@ test("attr(String)", function() {
67 67 // Bug #3685 (form contains input with name="name")
68 68 equals( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" );
69 69 extras.remove();
70   -
  70 +
71 71 equals( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" );
72 72 equals( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" );
73 73 equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
@@ -248,7 +248,7 @@ test("attr(String, Object)", function() {
248 248 commentNode = document.createComment("some comment"),
249 249 textNode = document.createTextNode("some text"),
250 250 obj = {};
251   -
  251 +
252 252 jQuery.each( [commentNode, textNode, attributeNode], function( i, elem ) {
253 253 var $elem = jQuery( elem );
254 254 $elem.attr( "nonexisting", "foo" );
@@ -288,7 +288,7 @@ test("attr(String, Object)", function() {
288 288 j.removeAttr("name");
289 289
290 290 QUnit.reset();
291   -
  291 +
292 292 // Type
293 293 var type = jQuery("#check2").attr("type");
294 294 var thrown = false;
@@ -450,7 +450,7 @@ test("removeAttr(String)", function() {
450 450 equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
451 451 equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
452 452 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 +
454 454 jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
455 455 equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
456 456 jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
@@ -607,11 +607,11 @@ test("val()", function() {
607 607 var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
608 608 equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
609 609 equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
610   -
  610 +
611 611 equals( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
612 612 });
613 613
614   -if ( "value" in document.createElement("meter") &&
  614 +if ( "value" in document.createElement("meter") &&
615 615 "value" in document.createElement("progress") ) {
616 616
617 617 test("val() respects numbers without exception (Bug #9319)", function() {
@@ -758,7 +758,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
758 758 same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
759 759
760 760 jQuery("#kk").remove();
761   -});
  761 +});
762 762
763 763 var testAddClass = function(valueObj) {
764 764 expect(5);
@@ -802,7 +802,7 @@ test("addClass(Function) with incoming value", function() {
802 802 var div = jQuery("div"), old = div.map(function(){
803 803 return jQuery(this).attr("class") || "";
804 804 });
805   -
  805 +
806 806 div.addClass(function(i, val) {
807 807 if ( this.id !== "_firebugConsole") {
808 808 equals( val, old[i], "Make sure the incoming value is correct." );

0 comments on commit a745ac8

Please sign in to comment.
Something went wrong with that request. Please try again.