diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-03-13 07:47:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-13 07:47:56 -0700 |
commit | 94c344a01422ef39c216f27bdcb3046f3ecf84ef (patch) | |
tree | e005c2f7d5470a34ba125f994b1d1f451b6f8e2d /components/script/dom/htmlimageelement.rs | |
parent | d70c1e53ae06d2dc2216c0d59709b12396378be7 (diff) | |
parent | ad1e4475afc521f5701dd73b4d742346516992ca (diff) | |
download | servo-94c344a01422ef39c216f27bdcb3046f3ecf84ef.tar.gz servo-94c344a01422ef39c216f27bdcb3046f3ecf84ef.zip |
Auto merge of #15882 - ak1t0:clean-up-htmlimageelement, r=Ms2ger
Clean up HTMLImageElement::areas
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15835 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because github issue says no tests needed.
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15882)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlimageelement.rs')
-rw-r--r-- | components/script/dom/htmlimageelement.rs | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index a0119f1ae29..321b5041553 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -413,24 +413,17 @@ impl HTMLImageElement { } pub fn areas(&self) -> Option<Vec<Root<HTMLAreaElement>>> { let elem = self.upcast::<Element>(); - let usemap_attr; - if elem.has_attribute(&LocalName::from("usemap")) { - usemap_attr = elem.get_string_attribute(&local_name!("usemap")); - } else { - return None; - } - - let (first, last) = usemap_attr.split_at(1); - - match first { - "#" => {}, - _ => return None, + let usemap_attr = match elem.get_attribute(&ns!(), &local_name!("usemap")) { + Some(attr) => attr, + None => return None, }; - match last.len() { - 0 => return None, - _ => {}, - }; + let value = usemap_attr.value(); + let (first, last) = value.split_at(1); + + if first != "#" || last.len() == 0 { + return None + } let map = self.upcast::<Node>() .following_siblings() |