mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Allow Base#_set() to exclude properties.
This commit is contained in:
parent
93c90d0cd8
commit
86a8f85874
1 changed files with 7 additions and 4 deletions
|
@ -67,14 +67,17 @@ Base.inject(/** @lends Base# */{
|
||||||
/**
|
/**
|
||||||
* #_set() is part of the mechanism for constructors which take one object
|
* #_set() is part of the mechanism for constructors which take one object
|
||||||
* literal describing all the properties to be set on the created instance.
|
* literal describing all the properties to be set on the created instance.
|
||||||
|
*
|
||||||
|
* @param {Object} props an object describing the properties to set
|
||||||
|
* @param {Object} [exclude=undefined] a lookup table listing properties to
|
||||||
|
* exclude.
|
||||||
* @return {Boolean} {@true if the object is a plain object}
|
* @return {Boolean} {@true if the object is a plain object}
|
||||||
*/
|
*/
|
||||||
_set: function(props) {
|
_set: function(props, exclude) {
|
||||||
if (props && Base.isPlainObject(props)) {
|
if (props && Base.isPlainObject(props)) {
|
||||||
for (var key in props)
|
for (var key in props)
|
||||||
// TODO: Filter out 'insert' parameter for now. This needs
|
if (props.hasOwnProperty(key) && key in this
|
||||||
// proper handling in Item constructor instead.
|
&& (!exclude || !exclude[key]))
|
||||||
if (key !== 'insert' && props.hasOwnProperty(key) && key in this)
|
|
||||||
this[key] = props[key];
|
this[key] = props[key];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue