diff --git a/src/core/PaperScopeItem.js b/src/core/PaperScopeItem.js index 63c54da8..610d8069 100644 --- a/src/core/PaperScopeItem.js +++ b/src/core/PaperScopeItem.js @@ -38,7 +38,7 @@ var PaperScopeItem = Base.extend(Callback, /** @lends PaperScopeItem# */{ if (!this._scope) return false; var prev = this._scope[this._reference]; - if (prev && prev != this) + if (prev && prev !== this) prev.fire('deactivate'); this._scope[this._reference] = this; this.fire('activate', prev); diff --git a/src/item/Item.js b/src/item/Item.js index caef1c30..2dcfcd32 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -830,7 +830,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{ * no children, a {@link TextItem} with no text content and a {@link Path} * with no segments all are considered empty. * - * @type Boolean + * @return Boolean */ isEmpty: function() { return !this._children || this._children.length == 0; diff --git a/src/project/Project.js b/src/project/Project.js index 327c7d2d..0eebe3b2 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -92,6 +92,18 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ this.symbols = []; }, + /** + * Specifies whether the project has any content or not. Note that since + * projects by default are created with one empty layer, this returns alos + * {@code true} if that layer exists but is itself empty. + * + * @return Boolean + */ + isEmpty: function() { + return this.layers.length <= 1 + && (!this.activeLayer || this.activeLayer.isEmpty()); + }, + /** * Removes this project from the {@link PaperScope#projects} list, and also * removes its view, if one was defined.