From efd0fce7a1ae9bc62ef2b1aa51d7adc224da1ec0 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Mon, 9 May 2011 09:48:23 +0200 Subject: [PATCH 1/2] Fixes #9109. When jQuery is loaded in the body, then the fake body element used in support has to be inserted before the document's body for boxModel to be properly detected (got the hint by looking at the code in jQuery mobile). Test page added so that we can keep checking this. --- src/support.js | 5 +++-- test/boxModelIE.html | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 test/boxModelIE.html diff --git a/src/support.js b/src/support.js index 41af0632..9a6a318d 100644 --- a/src/support.js +++ b/src/support.js @@ -3,6 +3,7 @@ jQuery.support = (function() { var div = document.createElement( "div" ), + documentElement = document.documentElement, all, a, select, @@ -150,7 +151,7 @@ jQuery.support = (function() { body.style[ i ] = bodyStyle[ i ]; } body.appendChild( div ); - document.documentElement.appendChild( body ); + documentElement.insertBefore( body, documentElement.firstChild ); // Check if a disconnected checkbox will retain its checked // value of true after appended to the DOM (IE6/7) @@ -210,7 +211,7 @@ jQuery.support = (function() { // Remove the body element we added body.innerHTML = ""; - document.documentElement.removeChild( body ); + documentElement.removeChild( body ); // Technique from Juriy Zaytsev // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ diff --git a/test/boxModelIE.html b/test/boxModelIE.html new file mode 100644 index 00000000..f8e6a431 --- /dev/null +++ b/test/boxModelIE.html @@ -0,0 +1,33 @@ + + + +

jQuery Test boxModel detection in IE 6 & 7 compatMode="CSS1Compat"

+
document.compatMode = ?
+
jQuery.support.boxModel = ?
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8c13cfa805c0576a2f02f33beb9d15d73afd2d41 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Mon, 9 May 2011 10:01:20 +0200 Subject: [PATCH 2/2] Fixes #9104. Returning null or undefined in a pipe callback shouldn't end up throwing an exception. Silly, silly, me. --- src/deferred.js | 2 +- test/unit/deferred.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/deferred.js b/src/deferred.js index 02f92b26..5cc5fb5b 100644 --- a/src/deferred.js +++ b/src/deferred.js @@ -119,7 +119,7 @@ jQuery.extend({ if ( jQuery.isFunction( fn ) ) { deferred[ handler ](function() { returned = fn.apply( this, arguments ); - if ( jQuery.isFunction( returned.promise ) ) { + if ( returned && jQuery.isFunction( returned.promise ) ) { returned.promise().then( newDefer.resolve, newDefer.reject ); } else { newDefer[ action ]( returned ); diff --git a/test/unit/deferred.js b/test/unit/deferred.js index c71fbdbe..89c9c612 100644 --- a/test/unit/deferred.js +++ b/test/unit/deferred.js @@ -145,7 +145,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { test( "jQuery.Deferred.pipe - filtering (done)", function() { - expect(3); + expect(4); var defer = jQuery.Deferred(), piped = defer.pipe(function( a, b ) { @@ -173,11 +173,15 @@ test( "jQuery.Deferred.pipe - filtering (done)", function() { jQuery.Deferred().reject().pipe(function() { ok( false, "pipe should not be called on reject" ); }); + + jQuery.Deferred().resolve().pipe( jQuery.noop ).done(function( value ) { + strictEqual( value, undefined, "pipe done callback can return undefined/null" ); + }); }); test( "jQuery.Deferred.pipe - filtering (fail)", function() { - expect(3); + expect(4); var defer = jQuery.Deferred(), piped = defer.pipe( null, function( a, b ) { @@ -205,6 +209,10 @@ test( "jQuery.Deferred.pipe - filtering (fail)", function() { jQuery.Deferred().resolve().pipe( null, function() { ok( false, "pipe should not be called on resolve" ); } ); + + jQuery.Deferred().reject().pipe( null, jQuery.noop ).fail(function( value ) { + strictEqual( value, undefined, "pipe fail callback can return undefined/null" ); + }); }); test( "jQuery.Deferred.pipe - deferred (done)", function() {