mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Set url attribute
This commit is contained in:
parent
2a7862540c
commit
37aa21d8db
2 changed files with 12 additions and 7 deletions
|
@ -1501,11 +1501,16 @@ impl Element {
|
||||||
};
|
};
|
||||||
let value = &**attr.value();
|
let value = &**attr.value();
|
||||||
// XXXManishearth this doesn't handle `javascript:` urls properly
|
// XXXManishearth this doesn't handle `javascript:` urls properly
|
||||||
document_from_node(self)
|
USVString(value.to_owned())
|
||||||
.base_url()
|
}
|
||||||
.join(value)
|
|
||||||
.map(|parsed| USVString(parsed.into_string()))
|
pub fn set_url_attribute(&self, local_name: &LocalName, value: USVString) {
|
||||||
.unwrap_or_else(|_| USVString(value.to_owned()))
|
assert!(*local_name == local_name.to_ascii_lowercase());
|
||||||
|
let base_url = document_from_node(self).base_url();
|
||||||
|
self.set_attribute(
|
||||||
|
local_name,
|
||||||
|
AttrValue::from_resolved_url(&base_url, value.to_string()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString {
|
pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString {
|
||||||
|
|
|
@ -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