Skip to content

Commit facbf0f

Browse files
committed
chore: remove deprecated removeStyle util
1 parent 2640ad7 commit facbf0f

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 } from 'utils'
2+
import { injectStyle } from 'utils/handle-style.ts'
23

34
describe('compute positions', () => {
45
test('empty reference elements', async () => {
@@ -256,3 +257,29 @@ describe('deepEqual', () => {
256257
expect(deepEqual(obj1, obj2)).toBe(false)
257258
})
258259
})
260+
261+
describe('handleStyle', () => {
262+
test('inject base styles with no CSS into the page', () => {
263+
injectStyle({ css: null, type: 'base' })
264+
265+
const styleElement = document.getElementById('react-tooltip-base-styles')
266+
267+
expect(styleElement).toBe(null)
268+
})
269+
270+
test('inject core styles into the page', () => {
271+
injectStyle({ css: `body { background: 'red' }`, type: 'core' })
272+
273+
const styleElement = document.getElementById('react-tooltip-core-styles')
274+
275+
expect(styleElement.innerHTML).toBe(`body { background: 'red' }`)
276+
})
277+
278+
test('inject base styles into the page', () => {
279+
injectStyle({ css: `body { background: 'red' }`, type: 'base' })
280+
281+
const styleElement = document.getElementById('react-tooltip-base-styles')
282+
283+
expect(styleElement.innerHTML).toBe(`body { background: 'red' }`)
284+
})
285+
})

src/utils/handle-style.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -87,37 +87,4 @@ function injectStyle({
8787
injected[type] = true
8888
}
8989

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

0 commit comments

Comments
 (0)