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

Cloning a form doesn't preserve changed values of its HTMLInputElement children. #25385

Closed
pshaughn opened this issue Dec 24, 2019 · 3 comments
Closed

Comments

@pshaughn
Copy link
Member

@pshaughn pshaughn commented Dec 24, 2019

WPT html/semantics/forms/the-input-element/clone.html has a form with value and checked content attributes on many input children. It sets .value on the children, then calls cloneNode on the form. It gets back a clone, but the clone's children's values match the original values from their content attributes, not the updated values that were set by the script.

@jdm jdm added the A-content/dom label Dec 25, 2019
@jdm jdm added this to To do in web-platform-test failures via automation Dec 25, 2019
@jdm
Copy link
Member

@jdm jdm commented Dec 25, 2019

Node::clone's handling of elements doesn't include the concept of "cloning steps" (ie. step 5 of the algorithm), which includes specific steps for input elements (https://html.spec.whatwg.org/multipage/input.html#the-input-element%3Aconcept-node-clone-ext).

NodeTypeId::Element(..) => {
let element = node.downcast::<Element>().unwrap();
let name = QualName {
prefix: element.prefix().as_ref().map(|p| Prefix::from(&**p)),
ns: element.namespace().clone(),
local: element.local_name().clone(),
};
let element = Element::create(
name,
element.get_is(),
&document,
ElementCreator::ScriptCreated,
CustomElementCreationMode::Asynchronous,
);
DomRoot::upcast::<Node>(element)

We should probably extend the VirtualMethods trait to incorporate cloning steps.

@teapotd
Copy link
Contributor

@teapotd teapotd commented Dec 26, 2019

VirtualMethods trait already has cloning_steps method and Node::clone includes step 5:

// Step 5: cloning steps.
vtable_for(&node).cloning_steps(&copy, maybe_doc, clone_children);

It suffices to implement cloning_steps for HTMLInputElement. I'd like to claim this one.

@highfive assign me

@highfive highfive added the C-assigned label Dec 26, 2019
@highfive
Copy link

@highfive highfive commented Dec 26, 2019

Hey @teapotd! Thanks for your interest in working on this issue. It's now assigned to you!

@teapotd teapotd mentioned this issue Dec 26, 2019
4 of 4 tasks complete
bors-servo added a commit that referenced this issue Dec 27, 2019
Implement HTMLInputElement cloning steps

This change adds missing [cloning steps for input elements](https://html.spec.whatwg.org/multipage/#the-input-element%3Aconcept-node-clone-ext).

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25385
- [X] There are tests for these changes
bors-servo added a commit that referenced this issue Jan 3, 2020
Implement HTMLInputElement cloning steps

This change adds missing [cloning steps for input elements](https://html.spec.whatwg.org/multipage/#the-input-element%3Aconcept-node-clone-ext).

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25385
- [X] There are tests for these changes
bors-servo added a commit that referenced this issue Jan 3, 2020
Implement HTMLInputElement cloning steps

This change adds missing [cloning steps for input elements](https://html.spec.whatwg.org/multipage/#the-input-element%3Aconcept-node-clone-ext).

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25385
- [X] There are tests for these changes
@bors-servo bors-servo closed this in 7d986a2 Jan 3, 2020
web-platform-test failures automation moved this from To do to Done Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.