From 0743f1b7b821274ba6c8508109a24af2006f7fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 14 Jan 2016 01:44:05 +0100 Subject: [PATCH] Various optimizations around Project#view. --- src/core/PaperScope.js | 3 ++- src/core/PaperScopeItem.js | 4 ++++ src/item/Item.js | 2 +- src/style/Style.js | 2 +- src/view/View.js | 5 +++-- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/core/PaperScope.js b/src/core/PaperScope.js index 99f9f441..609d4e9e 100644 --- a/src/core/PaperScope.js +++ b/src/core/PaperScope.js @@ -155,7 +155,8 @@ var PaperScope = Base.extend(/** @lends PaperScope# */{ * @type View */ getView: function() { - return this.project && this.project.getView(); + var project = this.project; + return project && project._view; }, /** diff --git a/src/core/PaperScopeItem.js b/src/core/PaperScopeItem.js index cd78676b..f03b8904 100644 --- a/src/core/PaperScopeItem.js +++ b/src/core/PaperScopeItem.js @@ -58,5 +58,9 @@ var PaperScopeItem = Base.extend(Emitter, /** @lends PaperScopeItem# */{ this._scope[this._reference] = null; this._scope = null; return true; + }, + + getView: function() { + return this._scope.getView(); } }); diff --git a/src/item/Item.js b/src/item/Item.js index f12016a1..599c4596 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1189,7 +1189,7 @@ var Item = Base.extend(Emitter, /** @lends Item# */{ * @bean */ getView: function() { - return this._project.getView(); + return this._project._view; }, /** diff --git a/src/style/Style.js b/src/style/Style.js index 2b496eb9..e747a0f1 100644 --- a/src/style/Style.js +++ b/src/style/Style.js @@ -302,7 +302,7 @@ var Style = Base.extend(new function() { * @type View */ getView: function() { - return this._project.getView(); + return this._project._view; }, // Overrides diff --git a/src/view/View.js b/src/view/View.js index fa90de33..7d37d5e9 100644 --- a/src/view/View.js +++ b/src/view/View.js @@ -132,8 +132,9 @@ var View = Base.extend(Emitter, /** @lends View# */{ View._views.splice(View._views.indexOf(this), 1); delete View._viewsById[this._id]; // Unlink from project - if (this._project._view === this) - this._project._view = null; + var project = this._project; + if (project._view === this) + project._view = null; /*#*/ if (__options.environment == 'browser') { // Uninstall event handlers again for this view. DomEvent.remove(this._element, this._viewEvents);