Skip to content

Commit

Permalink
🐛 Fix dom reader failing to append the node outside render view
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 15, 2014
1 parent daece0b commit 17ba173
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions lib/minimap-render-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ class MinimapRenderView extends ScrollView
height: @getMinimapHeight()
}

getDummyDOMRoot: (shadowRoot) ->
if shadowRoot
@minimapView.getEditorViewRoot()
else
@editorView

# Returns a pixel position corresponding to a character's screen
# position.
#
Expand Down
13 changes: 7 additions & 6 deletions lib/mixins/dom-styles-reader.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ Mixin = require 'mixto'

module.exports =
class DOMStylesReader extends Mixin
@domStylesCache: {}

# Internal: This function insert a dummy element in the DOM to compute
# its style, return the specified property, and remove the element
# from the DOM.
Expand All @@ -16,6 +14,8 @@ class DOMStylesReader extends Mixin
#
# Returns a {String} of the property value.
retrieveStyleFromDom: (scopes, property, shadowRoot=true, cache=true) ->
@ensureCache()

key = scopes.join(' ')

if cache and @constructor.domStylesCache[key]?[property]?
Expand Down Expand Up @@ -45,10 +45,11 @@ class DOMStylesReader extends Mixin
unless @dummyNode?
@dummyNode = document.createElement('span')
@dummyNode.style.visibility = 'hidden'
if shadowRoot
@minimapView.getEditorViewRoot().appendChild(@dummyNode)
else
@editorView.appendChild(@dummyNode)

@getDummyDOMRoot(shadowRoot).appendChild(@dummyNode)

ensureCache: ->
@constructor.domStylesCache ?= {}

invalidateCache: ->
@constructor.domStylesCache = {}
Expand Down

0 comments on commit 17ba173

Please sign in to comment.