Implement HTMLInputElement cloning steps

This commit is contained in:
teapotd 2019-12-26 17:53:18 +01:00
parent 8002c6bc53
commit 386dc9fd75
3 changed files with 21 additions and 71 deletions

View file

@ -35,7 +35,7 @@ use crate::dom::htmlformelement::{ResetFrom, SubmittedFrom};
use crate::dom::keyboardevent::KeyboardEvent;
use crate::dom::mouseevent::MouseEvent;
use crate::dom::node::{document_from_node, window_from_node};
use crate::dom::node::{BindContext, Node, NodeDamage, UnbindContext};
use crate::dom::node::{BindContext, CloneChildrenFlag, Node, NodeDamage, UnbindContext};
use crate::dom::nodelist::NodeList;
use crate::dom::textcontrol::{TextControlElement, TextControlSelection};
use crate::dom::validation::Validatable;
@ -1659,6 +1659,26 @@ impl VirtualMethods for HTMLInputElement {
}
}
}
// https://html.spec.whatwg.org/multipage/#the-input-element%3Aconcept-node-clone-ext
fn cloning_steps(
&self,
copy: &Node,
maybe_doc: Option<&Document>,
clone_children: CloneChildrenFlag,
) {
if let Some(ref s) = self.super_type() {
s.cloning_steps(copy, maybe_doc, clone_children);
}
let elem = copy.downcast::<HTMLInputElement>().unwrap();
elem.value_dirty.set(self.value_dirty.get());
elem.checked_changed.set(self.checked_changed.get());
elem.upcast::<Element>()
.set_state(ElementState::IN_CHECKED_STATE, self.Checked());
elem.textinput
.borrow_mut()
.set_content(self.textinput.borrow().get_content());
}
}
impl FormControl for HTMLInputElement {

View file

@ -1,56 +0,0 @@
[clone.html]
type: testharness
[Checkbox must retain checked state.]
expected: FAIL
[Checkbox must retain unchecked state.]
expected: FAIL
[Radiobutton must retain checked state.]
expected: FAIL
[Radiobutton must retain unchecked state.]
expected: FAIL
[Text field must retain changed value.]
expected: FAIL
[Search field must retain changed value.]
expected: FAIL
[Phone number field must retain changed value.]
expected: FAIL
[URL field must retain changed value.]
expected: FAIL
[Email field must retain changed value.]
expected: FAIL
[Password field must retain changed value.]
expected: FAIL
[Date field must retain changed value.]
expected: FAIL
[Month field must retain changed value.]
expected: FAIL
[Week field must retain changed value.]
expected: FAIL
[Time field must retain changed value.]
expected: FAIL
[Datetime (local) field must retain changed value.]
expected: FAIL
[Number field must retain changed value.]
expected: FAIL
[Range control must retain changed value.]
expected: FAIL
[Color picker must retain changed value.]
expected: FAIL

View file

@ -1,14 +0,0 @@
[cloning-steps.html]
type: testharness
[input element's value should be cloned]
expected: FAIL
[input element's dirty value flag should be cloned, so setAttribute doesn't affect the cloned input's value]
expected: FAIL
[input element's checkedness should be cloned]
expected: FAIL
[input element's dirty checkedness should be cloned, so setAttribute doesn't affect the cloned input's checkedness]
expected: FAIL