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

Implement HTMLSelectElement.{multiple, name, size} (fixes #6017) #6018

Merged
merged 1 commit into from May 12, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Implement HTMLSelectElement.{multiple, name, size} (fixes #6017)

  • Loading branch information
Jinwoo-Song committed May 12, 2015
commit 656a8ee3c8ebfe4b73d7488b230823363a2f2d08
@@ -2,17 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use dom::attr::Attr;
use dom::attr::AttrHelpers;
use dom::attr::{Attr, AttrHelpers, AttrValue};
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLSelectElementDerived, HTMLFieldSetElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLSelectElementDerived, HTMLFieldSetElementDerived};
use dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement;
use dom::bindings::js::{JSRef, Rootable, Temporary};
use dom::document::Document;
use dom::element::{AttributeHandlers, Element};
use dom::element::AttributeHandlers;
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::element::ElementTypeId;
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
@@ -36,6 +35,8 @@ impl HTMLSelectElementDerived for EventTarget {
}
}

static DEFAULT_SELECT_SIZE: u32 = 0;

impl HTMLSelectElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLSelectElement {
HTMLSelectElement {
@@ -66,10 +67,27 @@ impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> {
// https://www.whatwg.org/html/#dom-fe-disabled
make_bool_setter!(SetDisabled, "disabled");

// https://html.spec.whatwg.org/multipage/#dom-select-multiple
make_bool_getter!(Multiple);

// https://html.spec.whatwg.org/multipage/#dom-select-multiple
make_bool_setter!(SetMultiple, "multiple");

// https://html.spec.whatwg.org/multipage/#dom-fe-name
make_getter!(Name);

// https://html.spec.whatwg.org/multipage/#dom-fe-name
make_setter!(SetName, "name");

// https://html.spec.whatwg.org/multipage/#dom-select-size
make_uint_getter!(Size, "size", DEFAULT_SELECT_SIZE);

// https://html.spec.whatwg.org/multipage/#dom-select-size
make_uint_setter!(SetSize, "size", DEFAULT_SELECT_SIZE);

// https://html.spec.whatwg.org/multipage/#dom-select-type
fn Type(self) -> DOMString {
let elem: JSRef<Element> = ElementCast::from_ref(self);
if elem.has_attribute(&atom!("multiple")) {
if self.Multiple() {
"select-multiple".to_owned()
} else {
"select-one".to_owned()
@@ -135,5 +153,12 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
node.check_disabled_attribute();
}
}

fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
match local_name {
&atom!("size") => AttrValue::from_u32(value, DEFAULT_SELECT_SIZE),
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
}
}
}

@@ -8,10 +8,10 @@ interface HTMLSelectElement : HTMLElement {
// attribute boolean autofocus;
attribute boolean disabled;
//readonly attribute HTMLFormElement? form;
// attribute boolean multiple;
// attribute DOMString name;
attribute boolean multiple;
attribute DOMString name;
// attribute boolean required;
// attribute unsigned long size;
attribute unsigned long size;

readonly attribute DOMString type;

@@ -5808,18 +5808,9 @@
[HTMLSelectElement interface: attribute form]
expected: FAIL

[HTMLSelectElement interface: attribute multiple]
expected: FAIL

[HTMLSelectElement interface: attribute name]
expected: FAIL

[HTMLSelectElement interface: attribute required]
expected: FAIL

[HTMLSelectElement interface: attribute size]
expected: FAIL

[HTMLSelectElement interface: attribute options]
expected: FAIL

@@ -5877,18 +5868,9 @@
[HTMLSelectElement interface: document.createElement("select") must inherit property "form" with the proper type (3)]
expected: FAIL

[HTMLSelectElement interface: document.createElement("select") must inherit property "multiple" with the proper type (4)]
expected: FAIL

[HTMLSelectElement interface: document.createElement("select") must inherit property "name" with the proper type (5)]
expected: FAIL

[HTMLSelectElement interface: document.createElement("select") must inherit property "required" with the proper type (6)]
expected: FAIL

[HTMLSelectElement interface: document.createElement("select") must inherit property "size" with the proper type (7)]
expected: FAIL

[HTMLSelectElement interface: document.createElement("select") must inherit property "options" with the proper type (9)]
expected: FAIL

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