This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Created attachment 1105 [details] Test case for null assignment on common DOMString reflecting values I just ran into a compatibility issue in IE10 (on site 58.com), where the site ends up assigning the null literal value to the input element's value IDL attribute. As far as I can tell, IE10 is currently doing the "correct" behavior according to the current definition of the value IDL attribute and WebIDL conversion logic: <blockquote> The value IDL attribute allows scripts to manipulate the value of an input element. The attribute is in one of the following modes, which define its behavior: * value On getting, it must return the current value of the element. On setting, it must set the element's value to the new value, set the element's dirty value flag to true, invoke the value sanitization algorithm, if the element's type attribute's current state defines one, and then, if the element has a text entry cursor position, should move the text entry cursor position to the end of the text field, unselecting any selected text and resetting the selection direction to none. </blockquote> (From HTML5 4.10.7.4) On the site, the input is type=text, which means the value attribute is in the "value" mode. The value sanitization algorithm for that state just trims line breaks from the value. Since, the HTMLInputElement interface WebIDL is defined as following: interface HTMLInputElement : HTMLElement { [snip] attribute DOMString value; [snip] }; Then the conversion of a null literal value should result in the string "null" being assigned per 4.2.16. of WebIDL. IE10 places the string "null" in the value of the input type=text field. Unfortunately, the site does not want that to happen, instead, they expect the value to be the empty string so that the placeholder text is put in the input box instead. At a minimum, I'd recommending changing the value IDL attribute to either: [TreatNullAs=EmptyString] attribute DOMString value; or attribute DOMString? value; (and providing a description of how this IDL attribute handles null (e.g., by setting the value to the empty string) ... to ensure good interop and avoid site issues like the above-specified one. I did some testing of other reflecting DOM attributes (on DIV and on HTMLInputElement -- see attached) under this same scenario, and IE is pretty consistent about assigning the string "null" in all these cases (going as far back as IE8--likely back to IE6, but I didn't test that). While IE appears to have the correct behavior in these scenarios per the spec(and this behavior has not changed in some time), I wonder if this is the best behavior. According to the attached test, the other browsers aren't perfectly aligned on an alternate behavior, but none of them match IE at the moment. Interestingly, WebKit based browsers tend to clear the content attribute when null is assigned, whereas Firefox/Opera assign the empty string to the content attribute. This _does_ make a difference with respect to some attributes like "title" where the presence of the attribute (vs. an empty string value) make a difference.
I'd much prefer the TreatNullAs approach to the prose approach, for what it's worth, as an implementor.
Since .value doesn't reflect the content attribute, I think it makes little sense to remove the content attribute when setting to null. Setting concept-value to the empty string seems OK.
(In reply to comment #2) > Since .value doesn't reflect the content attribute, I think it makes little > sense to remove the content attribute when setting to null. Setting > concept-value to the empty string seems OK. However, removing the content attribute when setting .defaultValue and other reflecting IDL attributes seems reasonable; https://www.w3.org/Bugs/Public/show_bug.cgi?id=17283
This bug was cloned to create bug 17834 as part of operation convergence.
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the Editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the Tracker Issue; or you may create a Tracker Issue yourself, if you are able to do so. For more details, see this document: http://dev.w3.org/html5/decision-policy/decision-policy-v2.html Status: Accepted Change Description: https://github.com/w3c/html/commit/827f02df82e56c91ec99f345f5dcbb5fcd088347 Rationale: accepted WHATWG change