From 396dd2127330a7ed742d1e9092af54b668c46e85 Mon Sep 17 00:00:00 2001 From: John Resig Date: Mon, 23 Aug 2010 12:38:55 -0700 Subject: [PATCH] Fixing getting/setting classes and makeArray(RegExp) for Blackberry 4.7. Fixes #6930, #6931. --- src/attributes.js | 3 ++- src/core.js | 3 ++- test/unit/core.js | 43 ++++++++++++++++++++++++++++--------------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index aca9e055d..1278ff84b 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -278,7 +278,8 @@ jQuery.extend({ } // If applicable, access the attribute via the DOM 0 way - if ( name in elem && notxml && !special ) { + // 'in' checks fail in Blackberry 4.7 #6931 + if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) { if ( set ) { // We can't allow the type property to be changed (since it causes problems in IE) if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { diff --git a/src/core.js b/src/core.js index e1a3a6df2..50ad55d94 100644 --- a/src/core.js +++ b/src/core.js @@ -594,7 +594,8 @@ jQuery.extend({ // The window, strings (and functions) also have 'length' // The extra typeof function check is to prevent crashes // in Safari 2 (See: #3039) - if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) { + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || typeof array === "function" || typeof array.setInterval !== "undefined" ) { push.call( ret, array ); } else { jQuery.merge( ret, array ); diff --git a/test/unit/core.js b/test/unit/core.js index 5d6b9fe68..3960a7df9 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -258,21 +258,28 @@ test("isPlainObject", function() { // Window ok(!jQuery.isPlainObject(window), "window"); - - var iframe = document.createElement("iframe"); - document.body.appendChild(iframe); - window.iframeDone = function(otherObject){ - // Objects from other windows should be matched - ok(jQuery.isPlainObject(new otherObject), "new otherObject"); + try { + var iframe = document.createElement("iframe"); + document.body.appendChild(iframe); + + window.iframeDone = function(otherObject){ + // Objects from other windows should be matched + ok(jQuery.isPlainObject(new otherObject), "new otherObject"); + document.body.removeChild( iframe ); + start(); + }; + + var doc = iframe.contentDocument || iframe.contentWindow.document; + doc.open(); + doc.write(""); + doc.close(); + } catch(e) { document.body.removeChild( iframe ); + + ok(true, "new otherObject - iframes not supported"); start(); - }; - - var doc = iframe.contentDocument || iframe.contentWindow.document; - doc.open(); - doc.write(""); - doc.close(); + } }); test("isFunction", function() { @@ -374,9 +381,15 @@ test("isXMLDoc - HTML", function() { try { var body = jQuery(iframe).contents()[0]; - ok( !jQuery.isXMLDoc( body ), "Iframe body element" ); - } catch(e){ - ok( false, "Iframe body element exception" ); + + try { + ok( !jQuery.isXMLDoc( body ), "Iframe body element" ); + } catch(e) { + ok( false, "Iframe body element exception" ); + } + + } catch(e) { + ok( true, "Iframe body element - iframe not working correctly" ); } document.body.removeChild( iframe ); -- 2.39.5