Closed
Bug 1314026
Opened 8 years ago
Closed 8 years ago
colspan and rowspan setters should not stealth-cast unsigned ints to ints
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla52
Tracking | Status | |
---|---|---|
firefox52 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: bzbarsky)
Details
Attachments
(1 file)
The call to SetHTMLIntAttr casts to int. So if you do: td.colSpan = 2147483648; you get "-2147483648" as the attribute value. This is quite odd.
Assignee | ||
Comment 1•8 years ago
|
||
Tests will appear at https://github.com/w3c/web-platform-tests/pull/4115 in a bit
Attachment #8805954 -
Flags: review?(bkelly)
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment 2•8 years ago
|
||
Comment on attachment 8805954 [details] [diff] [review] Add a SetHTMLUIntAttr function that does the right thing with setters for unsigned long IDL attributes that reflect a content attribute Review of attachment 8805954 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/html/nsGenericHTMLElement.h @@ +979,5 @@ > > SetHTMLAttr(aName, value, aError); > } > > + void SetHTMLUIntAttr(nsIAtom* aName, uint32_t aValue, mozilla::ErrorResult& aError) This is fine, but we could remove some duplication if we use a template: template <typename T> void SetHTMLIntAttr(nsIAtom* aName, T aValue, mozilla::ErrorResult& aError) { nsAutoString value; value.AppendInt(aValue); SetHTMLAttr(aName, value, aError); }
Attachment #8805954 -
Flags: review?(bkelly) → review+
Assignee | ||
Comment 3•8 years ago
|
||
That's true. I wasn't quite sure whether it was better to do that or to make the caller's desire for int/uint be explicit....
Assignee | ||
Comment 4•8 years ago
|
||
Thoughts on the implicit vs explicit thing?
Flags: needinfo?(bkelly)
Comment 5•8 years ago
|
||
(In reply to Boris Zbarsky [:bz] (still a bit busy) from comment #4) > Thoughts on the implicit vs explicit thing? I don't feel super strong either way. I think since we have AppendInt() that works for both signed and unsigned in our string API that there is precedent for not including the full type in the method name.
Flags: needinfo?(bkelly)
Assignee | ||
Comment 6•8 years ago
|
||
OK. Thought about it some more, and calling the int overload with an unsigned value that doesn't fit in int makes no sense, and calling the uint overload with a negative-valued int would also be nonsense. So I went ahead with the template approach.
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/933e7a735a80 Add a version of SetHTMLIntAttr that does the right thing with an unsigned argument, for use from setters for unsigned long IDL attributes that reflect a content attribute. r=bkelly
Comment 8•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/933e7a735a80
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in
before you can comment on or make changes to this bug.
Description
•