[Webkit-unassigned] [Bug 44886] Reflected attribute input.size wraps on negative values (Chrome), or returns them (Safari)

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri May 27 08:15:52 PDT 2011


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





--- Comment #2 from Aryeh Gregor <Simetrical+webkit at gmail.com>  2011-05-27 08:15:51 PST ---
(In reply to comment #1)
> IE9 is, as of this date, actually the only browser that seems to parse this correctly.  IE9 throws an "Invalid property value" error upon setting size = -1.  Per rule 7 of the "rules for parsing non-negative integers," this is the appropriate response.  Webkit should throw an error.  Only IE9 currently throws an error.

You mean that setAttribute() should throw?  setAttribute() never throws, if the first argument is a valid attribute name:

http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-element-setattribute

It will always set the content attribute to the given value, and getAttribute() will return exactly the string that was set (in this case, "-1").  The question is what the IDL attribute (element.size) should return.

Rule 7 of the rules for parsing non-negative integers says that it has to return an error, as you say.  This doesn't mean throw an exception.  The rules for reflection cited in comment #0 explain what to do in this case: "If, on the other hand, it fails or returns an out of range value, or if the attribute is absent, the default value must be returned instead, or 0 if there is no default value."

Whether to throw an exception when doing el.size = -1 is a separate issue.  I'm talking about parsing the content attribute here, whether it's set by setAttribute() or just <input size="-1"> (throwing in the latter case is of course impossible).


Actually, though, the spec has changed since I wrote comment #0.  See <http://www.w3.org/Bugs/Public/show_bug.cgi?id=10517>.  There's now a default value of 20:

"The size IDL attribute is limited to only non-negative numbers greater than zero and has a default value of 20."
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#attr-input-size

So the correct thing to alert per spec is now 20, not 0.  Firefox 5.0a2 now alerts 20, as does IE9.  Opera 11.10 still alerts -1.  The spec/IE/Firefox behavior makes the most sense and is probably the most compatible, so it makes sense to go with that.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list