Skip to content

Commit

Permalink
🐛 Fix not update when user-styles reload, #303
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Mar 30, 2015
1 parent 94e02a9 commit af96175
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ class MinimapElement extends HTMLElement
@subscriptions = new CompositeDisposable
@initializeContent()

@subscriptions.add atom.themes.onDidChangeActiveThemes =>
# Uses of `atom.styles.onDidAddStyleElement` instead of
# `atom.themes.onDidChangeActiveThemes`.
# Why?
# Currently, The styleElement will be removed first,
# and then re-add. So the `change` event has not be triggered.
@subscriptions.add atom.styles.onDidAddStyleElement =>
@invalidateCache()
@requestForcedUpdate()

Expand Down
6 changes: 4 additions & 2 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,15 @@ describe 'MinimapElement', ->
# ## ## ## ## ## ### ## ## ## ##
# ###### ####### ## ## ## #### ######

describe 'when the atom themes are changed', ->
describe 'when the atom styles are changed', ->
beforeEach ->
nextAnimationFrame()
spyOn(minimapElement, 'requestForcedUpdate').andCallThrough()
spyOn(minimapElement, 'invalidateCache').andCallThrough()

atom.themes.emitter.emit 'did-change-active-themes'
styleNode = document.createElement('style')
styleNode.textContent = 'body{ color: #233; }'
atom.styles.emitter.emit 'did-add-style-element', styleNode

waitsFor -> minimapElement.frameRequested

Expand Down

1 comment on commit af96175

@abe33
Copy link
Contributor

@abe33 abe33 commented on af96175 Mar 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆗

Please sign in to comment.