mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -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
|
||||
* 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}
|
||||
*/
|
||||
_set: function(props) {
|
||||
_set: function(props, exclude) {
|
||||
if (props && Base.isPlainObject(props)) {
|
||||
for (var key in props)
|
||||
// TODO: Filter out 'insert' parameter for now. This needs
|
||||
// proper handling in Item constructor instead.
|
||||
if (key !== 'insert' && props.hasOwnProperty(key) && key in this)
|
||||
if (props.hasOwnProperty(key) && key in this
|
||||
&& (!exclude || !exclude[key]))
|
||||
this[key] = props[key];
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue