mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Simplify Item#getId()
This commit is contained in:
parent
0d85e0941c
commit
1dd0ee2533
1 changed files with 10 additions and 14 deletions
|
@ -34,6 +34,16 @@ var Item = this.Item = Base.extend({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The unique id of the item.
|
||||
*/
|
||||
getId: function() {
|
||||
if (this._id == null) {
|
||||
this._id = Item._id = (Item._id || 0) + 1;
|
||||
}
|
||||
return this._id;
|
||||
}
|
||||
|
||||
/**
|
||||
* When passed a document, copies the item to the document,
|
||||
* or duplicates it within the same document. When passed an item,
|
||||
|
@ -996,18 +1006,4 @@ var Item = this.Item = Base.extend({
|
|||
return this;
|
||||
}
|
||||
});
|
||||
}, new function() {
|
||||
var id = 0;
|
||||
return {
|
||||
beans: true,
|
||||
|
||||
/**
|
||||
* The unique id of the item.
|
||||
*/
|
||||
getId: function() {
|
||||
if (this._id === undefined)
|
||||
this._id = id++;
|
||||
return this._id;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue