From f5f6e7792bd8ef471d2f122dabfc34e3f2adcb88 Mon Sep 17 00:00:00 2001 From: abe33 Date: Fri, 5 Dec 2014 13:45:56 +0100 Subject: [PATCH] :bug: Fix broken minimap when shadowRoot isn't enabled --- lib/minimap-view.coffee | 12 ++++++++---- lib/mixins/dom-styles-reader.coffee | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/minimap-view.coffee b/lib/minimap-view.coffee index c6d0c827..cc50f5bc 100644 --- a/lib/minimap-view.coffee +++ b/lib/minimap-view.coffee @@ -91,7 +91,8 @@ class MinimapView extends View @offsetTop = 0 @indicator = new MinimapIndicator() - @scrollView = @editorView.shadowRoot.querySelector('.scroll-view') + @scrollView = @getEditorViewRoot().querySelector('.scroll-view') + @scrollViewLines = @scrollView.querySelector('.lines') @subscribeToEditor() @@ -194,7 +195,7 @@ class MinimapView extends View @scaleX = @scaleY = computedLineHeight / originalLineHeight getEditorLineHeight: -> - lineHeight = window.getComputedStyle(@editorView.shadowRoot.querySelector('.lines')).getPropertyValue('line-height') + lineHeight = window.getComputedStyle(@getEditorViewRoot().querySelector('.lines')).getPropertyValue('line-height') parseInt(lineHeight) # Destroys this view and release all its subobjects. @@ -220,6 +221,9 @@ class MinimapView extends View @obsPane.dispose() @obsPane = @pane.observeActiveItem @onActiveItemChanged + getEditorViewRoot: -> + @editorView.shadowRoot ? @editorView + # ######## #### ###### ######## ## ### ## ## # ## ## ## ## ## ## ## ## ## ## ## ## # ## ## ## ## ## ## ## ## ## #### @@ -353,7 +357,7 @@ class MinimapView extends View @editorView.style.paddingLeft = maxWidth else @editorView.style.paddingRight = maxWidth - @editorView.shadowRoot.querySelector('.vertical-scrollbar').style.right = maxWidth + @getEditorViewRoot().querySelector('.vertical-scrollbar').style.right = maxWidth # Internal: Resets the styles modified when the minimap width is adjusted # based on the soft-wrap. @@ -361,7 +365,7 @@ class MinimapView extends View @css maxWidth: '' @editorView.style.paddingRight = '' @editorView.style.paddingLeft = '' - @editorView.shadowRoot.querySelector('.vertical-scrollbar').style.right = '' + @getEditorViewRoot().querySelector('.vertical-scrollbar').style.right = '' # Internal: Updates the vertical scrolling of the minimap. # diff --git a/lib/mixins/dom-styles-reader.coffee b/lib/mixins/dom-styles-reader.coffee index afb8e92e..1f5ee391 100644 --- a/lib/mixins/dom-styles-reader.coffee +++ b/lib/mixins/dom-styles-reader.coffee @@ -46,7 +46,7 @@ class DOMStylesReader extends Mixin @dummyNode = document.createElement('span') @dummyNode.style.visibility = 'hidden' if shadowRoot - @editorView.shadowRoot.appendChild(@dummyNode) + @minimapView.getEditorViewRoot().appendChild(@dummyNode) else @editorView.appendChild(@dummyNode)