diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-01-14 12:58:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-14 12:58:08 -0500 |
commit | 310ee3ef8535554d488b5d7027bbbed6b9bb8659 (patch) | |
tree | 4c5241fd226ae3c23764f0a064233ef2479654be /components/script/dom | |
parent | e1cff7b8a7f661675f2caf4c852d029510bdf21d (diff) | |
parent | 02d28e02e35d28437503033c7fd1336227a1dc4e (diff) | |
download | servo-310ee3ef8535554d488b5d7027bbbed6b9bb8659.tar.gz servo-310ee3ef8535554d488b5d7027bbbed6b9bb8659.zip |
Auto merge of #22682 - shanavas786:set-url-attr, r=nox
Implement Element::set_url_attribute
<!-- 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: -->
- [ ] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22568
<!-- Either: -->
- [ ] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- 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/22682)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/element.rs | 5 | ||||
-rw-r--r-- | components/script/dom/macros.rs | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index d461cd11527..155098247b6 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1508,6 +1508,11 @@ impl Element { .unwrap_or_else(|_| USVString(value.to_owned())) } + pub fn set_url_attribute(&self, local_name: &LocalName, value: USVString) { + assert!(*local_name == local_name.to_ascii_lowercase()); + self.set_attribute(local_name, AttrValue::String(value.to_string())); + } + pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString { match self.get_attribute(&ns!(), local_name) { Some(x) => x.Value(), diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 454f1a678f8..a566fee4fb6 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -112,8 +112,8 @@ macro_rules! make_url_setter( use crate::dom::bindings::inheritance::Castable; use crate::dom::element::Element; let element = self.upcast::<Element>(); - element.set_string_attribute(&local_name!($htmlname), - DOMString::from(value.0)); + element.set_url_attribute(&local_name!($htmlname), + value); } ); ); |