Bug Tracker

Opened 8 years ago

Closed 7 years ago

#8429 closed bug (wontfix)

:empty discrepancy between IE and Chrome

Reported by: monkeyboyluke@… 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.

Change History (6)

comment:1 Changed 8 years ago by Rick Waldron

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.

comment:2 Changed 8 years ago by 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

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

comment:3 in reply to:  2 ; Changed 8 years ago by monkeyboyluke@…

Replying to 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/

comment:4 Changed 8 years ago by dmethvin

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.

comment:5 in reply to:  3 Changed 8 years ago by dgalvez@…

Replying to monkeyboyluke@…:

Replying to 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.

comment:6 Changed 7 years ago by timmywil

Priority: highlow
Resolution: wontfix
Status: openclosed

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

Note: See TracTickets for help on using tickets.