mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
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:
commit
310ee3ef85
2 changed files with 7 additions and 2 deletions
|
@ -1508,6 +1508,11 @@ impl Element {
|
||||||
.unwrap_or_else(|_| USVString(value.to_owned()))
|
.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 {
|
pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString {
|
||||||
match self.get_attribute(&ns!(), local_name) {
|
match self.get_attribute(&ns!(), local_name) {
|
||||||
Some(x) => x.Value(),
|
Some(x) => x.Value(),
|
||||||
|
|
|
@ -112,8 +112,8 @@ macro_rules! make_url_setter(
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::element::Element;
|
use crate::dom::element::Element;
|
||||||
let element = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
element.set_string_attribute(&local_name!($htmlname),
|
element.set_url_attribute(&local_name!($htmlname),
|
||||||
DOMString::from(value.0));
|
value);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue