mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
webdriver: Implement element clear (#38208)
Initial Implementation of [Element Clear](https://w3c.github.io/webdriver/#element-clear). Testing: `tests/wpt/tests/webdriver/tests/classic/element_clear/` --------- Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com> Signed-off-by: Kenzie Raditya Tirtarahardja <kenzieradityatirtarahardja18@gmail.com> Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
1fb782bc38
commit
4b12ae73fe
11 changed files with 175 additions and 367 deletions
|
@ -2193,6 +2193,26 @@ impl HTMLInputElement {
|
|||
self.upcast::<Node>().dirty(NodeDamage::Other);
|
||||
}
|
||||
|
||||
/// <https://w3c.github.io/webdriver/#ref-for-dfn-clear-algorithm-3>
|
||||
/// Used by WebDriver to clear the input element.
|
||||
pub(crate) fn clear(&self, can_gc: CanGc) {
|
||||
// Step 1. Reset dirty value and dirty checkedness flags.
|
||||
self.value_dirty.set(false);
|
||||
self.checked_changed.set(false);
|
||||
// Step 2. Set value to empty string.
|
||||
self.textinput.borrow_mut().set_content(DOMString::from(""));
|
||||
// Step 3. Set checkedness based on presence of content attribute.
|
||||
self.update_checked_state(self.DefaultChecked(), false);
|
||||
self.value_changed(can_gc);
|
||||
// Step 4. Empty selected files
|
||||
self.filelist.set(None);
|
||||
// Step 5. invoke the value sanitization algorithm iff
|
||||
// the type attribute's current state defines one.
|
||||
// This is covered in `fn sanitize_value` called below.
|
||||
self.enable_sanitization();
|
||||
self.upcast::<Node>().dirty(NodeDamage::Other);
|
||||
}
|
||||
|
||||
fn update_placeholder_shown_state(&self) {
|
||||
if !self.input_type().is_textual_or_password() {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue