mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Define Item#clear() as an alias for Item#removeChildren(), or Path#removeSegments() for paths.
This commit is contained in:
parent
df80eb2f23
commit
132f54d362
3 changed files with 7 additions and 4 deletions
|
@ -1956,6 +1956,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
* Removes all of the item's {@link #children} (if any).
|
||||
*
|
||||
* @name Item#removeChildren
|
||||
* @alias Item#clear
|
||||
* @function
|
||||
* @return {Item[]} an array containing the removed items
|
||||
*/
|
||||
|
@ -1985,6 +1986,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
return removed;
|
||||
},
|
||||
|
||||
clear: '#removeChildren',
|
||||
|
||||
/**
|
||||
* Reverses the order of the item's children
|
||||
*/
|
||||
|
|
|
@ -635,6 +635,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
* Removes all segments from the path's {@link #segments} array.
|
||||
*
|
||||
* @name Path#removeSegments
|
||||
* @alias Path#clear
|
||||
* @function
|
||||
* @return {Segment[]} an array containing the removed segments
|
||||
*/
|
||||
|
@ -707,6 +708,8 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
return removed;
|
||||
},
|
||||
|
||||
clear: '#removeSegments',
|
||||
|
||||
/**
|
||||
* Specifies whether an path is selected and will also return {@code true}
|
||||
* if the path is partially selected, i.e. one or more of its segments is
|
||||
|
|
|
@ -108,10 +108,7 @@ var PathItem = Item.extend(/** @lends PathItem# */{
|
|||
}
|
||||
|
||||
// First clear the previous content
|
||||
if (this._type === 'path')
|
||||
this.removeSegments();
|
||||
else
|
||||
this.removeChildren();
|
||||
this.clear();
|
||||
|
||||
for (var i = 0, l = parts.length; i < l; i++) {
|
||||
var part = parts[i],
|
||||
|
|
Loading…
Reference in a new issue