Skip to content

Commit

Permalink
fix: use DOMStylesReader as a class in MinimapElement
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 1, 2021
1 parent 2641ae6 commit a1c99e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const SPEC_MODE = atom.inSpecMode()
*/
class MinimapElement {
static initClass () {
include(this, DOMStylesReader, CanvasDrawer, EventsDelegation, AncestorsMethods)
include(this, CanvasDrawer, EventsDelegation, AncestorsMethods)
return element(this, 'atom-text-editor-minimap')
}

Expand Down Expand Up @@ -181,6 +181,11 @@ class MinimapElement {
*/
this.quickSettingsElement = undefined

/**
* This MinimapElement's DOMStylesReader
*/
this.DOMStylesReader = new DOMStylesReader()

// States

/**
Expand Down Expand Up @@ -389,7 +394,7 @@ class MinimapElement {
and the `change` event has not be triggered in the process.
*/
atom.styles.onDidAddStyleElement(() => {
this.invalidateDOMStylesCache()
this.DOMStylesReader.invalidateDOMStylesCache()
this.requestForcedUpdate()
}),

Expand Down
8 changes: 4 additions & 4 deletions spec/minimap-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('MinimapElement', () => {
describe('when a hue-rotate filter is applied to a rgb color', () => {
let [additionnalStyleNode] = []
beforeEach(() => {
minimapElement.invalidateDOMStylesCache()
minimapElement.DOMStylesReader.invalidateDOMStylesCache()

additionnalStyleNode = document.createElement('style')
additionnalStyleNode.textContent = `
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('MinimapElement', () => {
let [additionnalStyleNode] = []

beforeEach(() => {
minimapElement.invalidateDOMStylesCache()
minimapElement.DOMStylesReader.invalidateDOMStylesCache()

additionnalStyleNode = document.createElement('style')
additionnalStyleNode.textContent = `
Expand Down Expand Up @@ -1195,7 +1195,7 @@ describe('MinimapElement', () => {
runs(() => {
nextAnimationFrame()
spyOn(minimapElement, 'requestForcedUpdate').andCallThrough()
spyOn(minimapElement, 'invalidateDOMStylesCache').andCallThrough()
spyOn(minimapElement.DOMStylesReader, 'invalidateDOMStylesCache').andCallThrough()

const styleNode = document.createElement('style')
styleNode.textContent = 'body{ color: #233 }'
Expand All @@ -1209,7 +1209,7 @@ describe('MinimapElement', () => {

it('forces a refresh with cache invalidation', () => {
expect(minimapElement.requestForcedUpdate).toHaveBeenCalled()
expect(minimapElement.invalidateDOMStylesCache).toHaveBeenCalled()
expect(minimapElement.DOMStylesReader.invalidateDOMStylesCache).toHaveBeenCalled()
})
})

Expand Down

0 comments on commit a1c99e5

Please sign in to comment.