diff options
Diffstat (limited to 'components/script/dom/macros.rs')
-rw-r--r-- | components/script/dom/macros.rs | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 68aa8351bb9..89d545d80f2 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -106,38 +106,22 @@ macro_rules! make_url_getter( ); #[macro_export] -macro_rules! make_url_or_base_getter( +macro_rules! make_form_action_getter( ( $attr:ident, $htmlname:tt ) => ( fn $attr(&self) -> DOMString { use dom::bindings::inheritance::Castable; use dom::element::Element; let element = self.upcast::<Element>(); - let url = element.get_url_attribute(&local_name!($htmlname)); - if url.is_empty() { - let window = window_from_node(self); - DOMString::from(window.get_url().into_string()) - } else { - url - } - } - ); -); - -#[macro_export] -macro_rules! make_string_or_document_url_getter( - ( $attr:ident, $htmlname:tt ) => ( - fn $attr(&self) -> DOMString { - use dom::bindings::inheritance::Castable; - use dom::element::Element; - use dom::node::document_from_node; - let element = self.upcast::<Element>(); - let val = element.get_string_attribute(&local_name!($htmlname)); - - if val.is_empty() { - let doc = document_from_node(self); - DOMString::from(doc.url().into_string()) - } else { - val + let doc = ::dom::node::document_from_node(self); + let attr = element.get_attribute(&ns!(), &local_name!($htmlname)); + let value = attr.as_ref().map(|attr| attr.value()); + let value = match value { + Some(ref value) if !value.is_empty() => &***value, + _ => return doc.url().into_string().into(), + }; + match doc.base_url().join(value) { + Ok(parsed) => parsed.into_string().into(), + Err(_) => value.to_owned().into(), } } ); |