Skip to content

Commit a83f9fd

Browse files
danielbariongabrieljablonski
authored andcommitted
chore: remove deprecated removeStyle util
1 parent 2e594c7 commit a83f9fd

File tree

3 files changed

+28
-36
lines changed

3 files changed

+28
-36
lines changed

src/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,3 @@ export type {
5050
Middleware,
5151
TooltipRefProps,
5252
}
53-
54-
export { removeStyle } from './utils/handle-style'

src/test/utils.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { debounce, deepEqual, computeTooltipPosition, cssTimeToMs, clearTimeoutRef } from 'utils'
2+
import { injectStyle } from 'utils/handle-style.ts'
23

34
describe('compute positions', () => {
45
test('empty reference elements', async () => {
@@ -272,3 +273,29 @@ describe('clearTimeoutRef', () => {
272273
expect(timeoutRef.current).toBe(null)
273274
})
274275
})
276+
277+
describe('handleStyle', () => {
278+
test('inject base styles with no CSS into the page', () => {
279+
injectStyle({ css: null, type: 'base' })
280+
281+
const styleElement = document.getElementById('react-tooltip-base-styles')
282+
283+
expect(styleElement).toBe(null)
284+
})
285+
286+
test('inject core styles into the page', () => {
287+
injectStyle({ css: `body { background: 'red' }`, type: 'core' })
288+
289+
const styleElement = document.getElementById('react-tooltip-core-styles')
290+
291+
expect(styleElement.innerHTML).toBe(`body { background: 'red' }`)
292+
})
293+
294+
test('inject base styles into the page', () => {
295+
injectStyle({ css: `body { background: 'red' }`, type: 'base' })
296+
297+
const styleElement = document.getElementById('react-tooltip-base-styles')
298+
299+
expect(styleElement.innerHTML).toBe(`body { background: 'red' }`)
300+
})
301+
})

src/utils/handle-style.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -81,37 +81,4 @@ function injectStyle({
8181
injected[type] = true
8282
}
8383

84-
/**
85-
* @deprecated Use the `disableStyleInjection` tooltip prop instead.
86-
* See https://react-tooltip.com/docs/examples/styling#disabling-reacttooltip-css
87-
*/
88-
function removeStyle({
89-
type = 'base',
90-
id = REACT_TOOLTIP_BASE_STYLES_ID,
91-
}: {
92-
type?: 'core' | 'base'
93-
id?: string
94-
} = {}) {
95-
if (!injected[type]) {
96-
return
97-
}
98-
99-
if (type === 'core') {
100-
// eslint-disable-next-line no-param-reassign
101-
id = REACT_TOOLTIP_CORE_STYLES_ID
102-
}
103-
104-
const style = document.getElementById(id)
105-
if (style?.tagName === 'style') {
106-
style?.remove()
107-
} else if (process.env.NODE_ENV !== 'production') {
108-
// eslint-disable-next-line no-console
109-
console.warn(
110-
`[react-tooltip] Failed to remove 'style' element with id '${id}'. Call \`injectStyle()\` first`,
111-
)
112-
}
113-
114-
injected[type] = false
115-
}
116-
117-
export { injectStyle, removeStyle }
84+
export { injectStyle }

0 commit comments

Comments
 (0)