Object.mixin, why just for enumerables (?)
Object.mixin, why just for enumerables (?)
It's a copy-paste error in the draft: ecmascript#1999#c1
this is the closest to specs we have today: WebReflection/object-mixin#object-mixin
it does copy all own descriptors so it's suitable for almost everything you
need but Symbols
(in any case absent in ES5)
That being said, it will be compatible with my Symbol
proposal/shim/polyfill if used.
gist.github.com/gitawego/5831179
But I am not testing, neither suggesting, to use the latter one if not
truly needed and not through Object.mixin
br
No, the closest yo a spec that we have is the spec
people.mozilla.org/~jorendorff/es6-draft.html#sec-object.mixin
I was talking about concrete and usable implementation of those specs. Updates and contribution always welcome, of course.
Object.mixin, why just for enumerables (?)
This is related to: mozilla.6506.n7.nabble.com/Object-define-Object-mixin-tp265638p265651.html
In a spec we have both Object.assign and Object.mixin.
Object.assign is for copying properties ES3 way, which even in ES5 world is what you want in most cases (btw. I don't agree with www.nczonline.net/blog/2012/12/11/are-your-mixins-ecmascript-5-compatible For 3 years I work strictly with ES5, and I never had a case in which I wanted to just copy enumerables and preserve getters, it's highly unwanted in all cases I had).
Object.mixin is for copying definitions, which I find as rare but also valid use case, e.g. to mimic multiple inheritance by copying properties from one prototype to other. However this cannot work as intended if it's limited just for enumerables. All properties in native prototypes are already defined as not enumerable, and this is also what I follow in my code when I define models.
So as specified currently I find Object.mixin as a function that I don't find valid use case for, and I strongly miss something like Object.assignDefinitions, which will copy properties by descriptors, no matter whether they're enumerable or not.