Skip to content

Commit 65858bf

Browse files
committed
chore(ui-codemods): add codemod to rename getComputedStyle to getCSSStyleDeclaration
INSTUI-4626
1 parent 028e93a commit 65858bf

21 files changed

+444
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// @ts-nocheck
2+
3+
// test for basic import renaming
4+
import { getComputedStyle } from '@instructure/ui-dom-utils'
5+
6+
function test() {
7+
const oldStyles = getComputedStyle(element)
8+
const newStyles = getCSSStyleDeclaration(element)
9+
10+
document.defaultView.getComputedStyle(element)
11+
12+
window.getComputedStyle()
13+
14+
getComputedStyle(element, ':before')
15+
16+
registerFunction(getComputedStyle)
17+
18+
return getComputedStyle()
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// @ts-nocheck
2+
3+
// test for basic import renaming
4+
import { getCSSStyleDeclaration } from '@instructure/ui-dom-utils'
5+
6+
function test() {
7+
const oldStyles = getCSSStyleDeclaration(element)
8+
const newStyles = getCSSStyleDeclaration(element)
9+
10+
document.defaultView.getComputedStyle(element)
11+
12+
window.getComputedStyle()
13+
14+
getCSSStyleDeclaration(element, ':before')
15+
16+
registerFunction(getCSSStyleDeclaration)
17+
18+
return getCSSStyleDeclaration()
19+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @ts-nocheck
2+
3+
import { getComputedStyle as getStyle } from '@instructure/ui-dom-utils'
4+
5+
function test() {
6+
const styles = getStyle(element)
7+
window.getComputedStyle()
8+
getComputedStyle()
9+
10+
obj.getComputedStyle(element)
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @ts-nocheck
2+
3+
import { getCSSStyleDeclaration as getStyle } from '@instructure/ui-dom-utils'
4+
5+
function test() {
6+
const styles = getStyle(element)
7+
window.getComputedStyle()
8+
getComputedStyle()
9+
10+
obj.getComputedStyle(element)
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @ts-nocheck
2+
3+
import { getComputedStyle, otherFunc } from '@instructure/ui-dom-utils'
4+
5+
function test() {
6+
const oldStyles = getComputedStyle(element)
7+
const newStyles = getCSSStyleDeclaration(element)
8+
window.getComputedStyle()
9+
return getComputedStyle()
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @ts-nocheck
2+
3+
import { getCSSStyleDeclaration, otherFunc } from '@instructure/ui-dom-utils'
4+
5+
function test() {
6+
const oldStyles = getCSSStyleDeclaration(element)
7+
const newStyles = getCSSStyleDeclaration(element)
8+
window.getComputedStyle()
9+
return getCSSStyleDeclaration()
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @ts-nocheck
2+
3+
import { getComputedStyle } from '@instructure/ui-dom-utils'
4+
5+
function test() {
6+
const getComputedStyle = () => {}
7+
return getComputedStyle(element)
8+
}
9+
10+
getComputedStyle()
11+
const styles = getComputedStyle<HTMLElement>(element)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @ts-nocheck
2+
3+
import { getCSSStyleDeclaration } from '@instructure/ui-dom-utils'
4+
5+
function test() {
6+
const getComputedStyle = () => {}
7+
return getComputedStyle(element)
8+
}
9+
10+
getCSSStyleDeclaration()
11+
const styles = getCSSStyleDeclaration<HTMLElement>(element)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @ts-nocheck
2+
3+
import { getComputedStyle } from '@instructure/ui-dom-utils'
4+
5+
function test() {
6+
const styleFunc = getComputedStyle
7+
return styleFunc(element)
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @ts-nocheck
2+
3+
import { getCSSStyleDeclaration } from '@instructure/ui-dom-utils'
4+
5+
function test() {
6+
const styleFunc = getCSSStyleDeclaration
7+
return styleFunc(element)
8+
}

0 commit comments

Comments
 (0)