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 16472 - Consider DOMString? for HTMLInputElement:value IDL attribute
Summary: Consider DOMString? for HTMLInputElement:value IDL attribute
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Silvia Pfeiffer
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-21 20:45 UTC by Travis Leithead [MSFT]
Modified: 2012-10-14 12:29 UTC (History)
9 users (show)

See Also:


Attachments
Test case for null assignment on common DOMString reflecting values (4.69 KB, text/html)
2012-03-21 20:45 UTC, Travis Leithead [MSFT]
Details

Description Travis Leithead [MSFT] 2012-03-21 20:45:38 UTC
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.
Comment 1 Boris Zbarsky 2012-03-23 14:08:54 UTC
I'd much prefer the TreatNullAs approach to the prose approach, for what it's worth, as an implementor.
Comment 2 Simon Pieters 2012-03-23 14:15:05 UTC
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.
Comment 3 Simon Pieters 2012-06-01 11:43:04 UTC
(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
Comment 4 contributor 2012-07-18 06:58:45 UTC
This bug was cloned to create bug 17834 as part of operation convergence.
Comment 5 Silvia Pfeiffer 2012-10-14 12:29:50 UTC
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