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 -->
This commit is contained in:
bors-servo 2019-01-14 12:58:08 -05:00 committed by GitHub
commit 310ee3ef85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -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(),

View file

@ -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);
}
);
);