RESOLVED FIXED 156637
Cloning a textarea does not clone the textarea's value
https://bugs.webkit.org/show_bug.cgi?id=156637
Summary Cloning a textarea does not clone the textarea's value
Myles C. Maxfield
Reported 2016-04-15 12:54:22 PDT
Created attachment 276497 [details] Reproduction Open the attached .html file. It should alert "a" twice.
Attachments
Reproduction (338 bytes, text/html)
2016-04-15 12:54 PDT, Myles C. Maxfield
no flags
Patch (2.12 KB, patch)
2016-04-25 20:47 PDT, Myles C. Maxfield
no flags
Patch (2.20 KB, patch)
2016-04-25 20:49 PDT, Myles C. Maxfield
no flags
Patch (9.68 KB, patch)
2016-09-15 12:36 PDT, Chris Dumez
no flags
Archive of layout-test-results from ews114 for mac-yosemite (1.58 MB, application/zip)
2016-09-15 13:47 PDT, Build Bot
no flags
Patch (9.76 KB, patch)
2016-09-15 14:52 PDT, Chris Dumez
no flags
Myles C. Maxfield
Comment 1 2016-04-15 12:55:09 PDT
Note that fixing this bug should include making sure checkValidity() works correctly.
Myles C. Maxfield
Comment 2 2016-04-15 13:00:17 PDT
(In reply to comment #1) > Note that fixing this bug should include making sure checkValidity() works > correctly. fast/forms/checkValidity-cloneNode-crash.html should be updated when this occurs.
Chris Dumez
Comment 3 2016-04-16 20:25:00 PDT
Firefox and Safari alert "a" once. Chrome alerts "a" twice.
Chris Dumez
Comment 4 2016-04-16 20:38:26 PDT
Myles, why do you expect the textarea cloning to clone the value? I am looking at the spec but I cannot find the part that says we should (maybe I missed it or maybe it is a bug in the spec). There is what I found in the spec: https://dom.spec.whatwg.org/#concept-node-clone -> Says we should copy over all the element attributes, but 'value' is not a content attribute of textarea. -> Says to run any cloning steps defined for the element in other applicable specifications So I looked at the HTML spec for HTMLTextAreaElement but it does not seem to define any additional cloning steps: https://html.spec.whatwg.org/multipage/forms.html#htmltextareaelement The only cloning steps I find on this page are: "The cloning steps for input elements must propagate the value, dirty value flag, checkedness, and dirty checkedness flag from the node being cloned to the copy." However, HTMLTextAreaElement is not an input element (HTMLInputElement). So, unless I am mistaken, Firefox and Safari/WebKit both match the specification. Assuming I did not miss anything and you think we should clone the value, I suggest filing a bug against the HTML spec.
Ryosuke Niwa
Comment 5 2016-04-17 17:16:48 PDT
As far as I read the spec, this is a bug in Chrome and WebKit/Gecko behavior is what the spec mandates. It's somewhat surprising that input element's value is propagated during cloning.
Anne van Kesteren
Comment 6 2016-04-17 23:09:52 PDT
Per HTML only <input>, <template>, and <script> have special cloning behavior. Rick, Philip, any idea why Chrome has this behavior for <textarea>?
Philip Jägenstedt
Comment 7 2016-04-25 13:24:08 PDT
To begin with, here's the code: https://chromium.googlesource.com/chromium/src/+blame/8400b8124886e7c94ce59b2e595ae74cee821f56/third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp#641 That was added in response to this bug: https://bugs.chromium.org/p/chromium/issues/detail?id=487352 I haven't dug deeper into how this turned out this way, but will comment on the bug and point here.
Ryosuke Niwa
Comment 8 2016-04-25 16:27:24 PDT
Closing this bug as won't fix since WebKit's current behavior matches the spec and Gecko's behavior. Given this Chrome not matching the spec appears to be unintentional, I don't think we should change our behavior.
Myles C. Maxfield
Comment 9 2016-04-25 20:42:47 PDT
Rather than closing the bug now, if we will proceed by considering this a supported operation, we should add a test.
Myles C. Maxfield
Comment 10 2016-04-25 20:47:29 PDT
Reopening to attach new patch.
Myles C. Maxfield
Comment 11 2016-04-25 20:47:32 PDT
Ryosuke Niwa
Comment 12 2016-04-25 20:48:56 PDT
Comment on attachment 277322 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=277322&action=review We should probably add a more direct test for cloneNode which checks that the value property doesn't get copied over. > LayoutTests/ChangeLog:7 > + Please add a change log description.
Chris Dumez
Comment 13 2016-04-25 20:49:05 PDT
Comment on attachment 277322 [details] Patch r=me
Myles C. Maxfield
Comment 14 2016-04-25 20:49:38 PDT
Myles C. Maxfield
Comment 15 2016-04-25 20:51:47 PDT
Daniel Bates
Comment 16 2016-04-28 23:11:36 PDT
Comment on attachment 277323 [details] Patch Clearing review flag given that this patch landed by comment #15.
Chris Dumez
Comment 17 2016-05-11 09:45:53 PDT
Chris Dumez
Comment 18 2016-09-15 10:56:33 PDT
Reopen given that the spec was updated got add cloning steps for Textarea: https://github.com/whatwg/html/pull/1784
Chris Dumez
Comment 19 2016-09-15 12:36:51 PDT
Build Bot
Comment 20 2016-09-15 13:47:50 PDT
Comment on attachment 288984 [details] Patch Attachment 288984 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/2081456 New failing tests: fast/forms/checkValidity-cloneNode-crash.html
Build Bot
Comment 21 2016-09-15 13:47:55 PDT
Created attachment 288992 [details] Archive of layout-test-results from ews114 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-yosemite Platform: Mac OS X 10.10.5
Sam Weinig
Comment 22 2016-09-15 14:27:54 PDT
Comment on attachment 288984 [details] Patch Causing crashes.
Chris Dumez
Comment 23 2016-09-15 14:52:39 PDT
Chris Dumez
Comment 24 2016-09-15 14:53:15 PDT
Comment on attachment 289003 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=289003&action=review > Source/WebCore/html/HTMLTextAreaElement.cpp:598 > + updateValidity(); I was missing a call to updateValidity() here.
Daniel Bates
Comment 25 2016-09-15 18:51:34 PDT
Comment on attachment 289003 [details] Patch Please file a new bug for this patch. This patch represents a change of behavior. We should not re-open this bug, which was fixed 5 months ago (comment #15) to conform to the spec. at the time.
Chris Dumez
Comment 26 2016-09-15 18:57:22 PDT
Comment on attachment 289003 [details] Patch No, this bug was opened for this purpose, as per the title. At the time, we decided to hold off on making this change (and file a bug upstream). But now that the spec has been updated, we should do it. This is also the bug that is tracked upstream (by spec editors).
Chris Dumez
Comment 27 2016-09-16 09:34:44 PDT
Comment on attachment 289003 [details] Patch Clearing flags on attachment: 289003 Committed r206026: <http://trac.webkit.org/changeset/206026>
Chris Dumez
Comment 28 2016-09-16 09:34:50 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.