[whatwg] Exposing visible string of an input field

Proposal:

I'd like to propose adding new IDL attribute to HTMLInputElement.
     readonly attribute DOMString rawValue;

It returns text content which a user actually see in an input field.
* For text, search, url, tel, password types, it's equivalent to 'value'
IDL attribute.
* For email type, it returns a string which a user is editing.  It means it
returns a string without Unicode -> Punycode conversion and without
normalization of whitespace and commas.
* For number type, it returns user-editing string. If a user typed '123+++'
into a number field, rawValue would be '123+++' as is.
* For date, datetime, datetime-local, month, time, week, the attribute
returns a string in a field. If a field is text-editable, it should return
user-editing string like email and number.  If a field has a fixed
localized date/time string chosen by a date/time picker, the attribute
should return the localized string.
* For submit, reset, button types, the attribute returns a label which the
field shows.  e.g. 'Submit' for <input type=submit> without value attribute.
* For other types, should it return an empty string?


Use case:

- We can enable text field selection APIs for email, number, and other types
- JavaScript-based screen readers can read user-visible content of input
fields.

Strings returned by rawValue attribute may be browser-dependent and
locale-dependent. However it would be useful.


-- 
TAMURA Kent
Software Engineer, Google

Received on Friday, 7 September 2012 09:50:30 UTC