Skip to content

Commit

Permalink
Merge pull request #1959 from Polymer/1911-kschaaf
Browse files Browse the repository at this point in the history
Move mixin to Base. Fixes #1911
  • Loading branch information
Steve Orvell committed Jun 24, 2015
2 parents 489bd29 + 2234eff commit 259efb8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
29 changes: 28 additions & 1 deletion src/lib/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@
this._doBehavior('attributeChanged', arguments); // abstract
},

// copy own properties from `api` to `prototype`
/**
* Copies own properties (including accessor descriptors) from a source
* object to a target object.
*
* @method extend
* @param {Object} prototype Target object to copy properties to.
* @param {Object} api Source object to copy properties from.
* @return {Object} prototype object that was passed as first argument.
*/
extend: function(prototype, api) {
if (prototype && api) {
Object.getOwnPropertyNames(api).forEach(function(n) {
Expand All @@ -58,6 +66,25 @@
return prototype || api;
},

/**
* Copies props from a source object to a target object.
*
* Note, this method ueses a simple `for...in` strategy for enumerating
* properties. To ensure only `ownProperties` are copied from source
* to target and that accessor implementations are copied, use `extend`.
*
* @method mixin
* @param {Object} target Target object to copy properties to.
* @param {Object} source Source object to copy properties from.
* @return {Object} Target object that was passed as first argument.
*/
mixin: function(target, source) {
for (var i in source) {
target[i] = source[i];
}
return target;
},

copyOwnProperty: function(name, source, target) {
var pd = Object.getOwnPropertyDescriptor(source, name);
if (pd) {
Expand Down
19 changes: 0 additions & 19 deletions src/standard/utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,6 @@
}
}
return elt;
},

/**
* Copies props from a source object to target a target object.
*
* Note, this method ueses a simple `for...in` strategy for enumerating
* properties. To ensure only `ownProperties` are copied from source
* to target and that accessor implementations are copied, use `extend`.
*
* @method mixin
* @param {Object} target Target object to copy properties to.
* @param {Object} source Source object to copy properties from.
* @return {Object} Target object that was passed as first argument.
*/
mixin: function(target, source) {
for (var i in source) {
target[i] = source[i];
}
return target;
}

});
Expand Down

0 comments on commit 259efb8

Please sign in to comment.