From f5ab5e36b85cb39b43c9f4f66737f3aacdddebbc Mon Sep 17 00:00:00 2001 From: abe33 Date: Sun, 1 Nov 2015 19:09:05 +0100 Subject: [PATCH] Implement new custom elements registration to allow updates --- lib/minimap-element.coffee | 7 ++++--- lib/minimap-plugin-generator-element.coffee | 6 ++++-- lib/minimap-quick-settings-element.coffee | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index 15bed7f7..f1004279 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -1,6 +1,6 @@ {debounce} = require 'underscore-plus' {CompositeDisposable, Disposable} = require 'atom' -{EventsDelegation, AncestorsMethods} = require 'atom-utils' +{registerOrUpdateElement, EventsDelegation, AncestorsMethods} = require 'atom-utils' DOMStylesReader = require './mixins/dom-styles-reader' CanvasDrawer = require './mixins/canvas-drawer' @@ -18,7 +18,7 @@ MinimapQuickSettingsElement = null # # Note that most interactions with the Minimap package is done through the # {Minimap} model so you should never have to access {MinimapElement} instances. -class MinimapElement extends HTMLElement +class MinimapElement DOMStylesReader.includeInto(this) CanvasDrawer.includeInto(this) EventsDelegation.includeInto(this) @@ -698,7 +698,8 @@ class MinimapElement extends HTMLElement # ## ## ## ## ## ## ## ### ## # ######## ######## ######## ## ## ######## ## ## ## -module.exports = MinimapElement = document.registerElement 'atom-text-editor-minimap', prototype: MinimapElement.prototype +module.exports = +MinimapElement = registerOrUpdateElement 'atom-text-editor-minimap', MinimapElement.prototype # Public: The method that registers the {MinimapElement} factory in the # `atom.views` registry with the passed-in model. diff --git a/lib/minimap-plugin-generator-element.coffee b/lib/minimap-plugin-generator-element.coffee index 5a062d8b..d34450f8 100644 --- a/lib/minimap-plugin-generator-element.coffee +++ b/lib/minimap-plugin-generator-element.coffee @@ -3,11 +3,12 @@ fs = require 'fs-plus' path = require 'path' {TextEditor, BufferedProcess} = require 'atom' {CompositeDisposable} = require 'event-kit' +{registerOrUpdateElement} = require 'atom-utils' # Internal: The {MinimapPluginGeneratorElement} is used whenever the user # triggers the `minimap:generate-plugin` command. module.exports = -class MinimapPluginGeneratorElement extends HTMLElement +class MinimapPluginGeneratorElement previouslyFocusedElement: null mode: null @@ -127,7 +128,8 @@ class MinimapPluginGeneratorElement extends HTMLElement new BufferedProcess({command, args, exit, options}) -module.exports = MinimapPluginGeneratorElement = document.registerElement 'minimap-plugin-generator', prototype: MinimapPluginGeneratorElement.prototype +module.exports = +MinimapPluginGeneratorElement = registerOrUpdateElement 'minimap-plugin-generator', MinimapPluginGeneratorElement.prototype atom.commands.add 'minimap-plugin-generator', { 'core:confirm': -> @confirm() diff --git a/lib/minimap-quick-settings-element.coffee b/lib/minimap-quick-settings-element.coffee index c30068f4..ea0f2560 100644 --- a/lib/minimap-quick-settings-element.coffee +++ b/lib/minimap-quick-settings-element.coffee @@ -1,12 +1,11 @@ -{EventsDelegation, SpacePenDSL} = require 'atom-utils' +{registerOrUpdateElement, EventsDelegation, SpacePenDSL} = require 'atom-utils' {CompositeDisposable, Emitter} = require 'event-kit' Main = require './main' # Internal: The {MinimapQuickSettingsElement} class is used to display # the Minimap quick settings when clicking on the corresponding button. -module.exports = -class MinimapQuickSettingsElement extends HTMLElement +class MinimapQuickSettingsElement SpacePenDSL.includeInto(this) EventsDelegation.includeInto(this) @@ -155,4 +154,5 @@ class MinimapQuickSettingsElement extends HTMLElement deactivateItem: (name, plugin) -> @plugins[name].classList.remove('active') -module.exports = MinimapQuickSettingsElement = document.registerElement 'minimap-quick-settings', prototype: MinimapQuickSettingsElement.prototype +module.exports = +MinimapQuickSettingsElement = registerOrUpdateElement 'minimap-quick-settings', MinimapQuickSettingsElement.prototype