Closed Bug 1270499 Opened 8 years ago Closed 8 years ago

Setting reflected unsigned long to out-of-range value should set to default

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: ayg, Assigned: ayg)

Details

(Whiteboard: btpp-active)

Attachments

(1 file)

data:text/html,<!DOCTYPE html>
<script>
var img = document.createElement("img");
img.width = 2147483649;
document.documentElement.textContent = img.getAttribute("width");
</script>

We output 2147483649.  Chrome outputs -2147483647.  IE 11 outputs 0.  The spec matches IE 11:

"""
On setting, first, if the new value is in the range 0 to 2147483647, then let n be the new value, otherwise let n be the default value, or 0 if there is no default value; then, n must be converted to the shortest possible string representing the number as a valid non-negative integer and that string must be used as the new content attribute value.
"""
https://html.spec.whatwg.org/multipage/infrastructure.html#reflect

This aligns nicely with getting, where out-of-range values also map to the default value, so given that there's no interop anyway, it seems sensible to converge on this.
Comment on attachment 8749179 [details] [diff] [review]
0001-Bug-1270499-Setting-reflected-unsigned-long-to-out-o.patch

>+    if (aValue > 2147483647) {

INT32_MAX, please.

r=me with that.
Attachment #8749179 - Flags: review?(bzbarsky) → review+
Whiteboard: btpp-active
https://hg.mozilla.org/mozilla-central/rev/13d2ff715514
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: