[whatwg] number-related feedback

Cameron McCormack cam at mcc.id.au
Wed Dec 31 16:36:08 PST 2008


Hi Ian, Jonas.

Ian Hickson:
> The UA would set a limit on the value it accepts for maxlength="", and 
> then cap the result at that, preventing someone from entering more than 
> 4GB (or 2GB, or 4TB, or whatever limit the UA has). Does that answer your 
> question? In practice I would expect other limitations to come into play 
> long before a test for this limit could be triggered.

I don’t think it does answer the question, since you need to know what
happens if you do:

  e.setAttribute('maxlength', '5000000000');
  alert(e.maxlength)

The text currently in the spec isn’t clear:

  If a reflecting DOM attribute is an unsigned integer type (unsigned
  long) then, on getting, the content attribute must be parsed according
  to rules for parsing non-negative integers, and if that is successful,
  the resulting value must be returned. If, on the other hand, it fails,
  or if the attribute is absent, the default value must be returned
  instead, or 0 if there is no default value.

The “rules for parsing non-negative integers” algorithm can return any
non-negative integer.  Web IDL doesn’t define what to do if a spec
defines an operation to return a value that is not a member of its
return type.  I’d classify that as a bug in the description of
reflecting DOM attributes.

I suggest to reword that paragraph to something like the following:

  If a reflecting DOM attribute is an unsigned integer type (unsigned
  long) then, on getting, the content attribute must be parsed according
  to rules for parsing non-negative integers, and if that successfully
  returns a value in the range of an unsigned long, that resulting value
  must be returned. If, on the other hand, it fails, 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.

Similar wording would be needed for other paragraphs in this section.

-- 
Cameron McCormack ≝ http://mcc.id.au/



More information about the whatwg mailing list