Closed Bug 495217 Opened 15 years ago Closed 15 years ago

Firefox 3.5 querySelectorAll considers hidden input elements when using the :enabled and :disabled pseudo-class

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 410472

People

(Reporter: diego.perini, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; it; rv:1.9.1b4) Gecko/20090423 Firefox/3.5b4
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; it; rv:1.9.1b4) Gecko/20090423 Firefox/3.5b4

Try this small URL snippet on "http://www.ibm.com/us/en/":

   javascript:alert(document.querySelectorAll('input:enabled').length);

In Firefox 3.5b4 the result is 6 while in Safari 4b the result is 2.

There are 4 hidden input elements and 2 text input element on that page.

Thus, FF 3.5b4 considers hidden elements part of the result set, while Safari 4b does not consider them as such. This seems in line with latest CSS Level 3 Selectors specifications while Safari seems to match the new HTML 5 selectors specifications.

Related specifications:

http://www.w3.org/TR/css3-selectors/#UIstates
http://www.w3.org/TR/html5/interactive-elements.html#selector-enabled

So having different implementations in current browsers will create confusion for authors and code written for them.

This bug have been submitted to webkit with ticket #25720, the description of the bug there is different (contrary) from this since the two browsers seems to follow different specification drafts.

https://bugs.webkit.org/show_bug.cgi?id=25720


Reproducible: Always

Steps to Reproduce:
1. Go to http://www.ibm.com/en/us
2. Type URL javascript:alert(document.querySelectorAll('input:enabled').length)
3. In FF 3.5b4 should alert 6 in Safari 4b should alert 2
Actual Results:  
Different results in FF3.5b4 and Safari 4b.

Expected Results:  
Different results expected by different draft specs CSS3/HTML5, not sure which is the one to be followed. I expected the same results in both browsers.

Not sure, though I see some advantages in implementing the HTML 5 specs.

The reason are that "hidden" fields could be "disabled" by author with the objective/intention of not submitting specific hidden fields. Then by using an ":enabled" query on a specific form we could easily serialize their submitted fields, and have "disabled" fields automatically excluded.

This is the current behavior for "disabled" form elements (not submitted).

Another plus for HTML5 specs is that we could save authors from writing code that would turn "hidden" form elements into "visible" elements by means of wrong CSS skinning rules.
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.