mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add type IDL attr for submittable elements
This commit is contained in:
parent
e048f3f940
commit
8a2c746e61
10 changed files with 66 additions and 9 deletions
|
@ -24,6 +24,7 @@ use dom::virtualmethods::VirtualMethods;
|
|||
use servo_util::str::{DOMString, parse_unsigned_integer};
|
||||
use string_cache::Atom;
|
||||
|
||||
use std::ascii::OwnedStrAsciiExt;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::mem;
|
||||
|
||||
|
@ -131,6 +132,26 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> {
|
|||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-size
|
||||
make_uint_setter!(SetSize, "size")
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-type
|
||||
fn Type(self) -> DOMString {
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(self);
|
||||
let ty = elem.get_string_attribute("type").into_ascii_lower();
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#attr-input-type
|
||||
match ty.as_slice() {
|
||||
"hidden" | "search" | "tel" |
|
||||
"url" | "email" | "password" |
|
||||
"datetime" | "date" | "month" |
|
||||
"week" | "time" | "datetime-local" |
|
||||
"number" | "range" | "color" |
|
||||
"checkbox" | "radio" | "file" |
|
||||
"submit" | "image" | "reset" | "button" => ty,
|
||||
_ => "text".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-type
|
||||
make_setter!(SetType, "type")
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-value
|
||||
make_getter!(Value)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue