Re: [whatwg/dom] Define cloning steps for an select element (#644)

> If someone creates a library which clones select state too, and it becomes of a similar level of popularity as cloneNode, that would be a great signal that we should reconsider this. 

jQuery tried to fix some of these inconsistencies in the IE8 era but gave up on it because it's incredibly expensive to traverse two arbitrarily large cloned DOM trees to fix things after the fact. It's less of a burden at the app level (if you know you're cloning a specific set of form elements) but as a library we don't know that in advance so we have to do it for every clone operation.

At the point that jQuery documentation was written, you can see there were more exceptions. IE8 in particular cloned almost no state. As far as I can tell today, every modern browser clones the state of `<input>` and `<textarea>`. 

For `<textarea>` I think the cloning behavior change started in June 2015 with Chrome 43. According to [Chrome bug 487352](https://bugs.chromium.org/p/chromium/issues/detail?id=487352) the copying of `<textarea>'s` dynamic value was an accident and considered to be a bug. Then in September 2016 the same discrepancy was [revived in an old Firefox ticket](https://bugzilla.mozilla.org/show_bug.cgi?id=230307). 

The discussion in https://github.com/whatwg/html/issues/1233 is a good timeline. As far as I can tell, nobody has reported a bug anywhere against the new behavior, although the previous non-copying behavior had been reported as a bug several times against browsers and jQuery, see https://github.com/jquery/jquery/issues/3115 . (Note that ticket was about both `<textarea>` *and* `<select>` elements.)

> A tree-cloning function that also copies a few small pieces of state if the nodes of the tree have certain names is not good design. (That's the legacy mistake I refer to.)

This is *soooooo* true! No form elements should have ever cloned state IMO. I think it started with checkboxes in the distant past and spread from there. The only thing worse than cloning state on all form elements is cloning it on some because the result is tickets like this one. 



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/644#issuecomment-443428767

Received on Saturday, 1 December 2018 14:08:13 UTC