adding macro to return string or url,

using that macro with the form action,
making the form submit process use base url,
adding tests.
This commit is contained in:
Jake Goldsborough 2016-09-20 21:16:51 -07:00
parent 1ed3521dcf
commit ce249d9384
6 changed files with 52 additions and 2 deletions

View file

@ -123,6 +123,26 @@ macro_rules! make_url_or_base_getter(
);
);
#[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(&atom!($htmlname));
if val.is_empty() {
let doc = document_from_node(self);
DOMString::from(doc.url().clone().into_string())
} else {
val
}
}
);
);
#[macro_export]
macro_rules! make_enumerated_getter(
( $attr:ident, $htmlname:tt, $default:expr, $(($choices: pat))|+) => (