From 1f409871e8d0dad8e19d40d8896531f71b56d387 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 16 Jan 2021 15:19:51 +0100 Subject: [PATCH] Use key var for symbols --- src/dom_components/model/Component.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 939a2584f..0c9f6e293 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -27,6 +27,8 @@ const escapeRegExp = str => { const avoidInline = em => em && em.getConfig('avoidInlineStyle'); export const eventDrag = 'component:drag'; +export const keySymbol = '__symbol'; +export const keySymbolOf = '__symbol'; export const keySymbol2w = '__symbol2w'; /** @@ -591,7 +593,7 @@ const Component = Backbone.Model.extend(Styleable).extend( }, __isSymbol() { - return isArray(this.get('__symbol')); + return isArray(this.get(keySymbol)); }, __isSymbolTop() { @@ -600,11 +602,11 @@ const Component = Backbone.Model.extend(Styleable).extend( }, __getSymbolOf() { - return this.get('__symbolOf'); + return this.get(keySymbolOf); }, __getSymbToUp(opts = {}) { - const symbol = this.get('__symbol'); + const symbol = this.get(keySymbol); const symbolOf = this.__getSymbolOf(); let result = !this.__isSymbol() ? [] @@ -641,8 +643,8 @@ const Component = Backbone.Model.extend(Styleable).extend( const attrs = changed.attributes || {}; delete changed.status; delete changed.open; - delete changed.__symbol; - delete changed.__symbolOf; + delete changed[keySymbol]; + delete changed[keySymbolOf]; delete changed.attributes; delete attrs.id; if (!isEmptyObj(attrs)) changed.attributes = attrs; @@ -1106,13 +1108,13 @@ const Component = Backbone.Model.extend(Styleable).extend( // Symbols // If I clone an inner symbol, I have to reset it - cloned.unset('__symbol'); + cloned.unset(keySymbol); if (opt.symbol) { - const symbols = this.get('__symbol') || []; + const symbols = this.get(keySymbol) || []; symbols.push(cloned); - this.set('__symbol', symbols); + this.set(keySymbol, symbols); this.__initSymb(); - cloned.set('__symbolOf', this); + cloned.set(keySymbolOf, this); opt.symbol2w && cloned.set(keySymbol2w, 1); }