{"action":"created","issue":{"url":"https://api.github.com/repos/dojo/core/issues/26","labels_url":"https://api.github.com/repos/dojo/core/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/dojo/core/issues/26/comments","events_url":"https://api.github.com/repos/dojo/core/issues/26/events","html_url":"https://github.com/dojo/core/issues/26","id":82027226,"number":26,"title":"lang needs something that Just Works for simple value copying","user":{"login":"kfranqueiro","id":398379,"avatar_url":"https://avatars.githubusercontent.com/u/398379?v=3","gravatar_id":"","url":"https://api.github.com/users/kfranqueiro","html_url":"https://github.com/kfranqueiro","followers_url":"https://api.github.com/users/kfranqueiro/followers","following_url":"https://api.github.com/users/kfranqueiro/following{/other_user}","gists_url":"https://api.github.com/users/kfranqueiro/gists{/gist_id}","starred_url":"https://api.github.com/users/kfranqueiro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfranqueiro/subscriptions","organizations_url":"https://api.github.com/users/kfranqueiro/orgs","repos_url":"https://api.github.com/users/kfranqueiro/repos","events_url":"https://api.github.com/users/kfranqueiro/events{/privacy}","received_events_url":"https://api.github.com/users/kfranqueiro/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dojo/core/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"bryanforbes","id":204106,"avatar_url":"https://avatars.githubusercontent.com/u/204106?v=3","gravatar_id":"","url":"https://api.github.com/users/bryanforbes","html_url":"https://github.com/bryanforbes","followers_url":"https://api.github.com/users/bryanforbes/followers","following_url":"https://api.github.com/users/bryanforbes/following{/other_user}","gists_url":"https://api.github.com/users/bryanforbes/gists{/gist_id}","starred_url":"https://api.github.com/users/bryanforbes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryanforbes/subscriptions","organizations_url":"https://api.github.com/users/bryanforbes/orgs","repos_url":"https://api.github.com/users/bryanforbes/repos","events_url":"https://api.github.com/users/bryanforbes/events{/privacy}","received_events_url":"https://api.github.com/users/bryanforbes/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dojo/core/milestones/1","html_url":"https://github.com/dojo/core/milestones/Milestone%201","labels_url":"https://api.github.com/repos/dojo/core/milestones/1/labels","id":1140228,"number":1,"title":"Milestone 1","description":"","creator":{"login":"eheasley","id":7253801,"avatar_url":"https://avatars.githubusercontent.com/u/7253801?v=3","gravatar_id":"","url":"https://api.github.com/users/eheasley","html_url":"https://github.com/eheasley","followers_url":"https://api.github.com/users/eheasley/followers","following_url":"https://api.github.com/users/eheasley/following{/other_user}","gists_url":"https://api.github.com/users/eheasley/gists{/gist_id}","starred_url":"https://api.github.com/users/eheasley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eheasley/subscriptions","organizations_url":"https://api.github.com/users/eheasley/orgs","repos_url":"https://api.github.com/users/eheasley/repos","events_url":"https://api.github.com/users/eheasley/events{/privacy}","received_events_url":"https://api.github.com/users/eheasley/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":16,"state":"open","created_at":"2015-05-29T15:16:01Z","updated_at":"2015-06-03T22:48:37Z","due_on":"2015-06-27T04:00:00Z","closed_at":null},"comments":8,"created_at":"2015-05-28T16:54:39Z","updated_at":"2015-06-09T17:29:09Z","closed_at":null,"body":"I know we are already mulling over how to split up `lang.copy` to simplify its API and also the mental overhead regarding the combinations it supports.  On top of that, one thing it doesn't seem to support is simply copying values, a la `lang.mixin` in Dojo 1.\r\n\r\nHere's an interesting (though probably rather edgy) case I just ran into (trying to use it during development of `dom/geometry`, https://github.com/dojo/dom/issues/8) that affects various browsers differently, presumably due to how they treat native `ClientRect` objects:\r\n\r\n1. Get a native `ClientRect` object via `someElement.getBoundingClientRect()`\r\n2. Attempt to coerce to a plain ol' object by running through `copy`\r\n\r\nResults:\r\n\r\n* On Chrome this happens to Just Work as expected - you get an object with the expected properties with numeric values.\r\n* On Firefox (tested 38) and IE (tested 9 and 11), you end up with seemingly an empty object.\r\n\r\nTangentially, I would definitely vouch for not burying `sources` in a `kwArgs` object if we can help it, and accommodating one source without needing an array.  Having to do that in this case seems rather obtuse.  (I realize that other derivative APIs like `create` and `duplicate` wrap this complexity away.)"},"comment":{"url":"https://api.github.com/repos/dojo/core/issues/comments/110440666","html_url":"https://github.com/dojo/core/issues/26#issuecomment-110440666","issue_url":"https://api.github.com/repos/dojo/core/issues/26","id":110440666,"user":{"login":"mwistrand","id":3423657,"avatar_url":"https://avatars.githubusercontent.com/u/3423657?v=3","gravatar_id":"","url":"https://api.github.com/users/mwistrand","html_url":"https://github.com/mwistrand","followers_url":"https://api.github.com/users/mwistrand/followers","following_url":"https://api.github.com/users/mwistrand/following{/other_user}","gists_url":"https://api.github.com/users/mwistrand/gists{/gist_id}","starred_url":"https://api.github.com/users/mwistrand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwistrand/subscriptions","organizations_url":"https://api.github.com/users/mwistrand/orgs","repos_url":"https://api.github.com/users/mwistrand/repos","events_url":"https://api.github.com/users/mwistrand/events{/privacy}","received_events_url":"https://api.github.com/users/mwistrand/received_events","type":"User","site_admin":false},"created_at":"2015-06-09T17:29:09Z","updated_at":"2015-06-09T17:29:09Z","body":"The Dojo 2 Core proposal does include both `create` and `duplicate` methods. `create` is essentially identical to `Object.assign(Object.create(somePrototoype), source1, source2, ...sourceN);`. With `copyDeep` added, the `duplicate` method might be implemented as:\r\n\r\n```\r\nexport function duplicate(source: {}): {} {\r\n\tconst target = Object.create(Object.getPrototypeOf(source));\r\n\r\n\treturn copyDeep(target, source);\r\n}\r\n```\r\n\r\nAs for the difference between `copy` and `assign`, it is a little more involved than that one copies only own properties and the other copies all properties. `Object.assign` doesn't actually copy property descriptors, but instead does a simple assignment like Dojo 1's `lang.mixin`. So if we were keeping true to that, then `lang.assign` would include only enumerable, own properties, and the resulting property descriptors would be `{ configurable: true, enumerable: true, value: source[key], writable: true }`. `lang.copy`, on the other hand, would copy all properties (enumerable or otherwise, via `Object.getOwnPropertyNames(source)`), along with the associated descriptors. The exception here would be accessors, since I don't see how they can be safely copied, in which case the result of `source[key]` would be used for `descriptor.value`."}}