Skip to main content

Bug Tracker

Side navigation

#8429 closed bug (wontfix)

Opened March 03, 2011 05:40AM UTC

Closed June 19, 2012 05:59AM UTC

:empty discrepancy between IE and Chrome

Reported by: monkeyboyluke@yahoo.com Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:
Description

I tested the following code on:

Google Chrome 6.0.472.63

and

Internet Explorer 8.0.6001.18702

http://jsfiddle.net/dPDWK/

The :empty selector gives different results depending on the browser. In IE an object with whitespace is treated as empty and in Chrome an object with whitespace is not treated as empty. I think the internet explorer version is a more helpful implementation of :empty.

Attachments (0)
Change History (6)

Changed March 07, 2011 01:58AM UTC by rwaldron comment:1

component: unfiledselector
priority: undecidedhigh
status: newopen

This is not just in Chrome. Tested in Chrome, FF, Opera

http://jsfiddle.net/rwaldron/6y964/

One or the other behaviour should be in parity for all.

Changed July 12, 2011 05:11PM UTC by john comment:2

Unfortunately we really need to defer to the spec here (which is that whitespace makes something not empty):

http://www.w3.org/TR/css3-selectors/#empty-pseudo

Thus we would need to feature detect what's going on in IE and have it fall back to the old engine.

Changed July 12, 2011 10:22PM UTC by monkeyboyluke@yahoo.com comment:3

Replying to [comment:2 john]:

Unfortunately we really need to defer to the spec here (which is that whitespace makes something not empty): http://www.w3.org/TR/css3-selectors/#empty-pseudo

Well. JQuery docs actually define :empty as an element without children. I think what you are saying about CSS standards should mean that a text node counts as a child even if it is just whitespace. Which got me to thinking. Must be the whitespace isn't coming back as a child element. Sure enough, the :text object shows the same bug. http://jsfiddle.net/c5FwK/

http://jsfiddle.net/c5FwK/

Changed August 15, 2011 10:38PM UTC by dmethvin comment:4

I know everyone may like the idea of jQuery hiding this difference, but my feeling on this is wontfix due to the high cost of doing the checking. We'd need to look through all the children and see if they consist of only whitespace text nodes.

In most cases it would be possible to fix this by ensuring that there is no whitespace in empty markup.

Changed September 25, 2011 04:57PM UTC by dgalvez@editablething.com comment:5

Replying to [comment:3 monkeyboyluke@…]:

Replying to [comment:2 john]: > Unfortunately we really need to defer to the spec here (which is that whitespace makes something not empty): > http://www.w3.org/TR/css3-selectors/#empty-pseudo Well. JQuery docs actually define :empty as an element without children. I think what you are saying about CSS standards should mean that a text node counts as a child even if it is just whitespace. Which got me to thinking. Must be the whitespace isn't coming back as a child element. Sure enough, the :text object shows the same bug. http://jsfiddle.net/c5FwK/ http://jsfiddle.net/c5FwK/

Indeed, in ie8 the span innerHTML property is empty and childNodes is reporting there are no children nodes. So there is no way to distinguish between "<span></span>" and "<span> </span>" in this browser.

Changed June 19, 2012 05:59AM UTC by timmywil comment:6

priority: highlow
resolution: → wontfix
status: openclosed

It sounds like wontfix is the consensus here, and I agree.