Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for input element's maxlength attr #7323

Merged
merged 14 commits into from Dec 3, 2015

Resolves long-running merge conflicts

  • Loading branch information
samfoo committed Dec 3, 2015
commit 2ba1750c403e59556f667b163d5d2a90dd5f6dd6
@@ -1095,7 +1095,7 @@ impl Element {
assert!(local_name.chars().all(|ch| {
!ch.is_ascii() || ch.to_ascii_lowercase() == ch
}));
let attribute = self.get_attribute(&ns!(""), local_name);
let attribute = self.get_attribute(&ns!(), local_name);

match attribute {
Some(ref attribute) => {
@@ -28,21 +28,18 @@ macro_rules! make_bool_getter(

#[macro_export]
macro_rules! make_int_getter(
($attr:ident, $htmlname:expr, $default:expr) => (
($attr:ident, $htmlname:tt, $default:expr) => (
fn $attr(&self) -> i32 {
use dom::bindings::codegen::InheritTypes::ElementCast;
use string_cache::Atom;
let element = ElementCast::from_ref(self);
// FIXME(pcwalton): Do this at compile time, not runtime.
element.get_int_attribute(&Atom::from_slice($htmlname), $default)
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
element.get_int_attribute(&atom!($htmlname), $default)
}
);
($attr:ident, $htmlname:expr) => {

($attr:ident, $htmlname:tt) => {
make_int_getter!($attr, $htmlname, 0);
};
($attr:ident) => {
make_int_getter!($attr, to_lower!(stringify!($attr)));
}
);

#[macro_export]
@@ -23,11 +23,11 @@ fn text_input(lines: Lines, s: &str) -> TextInput<DummyClipboardContext> {
#[test]
fn test_set_content_ignores_max_length() {
let mut textinput = TextInput::new(
Lines::Single, "".to_owned(), DummyClipboardContext::new(""), Some(1)
Lines::Single, DOMString::from(""), DummyClipboardContext::new(""), Some(1)
);

textinput.set_content("mozilla rocks".to_owned());
assert_eq!(textinput.get_content(), "mozilla rocks".to_owned());
textinput.set_content(DOMString::from("mozilla rocks"));
assert_eq!(textinput.get_content(), DOMString::from("mozilla rocks"));
}

#[test]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.