From d9777111dcd8808ec36c5b7572a6233bcb920846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 24 Nov 2011 14:54:04 +0100 Subject: [PATCH] No need for an injection scope as we can also just use Base.each() in combination with a side-car. --- src/item/Item.js | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 7ef28f21..ddee7e03 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -293,26 +293,24 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ statics: { _id: 0 } -}, new function() { // Injection scope to produce getter setters for properties - // We need setters because we want to call _changed() if a property was - // modified. - return Base.each(['locked', 'visible', 'blendMode', 'opacity', 'guide'], - function(name) { - var part = Base.capitalize(name), - name = '_' + name; - this['get' + part] = function() { - return this[name]; - }; - this['set' + part] = function(value) { - if (value != this[name]) { - this[name] = value; - // #locked does not change appearance, all others do: - this._changed(name === '_locked' - ? ChangeFlag.ATTRIBUTE : Change.ATTRIBUTE); - } - }; - }, {}); -}, /** @lends Item# */{ +}, Base.each(['locked', 'visible', 'blendMode', 'opacity', 'guide'], + // Produce getter/setters for properties. We need setters because we want to + // call _changed() if a property was modified. + function(name) { + var part = Base.capitalize(name), + name = '_' + name; + this['get' + part] = function() { + return this[name]; + }; + this['set' + part] = function(value) { + if (value != this[name]) { + this[name] = value; + // #locked does not change appearance, all others do: + this._changed(name === '_locked' + ? ChangeFlag.ATTRIBUTE : Change.ATTRIBUTE); + } + }; +}, {}), /** @lends Item# */{ // Note: These properties have their getter / setters produced in the // injection scope above.