Opened 12 years ago
Closed 11 years ago
#8429 closed bug (wontfix)
:empty discrepancy between IE and Chrome
Reported by: | 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
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 12 years ago by
Component: | unfiled → selector |
---|---|
Priority: | undecided → high |
Status: | new → open |
comment:2 follow-up: 3 Changed 12 years ago by
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 follow-up: 5 Changed 12 years ago by
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/
comment:4 Changed 11 years ago by
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 Changed 11 years ago by
Replying to [email protected]…:
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/
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 11 years ago by
Priority: | high → low |
---|---|
Resolution: | → wontfix |
Status: | open → closed |
It sounds like wontfix is the consensus here, and I agree.
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.