Skip to content
Permalink
Browse files

Call .is(:visible) on the window or document does not thrown an error…

… in IE. Fixes #10267.
  • Loading branch information...
timmywil committed Sep 15, 2011
1 parent daeb665 commit 76a84fba94e0fd32b1a6612c71ef09dee39f6666
Showing with 9 additions and 6 deletions.
  1. +1 −1 src/css.js
  2. +8 −5 test/unit/css.js
@@ -371,7 +371,7 @@ if ( jQuery.expr && jQuery.expr.filters ) {
var width = elem.offsetWidth,
height = elem.offsetHeight;

return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
};

jQuery.expr.filters.visible = function( elem ) {
@@ -1,7 +1,7 @@
module("css", { teardown: moduleTeardown });

test("css(String|Hash)", function() {
expect( 42 );
expect( 44 );

equals( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\"");

@@ -10,6 +10,8 @@ test("css(String|Hash)", function() {
ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden");
jQuery("#nothiddendiv").css({display: "block"});
ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
ok( jQuery(window).is(":visible"), "Calling is(':visible') on window does not throw an error in IE.");
ok( jQuery(document).is(":visible"), "Calling is(':visible') on document does not throw an error in IE.");

var div = jQuery( "<div>" );

@@ -36,8 +38,8 @@ test("css(String|Hash)", function() {

var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height"));
jQuery("#nothiddendiv").css({ width: -1, height: -1 });
equals( parseFloat(jQuery("#nothiddendiv").css("width")), width, "Test negative width ignored")
equals( parseFloat(jQuery("#nothiddendiv").css("height")), height, "Test negative height ignored")
equals( parseFloat(jQuery("#nothiddendiv").css("width")), width, "Test negative width ignored");
equals( parseFloat(jQuery("#nothiddendiv").css("height")), height, "Test negative height ignored");

equals( jQuery("<div style='display: none;'>").css("display"), "none", "Styles on disconnected nodes");

@@ -62,7 +64,8 @@ test("css(String|Hash)", function() {
ok(true, "Requires the same number of tests"):
ok( ~jQuery("#empty")[0].currentStyle.filter.indexOf("gradient"), "Assert setting opacity doesn't overwrite other filters of the stylesheet in IE" );

var div = jQuery("#nothiddendiv"), child = jQuery("#nothiddendivchild");
div = jQuery("#nothiddendiv");
var child = jQuery("#nothiddendivchild");

equals( parseInt(div.css("fontSize")), 16, "Verify fontSize px set." );
equals( parseInt(div.css("font-size")), 16, "Verify fontSize px set." );
@@ -227,7 +230,7 @@ test("css(String, Object)", function() {
j.css("overflow", "visible");
equals( j.css("overflow"), "visible", "Check node,textnode,comment css works" );
// opera sometimes doesn't update 'display' correctly, see #2037
jQuery("#t2037")[0].innerHTML = jQuery("#t2037")[0].innerHTML
jQuery("#t2037")[0].innerHTML = jQuery("#t2037")[0].innerHTML;
equals( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );

var div = jQuery("#nothiddendiv"),

0 comments on commit 76a84fb

Please sign in to comment.
You can’t perform that action at this time.