diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-05-06 14:22:45 -0500 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-05-06 14:22:45 -0500 |
commit | 19744984da58feeeab64a98839ec2936fb8fb5a0 (patch) | |
tree | d7951916e1f895dea638758445f54cffa136b4bf /components/script/dom/attr.rs | |
parent | ccf1e6b9a701cf4ff010fa1f1b4ba9d656d962af (diff) | |
parent | fedad2af1f7c8b36f4ed76e79ebde5516721b11f (diff) | |
download | servo-19744984da58feeeab64a98839ec2936fb8fb5a0.tar.gz servo-19744984da58feeeab64a98839ec2936fb8fb5a0.zip |
Auto merge of #5923 - nox:limited-unsigned-long, r=jdm
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5923)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r-- | components/script/dom/attr.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 88384aabe5f..3e3979dbaef 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -54,8 +54,25 @@ impl AttrValue { AttrValue::TokenList(tokens, atoms) } + // https://html.spec.whatwg.org/multipage/#reflecting-content-attributes-in-idl-attributes:idl-unsigned-long pub fn from_u32(string: DOMString, default: u32) -> AttrValue { let result = parse_unsigned_integer(string.chars()).unwrap_or(default); + let result = if result > 2147483647 { + default + } else { + result + }; + AttrValue::UInt(string, result) + } + + // https://html.spec.whatwg.org/multipage/#limited-to-only-non-negative-numbers-greater-than-zero + pub fn from_limited_u32(string: DOMString, default: u32) -> AttrValue { + let result = parse_unsigned_integer(string.chars()).unwrap_or(default); + let result = if result == 0 || result > 2147483647 { + default + } else { + result + }; AttrValue::UInt(string, result) } |