aboutsummaryrefslogtreecommitdiffstats
path: root/src/effects.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2011-04-17 11:07:42 -0700
committerJohn Resig <jeresig@gmail.com>2011-04-17 11:07:42 -0700
commit21c0be8496127df3f0ad652e582133148430cc41 (patch)
tree1df5192669f32fe356bb6b1d61e3c4ae36544ac0 /src/effects.js
parent728a70c036dfcdc0c45c5c60c08aeade786ce195 (diff)
downloadjquery-21c0be8496127df3f0ad652e582133148430cc41.tar.gz
jquery-21c0be8496127df3f0ad652e582133148430cc41.zip
Make sure that hide or show don't fail when operating on non-Element nodes. Fixes #6135.
Diffstat (limited to 'src/effects.js')
-rw-r--r--src/effects.js38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/effects.js b/src/effects.js
index 2c7b44cb0..162de1266 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -28,19 +28,22 @@ jQuery.fn.extend({
} else {
for ( var i = 0, j = this.length; i < j; i++ ) {
elem = this[i];
- display = elem.style.display;
- // Reset the inline display of this element to learn if it is
- // being hidden by cascaded rules or not
- if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
- display = elem.style.display = "";
- }
+ if ( elem.style ) {
+ display = elem.style.display;
+
+ // Reset the inline display of this element to learn if it is
+ // being hidden by cascaded rules or not
+ if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
+ display = elem.style.display = "";
+ }
- // Set elements which have been overridden with display: none
- // in a stylesheet to whatever the default browser style is
- // for such an element
- if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
- jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
+ // Set elements which have been overridden with display: none
+ // in a stylesheet to whatever the default browser style is
+ // for such an element
+ if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
+ jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
+ }
}
}
@@ -48,10 +51,13 @@ jQuery.fn.extend({
// to avoid the constant reflow
for ( i = 0; i < j; i++ ) {
elem = this[i];
- display = elem.style.display;
- if ( display === "" || display === "none" ) {
- elem.style.display = jQuery._data(elem, "olddisplay") || "";
+ if ( elem.style ) {
+ display = elem.style.display;
+
+ if ( display === "" || display === "none" ) {
+ elem.style.display = jQuery._data(elem, "olddisplay") || "";
+ }
}
}
@@ -75,7 +81,9 @@ jQuery.fn.extend({
// Set the display of the elements in a second loop
// to avoid the constant reflow
for ( i = 0; i < j; i++ ) {
- this[i].style.display = "none";
+ if ( this[i].style ) {
+ this[i].style.display = "none";
+ }
}
return this;