diff options
Diffstat (limited to 'components/script/dom')
-rwxr-xr-x | components/script/dom/htmlbuttonelement.rs | 2 | ||||
-rwxr-xr-x | components/script/dom/htmlformelement.rs | 2 | ||||
-rwxr-xr-x | components/script/dom/htmlinputelement.rs | 2 | ||||
-rw-r--r-- | components/script/dom/macros.rs | 38 |
4 files changed, 14 insertions, 30 deletions
diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index aea8bf5c585..d72fb752194 100755 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -93,7 +93,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement { make_setter!(SetType, "type"); // https://html.spec.whatwg.org/multipage/#dom-fs-formaction - make_url_or_base_getter!(FormAction, "formaction"); + make_form_action_getter!(FormAction, "formaction"); // https://html.spec.whatwg.org/multipage/#dom-fs-formaction make_setter!(SetFormAction, "formaction"); diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index a61b7bf3e51..b58194bed62 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -100,7 +100,7 @@ impl HTMLFormElementMethods for HTMLFormElement { make_setter!(SetAcceptCharset, "accept-charset"); // https://html.spec.whatwg.org/multipage/#dom-fs-action - make_string_or_document_url_getter!(Action, "action"); + make_form_action_getter!(Action, "action"); // https://html.spec.whatwg.org/multipage/#dom-fs-action make_setter!(SetAction, "action"); diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 3a16551d4c3..7260ec7bc50 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -452,7 +452,7 @@ impl HTMLInputElementMethods for HTMLInputElement { make_setter!(SetPlaceholder, "placeholder"); // https://html.spec.whatwg.org/multipage/#dom-input-formaction - make_url_or_base_getter!(FormAction, "formaction"); + make_form_action_getter!(FormAction, "formaction"); // https://html.spec.whatwg.org/multipage/#dom-input-formaction make_setter!(SetFormAction, "formaction"); 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(), } } ); |