Bug Tracker

Modify

Ticket #10406 (assigned bug)

Opened 20 months ago

Last modified 12 days ago

:hidden selector finds <br /> elements in chrome and safari (but not FF or IE)

Reported by: jen@… Owned by: timmywil
Priority: high Milestone: 1.11/2.1
Component: css Version: 1.6.4
Keywords: Cc:
Blocking: Blocked by:

Description

When using .find(':hidden') , Chrome and Safari return <br /> elements in addition to elements that you would expect. Firefox and IE (9) do not find <br /> elements.

Test case:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal">
<head>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
  <script type="text/javascript">
	$(document).ready(function() {
		var hidden_elements = $('#test').find(':hidden');
		console.log(hidden_elements);
		var len = hidden_elements.length;
		console.log(len);
	})
	</script>
</head>
<body>
	<div id="test">
		<br />
	</div>
</body>
</html>

Change History

comment:1 Changed 20 months ago by jen@…

JSfiddle test case here:  http://jsfiddle.net/DhddZ/

comment:2 Changed 20 months ago by dmethvin

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to selector

Confirmed. I thought it might be due to <br /> elements having different heights in the browser but this shows they both return 0 for height:

 http://jsfiddle.net/dmethvin/DhddZ/2/

comment:3 Changed 20 months ago by timmywil

  • Owner set to timmywil
  • Status changed from open to assigned

Sticking this here for future reference:  http://jsfiddle.net/timmywil/DhddZ/6/

This offsetHeight during the selection is 19, but the offsetHeight during the height() check is 0 because it goes through swap, which applies display: block before checking because offsetWidth was 0. So, the different codepaths make sense now, but this is a pain.

Possible solution would be to check width === 0 OR height === 0, but there may be a reason why do both.

comment:4 Changed 7 months ago by timmywil

  • Owner timmywil deleted
  • Status changed from assigned to open
  • Milestone changed from None to 1.next

comment:5 Changed 4 months ago by Timmy Willison

  • Status changed from open to closed
  • Resolution set to fixed

Treat elements as hidden when either offsetWidth OR offsetHeight is 0. Fixes #13132, #10406.

Changeset: 3015ee0b5a3cae399b53314bd9a859f61de3b94a

comment:6 Changed 4 months ago by Timmy Willison

Treat an element as hidden if either offsetWidth or offsetHeight is 0. Fixes #13132, #10406.

Changeset: 372e04e78e81cc8eb868c5fc97f271a695569aa5

comment:7 Changed 4 months ago by timmywil

comment:8 Changed 4 months ago by timmywil

  • Priority changed from low to high
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Component changed from selector to css

comment:9 Changed 4 months ago by timmywil

  • Owner set to timmywil
  • Status changed from reopened to assigned

comment:10 Changed 12 days ago by timmywil

  • Milestone changed from 1.next to 1.11/2.1

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as assigned
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.