This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27446 - Setting the checked IDL attr should affect the content attr
Summary: Setting the checked IDL attr should affect the content attr
Status: RESOLVED INVALID
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-26 17:15 UTC by Manish Goregaokar
Modified: 2015-09-01 07:39 UTC (History)
4 users (show)

See Also:


Attachments
test.html (185 bytes, text/plain)
2014-11-27 06:33 UTC, Manish Goregaokar
Details

Description Manish Goregaokar 2014-11-26 17:15:01 UTC
https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-fe-checked
https://html.spec.whatwg.org/multipage/forms.html#attr-input-checked

Currently, setting the `checked` content attr for an input element sets the IDL attribute too (via proxy of the "checkedness"), however the reverse is not true -- so we can pull the rug under the checked content attr and make it not reflect the true state of the checkbox.

Additionally, changing the checked state via a click does not affect the content attribute, only the checkedness[1], giving a similar effect.

Modern browsers, however, have the `checked` content attr reflecting the actual checked state -- should the spec be updated to do this? A simple note that "setting the checkedness should ensure that the corresponding content attr is updated" should do.


 [1]: https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-%28type=checkbox%29:pre-click-activation
Comment 1 Ian 'Hixie' Hickson 2014-11-26 19:19:24 UTC
Do you have a test showing where browsers differ from the spec?
Comment 2 Manish Goregaokar 2014-11-27 06:33:26 UTC
Created attachment 1552 [details]
test.html

Hm, I'm getting even stranger behavior.

I take an initially checked checkbox, and then click it followed by removing the content attr.

Chrome does this:

Initially, content attr is: true
Initially, IDL attr is: true
After clicking, content attr is: true
After clicking, IDL attr is: false
After removing content attr, IDL attr is: false

Firefox does this:
Initially, content attr is: true
Initially, IDL attr is: false
After clicking, content attr is: true
After clicking, IDL attr is: true
After removing content attr, IDL attr is: true

O.o
Comment 3 Ian 'Hixie' Hickson 2014-12-01 05:37:13 UTC
(Unless I'm missing something you didn't upload the test, you uploaded the results. Can you upload the test or provide a link to it?)

By "content attr is: true" I assume you mean "content attr is present". By "IDL attr" I assume you mean the "checked" IDL attribute, not the "defaultChecked" IDL attribute. (Note that the checked="" content attribute is reflected by the .defaultChecked IDL attribute, not the .checked IDL attribute. The latter merely describes the current state of the element. The current state is not reflected into the DOM.)

Assuming so, then Firefox is definitely wrong. If the checkbox appears checked, then the IDL "checked" attribute should be true. I am surprised by what you describe, though, I cannot reproduce it:
   http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3321

What you describe as Chrome's behaviour is, from what I can gather of the test you're describing, correct according to the spec.
Comment 4 Anne 2015-09-01 07:39:45 UTC
Manish, the content checked attribute is reflected by defaultChecked. The checked IDL attribute is about the current state.