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

Implemented HTMLFormElement.relList #27255

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion components/script/dom/htmlformelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
use crate::dom::bindings::refcounted::Trusted;
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::root::{Dom, DomOnceCell, DomRoot};
use crate::dom::bindings::root::{Dom, DomOnceCell, DomRoot, MutNullableDom};
use crate::dom::bindings::str::DOMString;
use crate::dom::blob::Blob;
use crate::dom::document::Document;
use crate::dom::domtokenlist::DOMTokenList;
use crate::dom::element::{AttributeMutation, Element};
use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::eventtarget::EventTarget;
Expand Down Expand Up @@ -68,6 +69,7 @@ use servo_atoms::Atom;
use servo_rand::random;
use std::borrow::ToOwned;
use std::cell::Cell;
use style::attr::AttrValue;
use style::str::split_html_space_chars;

use crate::dom::bindings::codegen::UnionTypes::RadioNodeListOrElement;
Expand All @@ -90,6 +92,7 @@ pub struct HTMLFormElement {
controls: DomRefCell<Vec<Dom<Element>>>,
past_names_map: DomRefCell<HashMap<Atom, (Dom<Element>, Tm)>>,
firing_submission_events: Cell<bool>,
rel_list: MutNullableDom<DOMTokenList>,
}

impl HTMLFormElement {
Expand All @@ -107,6 +110,7 @@ impl HTMLFormElement {
controls: DomRefCell::new(Vec::new()),
past_names_map: DomRefCell::new(HashMap::new()),
firing_submission_events: Cell::new(false),
rel_list: Default::default(),
}
}

Expand Down Expand Up @@ -241,6 +245,9 @@ impl HTMLFormElementMethods for HTMLFormElement {
// https://html.spec.whatwg.org/multipage/#dom-fs-target
make_setter!(SetTarget, "target");

// https://html.spec.whatwg.org/multipage/#dom-a-rel
make_getter!(Rel, "rel");

// https://html.spec.whatwg.org/multipage/#the-form-element:concept-form-submit
fn Submit(&self) {
self.submit(SubmittedFrom::FromForm, FormSubmitter::FormElement(self));
Expand Down Expand Up @@ -434,6 +441,18 @@ impl HTMLFormElementMethods for HTMLFormElement {
)));
}

// https://html.spec.whatwg.org/multipage/#dom-a-rel
fn SetRel(&self, rel: DOMString) {
self.upcast::<Element>()
.set_tokenlist_attribute(&local_name!("rel"), rel);
}

// https://html.spec.whatwg.org/multipage/#dom-a-rellist
fn RelList(&self) -> DomRoot<DOMTokenList> {
self.rel_list
.or_init(|| DOMTokenList::new(self.upcast(), &local_name!("rel")))
}

// https://html.spec.whatwg.org/multipage/#the-form-element:supported-property-names
#[allow(non_snake_case)]
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
Expand Down Expand Up @@ -1636,6 +1655,16 @@ impl VirtualMethods for HTMLFormElement {
.reset_form_owner();
}
}

fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
&local_name!("rel") => AttrValue::from_serialized_tokenlist(value.into()),
_ => self
.super_type()
.unwrap()
.parse_plain_attribute(name, value),
}
}
}

pub trait FormControlElementHelpers {
Expand Down
3 changes: 3 additions & 0 deletions components/script/dom/webidls/HTMLFormElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ interface HTMLFormElement : HTMLElement {
attribute boolean noValidate;
[CEReactions]
attribute DOMString target;
[CEReactions]
attribute DOMString rel;
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;

[SameObject] readonly attribute HTMLFormControlsCollection elements;
readonly attribute unsigned long length;
Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions tests/wpt/metadata/html/dom/idlharness.https.html.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1911,9 +1911,6 @@
[HTMLElement interface: attribute accessKey]
expected: FAIL

[HTMLFormElement interface: attribute rel]
expected: FAIL

[HTMLObjectElement interface: document.createElement("object") must inherit property "vspace" with the proper type]
expected: FAIL

Expand Down Expand Up @@ -2547,9 +2544,6 @@
[HTMLInputElement interface: createInput("password") must inherit property "useMap" with the proper type]
expected: FAIL

[HTMLFormElement interface: attribute relList]
expected: FAIL

[HTMLElement interface: document.createElement("noscript") must inherit property "onauxclick" with the proper type]
expected: FAIL

Expand Down Expand Up @@ -3237,9 +3231,6 @@
[HTMLInputElement interface: createInput("radio") must inherit property "useMap" with the proper type]
expected: FAIL

[HTMLFormElement interface: document.createElement("form") must inherit property "rel" with the proper type]
expected: FAIL

[HTMLIFrameElement interface: attribute allowPaymentRequest]
expected: FAIL

Expand Down Expand Up @@ -3375,9 +3366,6 @@
[HTMLAreaElement interface: document.createElement("area") must inherit property "username" with the proper type]
expected: FAIL

[HTMLFormElement interface: document.createElement("form") must inherit property "relList" with the proper type]
expected: FAIL

[HTMLInputElement interface: createInput("search") must inherit property "height" with the proper type]
expected: FAIL

Expand Down