define( [
"../core",
+ "../var/document",
"./support",
"../selector",
"../css"
-], function( jQuery, support ) {
+], function( jQuery, document, support ) {
function getDisplay( elem ) {
return elem.style && elem.style.display || jQuery.css( elem, "display" );
}
function filterHidden( elem ) {
+
+ // Disconnected elements are considered hidden
+ if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
+ return true;
+ }
while ( elem && elem.nodeType === 1 ) {
if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
return true;
} );
QUnit.test( ":visible/:hidden selectors", function( assert ) {
- assert.expect( 17 );
+ assert.expect( 19 );
var $div, $table, $a;
$a = jQuery( "<a href='#'><h1>Header</h1></a>" ).appendTo( "#qunit-fixture" );
assert.ok( $a.is( ":visible" ), "Anchor tag with flow content is visible (gh-2227)" );
+
+ assert.ok( !jQuery( "<div>Test</div>" ).is( ":visible" ), "Disconnected element is not visible" );
+ assert.ok( !jQuery( "<div><div>Test</div></div>" ).find("div").is( ":visible" ), "Disconnected element child is not visible" );
} );
QUnit.test( "Keep the last style if the new one isn't recognized by the browser (#14836)", function( assert ) {