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 {