mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Simplify Base.readNamed() methods.
This commit is contained in:
parent
7782116e06
commit
7294c5499c
1 changed files with 3 additions and 9 deletions
|
@ -231,9 +231,7 @@ this.Base = Base.inject(/** @lends Base# */{
|
||||||
*/
|
*/
|
||||||
readNamed: function(list, name) {
|
readNamed: function(list, name) {
|
||||||
var value = this.getNamed(list, name);
|
var value = this.getNamed(list, name);
|
||||||
// value is undefined if there is no arguments object, and null
|
return this.read(value != null ? [value] : list);
|
||||||
// if there is one, but no value is defined.
|
|
||||||
return this.read(value !== undefined ? [value] : list);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -246,13 +244,9 @@ this.Base = Base.inject(/** @lends Base# */{
|
||||||
var arg = list[0];
|
var arg = list[0];
|
||||||
if (list._hasObject === undefined)
|
if (list._hasObject === undefined)
|
||||||
list._hasObject = list.length === 1 && Base.isPlainObject(arg);
|
list._hasObject = list.length === 1 && Base.isPlainObject(arg);
|
||||||
if (list._hasObject) {
|
if (list._hasObject)
|
||||||
// Return the whole arguments object if no name is provided.
|
// Return the whole arguments object if no name is provided.
|
||||||
value = name ? arg[name] : arg;
|
return name ? arg[name] : arg;
|
||||||
// Convert undefined to null, to distinguish from undefined
|
|
||||||
// result, when there is no arguments object.
|
|
||||||
return value !== undefined ? value : null;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue