aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlformelement.rs
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-01-10 18:27:07 -0500
committerCorey Farwell <coreyf@rwell.org>2016-01-10 18:27:07 -0500
commit1ff1ec69dd1c0e7ea7d5c74dc1fcf9738fb71945 (patch)
treea2ed5e76f90f584328e04f56cfc83c36756817cc /components/script/dom/htmlformelement.rs
parent4056716ecdf5382eadf5866f7ac08ee49dcda8bb (diff)
downloadservo-1ff1ec69dd1c0e7ea7d5c74dc1fcf9738fb71945.tar.gz
servo-1ff1ec69dd1c0e7ea7d5c74dc1fcf9738fb71945.zip
HTMLFormElement::Elements should honor [SameObject] attribute
Ideally, this would get tested by web-platform-tests, but that has yet to be implemented: https://github.com/w3c/web-platform-tests/issues/2462
Diffstat (limited to 'components/script/dom/htmlformelement.rs')
-rw-r--r--components/script/dom/htmlformelement.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index 43cf6bce3ce..0922902778a 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaEl
use dom::bindings::conversions::DerivedFrom;
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
-use dom::bindings::js::{Root};
+use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::Reflectable;
use dom::document::Document;
use dom::element::Element;
@@ -47,6 +47,7 @@ use util::str::DOMString;
pub struct HTMLFormElement {
htmlelement: HTMLElement,
marked_for_reset: Cell<bool>,
+ elements: MutNullableHeap<JS<HTMLFormControlsCollection>>,
}
impl HTMLFormElement {
@@ -56,6 +57,7 @@ impl HTMLFormElement {
HTMLFormElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document),
marked_for_reset: Cell::new(false),
+ elements: Default::default(),
}
}
@@ -142,6 +144,10 @@ impl HTMLFormElementMethods for HTMLFormElement {
// https://html.spec.whatwg.org/multipage/#dom-form-elements
fn Elements(&self) -> Root<HTMLFormControlsCollection> {
+ if let Some(elements) = self.elements.get() {
+ return elements;
+ }
+
#[derive(JSTraceable, HeapSizeOf)]
struct ElementsFilter {
form: Root<HTMLFormElement>
@@ -193,7 +199,9 @@ impl HTMLFormElementMethods for HTMLFormElement {
}
let filter = box ElementsFilter { form: Root::from_ref(self) };
let window = window_from_node(self);
- HTMLFormControlsCollection::new(window.r(), self.upcast(), filter)
+ let elements = HTMLFormControlsCollection::new(window.r(), self.upcast(), filter);
+ self.elements.set(Some(&elements));
+ elements
}
// https://html.spec.whatwg.org/multipage/#dom-form-length