Commit 76a84fba authored by timmywil's avatar timmywil

Call .is(:visible) on the window or document does not thrown an error in IE. Fixes #10267.

parent daeb6650
...@@ -371,7 +371,7 @@ if ( jQuery.expr && jQuery.expr.filters ) { ...@@ -371,7 +371,7 @@ if ( jQuery.expr && jQuery.expr.filters ) {
var width = elem.offsetWidth, var width = elem.offsetWidth,
height = elem.offsetHeight; 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 ) { jQuery.expr.filters.visible = function( elem ) {
......
module("css", { teardown: moduleTeardown }); module("css", { teardown: moduleTeardown });
test("css(String|Hash)", function() { test("css(String|Hash)", function() {
expect( 42 ); expect( 44 );
equals( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\""); equals( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\"");
...@@ -10,6 +10,8 @@ test("css(String|Hash)", function() { ...@@ -10,6 +10,8 @@ test("css(String|Hash)", function() {
ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden"); ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden");
jQuery("#nothiddendiv").css({display: "block"}); jQuery("#nothiddendiv").css({display: "block"});
ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible"); 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>" ); var div = jQuery( "<div>" );
...@@ -36,8 +38,8 @@ test("css(String|Hash)", function() { ...@@ -36,8 +38,8 @@ test("css(String|Hash)", function() {
var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height")); var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height"));
jQuery("#nothiddendiv").css({ width: -1, height: -1 }); jQuery("#nothiddendiv").css({ width: -1, height: -1 });
equals( parseFloat(jQuery("#nothiddendiv").css("width")), width, "Test negative width ignored") 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("height")), height, "Test negative height ignored");
equals( jQuery("<div style='display: none;'>").css("display"), "none", "Styles on disconnected nodes"); equals( jQuery("<div style='display: none;'>").css("display"), "none", "Styles on disconnected nodes");
...@@ -62,7 +64,8 @@ test("css(String|Hash)", function() { ...@@ -62,7 +64,8 @@ test("css(String|Hash)", function() {
ok(true, "Requires the same number of tests"): 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" ); 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("fontSize")), 16, "Verify fontSize px set." );
equals( parseInt(div.css("font-size")), 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() { ...@@ -227,7 +230,7 @@ test("css(String, Object)", function() {
j.css("overflow", "visible"); j.css("overflow", "visible");
equals( j.css("overflow"), "visible", "Check node,textnode,comment css works" ); equals( j.css("overflow"), "visible", "Check node,textnode,comment css works" );
// opera sometimes doesn't update 'display' correctly, see #2037 // 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" ); equals( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
var div = jQuery("#nothiddendiv"), var div = jQuery("#nothiddendiv"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment