mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
add HTMLOptionElement form attribute support
This commit is contained in:
parent
7ebdf98d28
commit
f5dbf41841
2 changed files with 17 additions and 1 deletions
|
@ -6,6 +6,7 @@ use dom::attr::Attr;
|
||||||
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
|
||||||
|
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementBinding::HTMLSelectElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
|
@ -14,6 +15,8 @@ use dom::characterdata::CharacterData;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::{AttributeMutation, Element};
|
use dom::element::{AttributeMutation, Element};
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
|
use dom::htmlformelement::HTMLFormElement;
|
||||||
|
use dom::htmloptgroupelement::HTMLOptGroupElement;
|
||||||
use dom::htmlscriptelement::HTMLScriptElement;
|
use dom::htmlscriptelement::HTMLScriptElement;
|
||||||
use dom::htmlselectelement::HTMLSelectElement;
|
use dom::htmlselectelement::HTMLSelectElement;
|
||||||
use dom::node::{Node, UnbindContext};
|
use dom::node::{Node, UnbindContext};
|
||||||
|
@ -110,6 +113,19 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
|
||||||
self.upcast::<Node>().SetTextContent(Some(value))
|
self.upcast::<Node>().SetTextContent(Some(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-option-form
|
||||||
|
fn GetForm(&self) -> Option<Root<HTMLFormElement>> {
|
||||||
|
let parent = self.upcast::<Node>().GetParentNode().and_then(|p|
|
||||||
|
if p.is::<HTMLOptGroupElement>() {
|
||||||
|
p.upcast::<Node>().GetParentNode()
|
||||||
|
} else {
|
||||||
|
Some(p)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
parent.and_then(|p| p.downcast::<HTMLSelectElement>().and_then(|s| s.GetForm()))
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#attr-option-value
|
// https://html.spec.whatwg.org/multipage/#attr-option-value
|
||||||
fn Value(&self) -> DOMString {
|
fn Value(&self) -> DOMString {
|
||||||
let element = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
[Exposed=(Window,Worker)]
|
[Exposed=(Window,Worker)]
|
||||||
interface HTMLOptionElement : HTMLElement {
|
interface HTMLOptionElement : HTMLElement {
|
||||||
attribute boolean disabled;
|
attribute boolean disabled;
|
||||||
//readonly attribute HTMLFormElement? form;
|
readonly attribute HTMLFormElement? form;
|
||||||
attribute DOMString label;
|
attribute DOMString label;
|
||||||
attribute boolean defaultSelected;
|
attribute boolean defaultSelected;
|
||||||
attribute boolean selected;
|
attribute boolean selected;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue