mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-09 06:12:34 -05:00
Refactor Base._set
This commit is contained in:
parent
f193acf31b
commit
c6208db025
1 changed files with 7 additions and 7 deletions
|
@ -72,18 +72,18 @@ Base.inject(/** @lends Base# */{
|
||||||
* @return {Boolean} {@true if the object is a plain object}
|
* @return {Boolean} {@true if the object is a plain object}
|
||||||
*/
|
*/
|
||||||
_set: function(props, exclude, dontCheck) {
|
_set: function(props, exclude, dontCheck) {
|
||||||
if (props && (dontCheck || Base.isPlainObject(props))) {
|
if (dontCheck || Base.isPlainObject(props)) {
|
||||||
// If props is a filtering object, we need to execute hasOwnProperty
|
// If props is a filtering object, we need to execute hasOwnProperty
|
||||||
// on the original object (it's parent / prototype). See _filtered
|
// on the original object (it's parent / prototype). See _filtered
|
||||||
// inheritance trick in the argument reading code.
|
// inheritance trick in the argument reading code.
|
||||||
var orig = props._filtering || props;
|
var keys = Object.keys(props._filtering || props);
|
||||||
for (var key in orig) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
if (orig.hasOwnProperty(key) && !(exclude && exclude[key])) {
|
var key = keys[i];
|
||||||
var value = props[key];
|
if (!(exclude && exclude[key])) {
|
||||||
// Due to the _filtered inheritance trick, undefined is used
|
// Due to the _filtered inheritance trick, undefined is used
|
||||||
// to mask already consumed named arguments.
|
// to mask already consumed named arguments.
|
||||||
if (value !== undefined)
|
if (props[key] !== undefined)
|
||||||
this[key] = value;
|
this[key] = props[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue