Thanks, @mkay581 for your thoughtful response.
Yes, I guess I didn’t have my nomenclature quite right – I never really considered Object.assign and “…” to be doing a merge, due to the aggressive (but faster?) overwriting, but it does appear it is often called “merge”, so I will be sure to use “deep merge” in order to keep that clear in the future.
I see now that my use of the word “solves” also gives the wrong impression, like being able to set styles and datasets can’t be done without difficulty. But what I’m looking for here is nice syntactic sugar to easily set a bunch of properties of a DOM element, passing in one object with everything in one step. If you have an elegant way of doing this, without defining a function, feel free to provide your preferred syntax, and maybe that would render this proposal as not being useful.
I think that the fact that Object.assign doesn’t work (directly? please correct me if I’m wrong) when you try to set properties of an element, including read-only properties style and dataset objects, provides evidence that that deep merge is a fundamental primitive missing from the JavaScript language. Surely setting style and dataset properties, in addition to other properties, is a common problem, which we shouldn’t avoid? Maybe I’m misunderstanding your concerns. So one could write a function that makes exceptions for dataset and style, but what if the DOM elements get another read only property in the future? Wouldn’t the code break?
I agree, as I mentioned before, that deepmerge functions are quite small (I note that npm deepmerge and JQueries ‘extend’ might not yet support symbols, which is a must).
But many other JavaScript functions, including Object.assign are also small and easy to write. They’ve been added to the platform, I think, simply because they are used so often, that it’s one less piece of code every application has to send to the browser.
I agree that the npm download count doesn’t guarantee that it is actually used that much, but I’m not sure how else to tell how often this functionality is used.
I should note (just realized) that lodash also has a deep extend function.