diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/memory.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/memory.js b/src/memory.js index 336716a..9b6f308 100644 --- a/src/memory.js +++ b/src/memory.js @@ -1,9 +1,6 @@ SVG.extend(SVG.Element, { - // Initialize local memory object - _memory: {} - // Remember arbitrary data -, remember: function(k, v) { + remember: function(k, v) { /* remember every item in an object individually */ if (typeof arguments[0] == 'object') for (var v in k) @@ -11,11 +8,11 @@ SVG.extend(SVG.Element, { /* retrieve memory */ else if (arguments.length == 1) - return this._memory[k] + return this.memory()[k] /* store memory */ else - this._memory[k] = v + this.memory()[k] = v return this } @@ -26,9 +23,14 @@ SVG.extend(SVG.Element, { this._memory = {} else for (var i = arguments.length - 1; i >= 0; i--) - delete this._memory[arguments[i]] + delete this.memory()[arguments[i]] return this } + // Initialize or return local memory object +, memory: function() { + return this._memory || (this._memory = {}) + } + })
\ No newline at end of file |