Skip to content

Commit 65fc82e

Browse files
committed
fix: remove window
1 parent 0dd6065 commit 65fc82e

File tree

21 files changed

+44
-113
lines changed

21 files changed

+44
-113
lines changed

components/_util/css-animation/Event.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const TransitionEvents = {
8787

8888
addStartEventListener(node, eventListener) {
8989
if (startEvents.length === 0) {
90-
window.setTimeout(eventListener, 0);
90+
setTimeout(eventListener, 0);
9191
return;
9292
}
9393
startEvents.forEach(startEvent => {
@@ -109,7 +109,7 @@ const TransitionEvents = {
109109

110110
addEndEventListener(node, eventListener) {
111111
if (endEvents.length === 0) {
112-
window.setTimeout(eventListener, 0);
112+
setTimeout(eventListener, 0);
113113
return;
114114
}
115115
endEvents.forEach(endEvent => {

components/_util/css-animation/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Event from './Event';
44
import classes from '../component-classes';
55
import { requestAnimationTimeout, cancelAnimationTimeout } from '../requestAnimationTimeout';
6+
import { inBrowser } from '../env';
67

78
const isCssAnimationSupported = Event.endEvents.length !== 0;
89
const capitalPrefixes = [
@@ -15,6 +16,7 @@ const capitalPrefixes = [
1516
const prefixes = ['-webkit-', '-moz-', '-o-', 'ms-', ''];
1617

1718
function getStyleProperty(node, name) {
19+
if (inBrowser) return '';
1820
// old ff need null, https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
1921
const style = window.getComputedStyle(node, null);
2022
let ret = '';

components/_util/dom-closest.js

-24
This file was deleted.

components/_util/dom-matches.js

-47
This file was deleted.

components/_util/transition.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const collapseMotion = (style: Ref<CSSProperties>, className: Ref<string>): CSSM
147147
style.value = getCurrentHeight(node);
148148
},
149149
onLeave: node => {
150-
window.setTimeout(() => {
150+
setTimeout(() => {
151151
style.value = getCollapsedHeight(node);
152152
});
153153
},

components/_util/wave.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export default defineComponent({
129129
getComputedStyle(node).getPropertyValue('border-top-color') || // Firefox Compatible
130130
getComputedStyle(node).getPropertyValue('border-color') ||
131131
getComputedStyle(node).getPropertyValue('background-color');
132-
this.clickWaveTimeoutId = window.setTimeout(() => this.onClick(node, waveColor), 0);
132+
this.clickWaveTimeoutId = setTimeout(() => this.onClick(node, waveColor), 0);
133133
raf.cancel(this.animationStartId);
134134
this.animationStart = true;
135135

components/button/button.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default defineComponent({
6060
val => {
6161
clearTimeout(delayTimeoutRef.value);
6262
if (typeof loadingOrDelay.value === 'number') {
63-
delayTimeoutRef.value = window.setTimeout(() => {
63+
delayTimeoutRef.value = setTimeout(() => {
6464
innerLoading.value = val;
6565
}, loadingOrDelay.value);
6666
} else {

components/form/ErrorList.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ export default defineComponent({
2424
const timeout = ref();
2525
const cacheErrors = ref([...props.errors]);
2626
watch([() => [...props.errors], () => props.help], newValues => {
27-
window.clearTimeout(timeout.value);
27+
clearTimeout(timeout.value);
2828
if (props.help) {
2929
visible.value = !!(props.errors && props.errors.length);
3030
if (visible.value) {
3131
cacheErrors.value = newValues[0];
3232
}
3333
} else {
34-
timeout.value = window.setTimeout(() => {
34+
timeout.value = setTimeout(() => {
3535
visible.value = !!(props.errors && props.errors.length);
3636
if (visible.value) {
3737
cacheErrors.value = newValues[0];
@@ -40,7 +40,7 @@ export default defineComponent({
4040
}
4141
});
4242
onBeforeUnmount(() => {
43-
window.clearTimeout(timeout.value);
43+
clearTimeout(timeout.value);
4444
});
4545
// Memo status in same visible
4646
watch([visible, status], () => {

components/menu/src/Menu.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ export default defineComponent({
214214
{ immediate: true },
215215
);
216216

217-
let timeout: number;
217+
let timeout: any;
218218
const changeActiveKeys = (keys: Key[]) => {
219-
window.clearTimeout(timeout);
220-
timeout = window.setTimeout(() => {
219+
clearTimeout(timeout);
220+
timeout = setTimeout(() => {
221221
if (props.activeKey === undefined) {
222222
activeKeys.value = keys;
223223
}

components/statistic/Countdown.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default defineComponent({
1717
}),
1818
emits: ['finish', 'change'],
1919
setup(props, { emit }) {
20-
const countdownId = ref<number>();
20+
const countdownId = ref<any>();
2121
const statistic = ref();
2222
const syncTimer = () => {
2323
const { value } = props;
@@ -32,7 +32,7 @@ export default defineComponent({
3232
const startTimer = () => {
3333
if (countdownId.value) return;
3434
const timestamp = getTime(props.value);
35-
countdownId.value = window.setInterval(() => {
35+
countdownId.value = setInterval(() => {
3636
statistic.value.$forceUpdate();
3737
if (timestamp > Date.now()) {
3838
emit('change', timestamp - Date.now());

components/table/hooks/useFilter/FilterDropdown.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,16 @@ export default defineComponent<FilterDropdownProps<any>>({
181181
const openRef = ref();
182182

183183
const onOpenChange = (keys: string[]) => {
184-
openRef.value = window.setTimeout(() => {
184+
openRef.value = setTimeout(() => {
185185
openKeys.value = keys;
186186
});
187187
};
188188
const onMenuClick = () => {
189-
window.clearTimeout(openRef.value);
189+
clearTimeout(openRef.value);
190190
};
191191

192192
onBeforeUnmount(() => {
193-
window.clearTimeout(openRef.value);
193+
clearTimeout(openRef.value);
194194
});
195195

196196
// ======================= Submit ========================

components/tabs/src/TabNavList/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ export default defineComponent({
129129
};
130130

131131
// ========================= Mobile ========================
132-
const touchMovingRef = ref<number>();
132+
const touchMovingRef = ref<any>();
133133
const [lockAnimation, setLockAnimation] = useState<number>();
134134

135135
const doLockAnimation = () => {
136136
setLockAnimation(Date.now());
137137
};
138138

139139
const clearTouchMoving = () => {
140-
window.clearTimeout(touchMovingRef.value);
140+
clearTimeout(touchMovingRef.value);
141141
};
142142
const doMove = (setState: (fn: (val: number) => number) => void, offset: number) => {
143143
setState((value: number) => {
@@ -171,7 +171,7 @@ export default defineComponent({
171171
watch(lockAnimation, () => {
172172
clearTouchMoving();
173173
if (lockAnimation.value) {
174-
touchMovingRef.value = window.setTimeout(() => {
174+
touchMovingRef.value = setTimeout(() => {
175175
setLockAnimation(0);
176176
}, 100);
177177
}

components/tabs/src/hooks/useTouchMove.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ export default function useTouchMove(
1818
const [lastTimestamp, setLastTimestamp] = useState<number>(0);
1919
const [lastTimeDiff, setLastTimeDiff] = useState<number>(0);
2020
const [lastOffset, setLastOffset] = useState<{ x: number; y: number }>();
21-
const motionRef = ref<number>();
21+
const motionInterval = ref<any>();
2222

2323
// ========================= Events =========================
2424
// >>> Touch events
2525
function onTouchStart(e: TouchEvent) {
2626
const { screenX, screenY } = e.touches[0];
2727
setTouchPosition({ x: screenX, y: screenY });
28-
window.clearInterval(motionRef.value);
28+
clearInterval(motionInterval.value);
2929
}
3030

3131
function onTouchMove(e: TouchEvent) {
@@ -62,9 +62,9 @@ export default function useTouchMove(
6262
let currentX = distanceX;
6363
let currentY = distanceY;
6464

65-
motionRef.value = window.setInterval(() => {
65+
motionInterval.value = setInterval(() => {
6666
if (Math.abs(currentX) < STOP_SWIPE_DISTANCE && Math.abs(currentY) < STOP_SWIPE_DISTANCE) {
67-
window.clearInterval(motionRef.value);
67+
clearInterval(motionInterval.value);
6868
return;
6969
}
7070

components/typography/Base.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const Base = defineComponent<InternalBlockProps>({
139139
});
140140

141141
onBeforeUnmount(() => {
142-
window.clearTimeout(state.copyId);
142+
clearTimeout(state.copyId);
143143
raf.cancel(state.rafId);
144144
});
145145

@@ -223,7 +223,7 @@ const Base = defineComponent<InternalBlockProps>({
223223
copyConfig.onCopy();
224224
}
225225

226-
state.copyId = window.setTimeout(() => {
226+
state.copyId = setTimeout(() => {
227227
state.copied = false;
228228
}, 3000);
229229
});

components/vc-align/hooks/useBuffer.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default (callback: () => boolean, buffer: ComputedRef<number>) => {
55
let timeout = null;
66

77
function cancelTrigger() {
8-
window.clearTimeout(timeout);
8+
clearTimeout(timeout);
99
}
1010

1111
function trigger(force?: boolean) {
@@ -17,12 +17,12 @@ export default (callback: () => boolean, buffer: ComputedRef<number>) => {
1717

1818
called = true;
1919
cancelTrigger();
20-
timeout = window.setTimeout(() => {
20+
timeout = setTimeout(() => {
2121
called = false;
2222
}, buffer.value);
2323
} else {
2424
cancelTrigger();
25-
timeout = window.setTimeout(() => {
25+
timeout = setTimeout(() => {
2626
called = false;
2727
trigger();
2828
}, buffer.value);

components/vc-mentions/src/Mentions.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ export default defineComponent({
173173
onBlur(event);
174174
};
175175
const onFocus = (event: Event) => {
176-
window.clearTimeout(focusId.value);
176+
clearTimeout(focusId.value);
177177
const { isFocus } = state;
178178
if (!isFocus && event) {
179179
emit('focus', event);
180180
}
181181
state.isFocus = true;
182182
};
183183
const onBlur = (event: Event) => {
184-
focusId.value = window.setTimeout(() => {
184+
focusId.value = setTimeout(() => {
185185
state.isFocus = false;
186186
stopMeasure();
187187
emit('blur', event);

components/vc-picker/RangePicker.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ function RangerPicker<DateType>() {
395395
function triggerOpenAndFocus(index: 0 | 1) {
396396
triggerOpen(true, index);
397397
// Use setTimeout to make sure panel DOM exists
398-
window.setTimeout(() => {
398+
setTimeout(() => {
399399
const inputRef = [startInputRef, endInputRef][index];
400400
if (inputRef.value) {
401401
inputRef.value.focus();

components/vc-select/hooks/useDelayReset.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ export default function useDelayReset(
99
timeout = 10,
1010
): [Ref<Boolean>, (val: boolean, callback?: () => void) => void, () => void] {
1111
const bool = ref(false);
12-
let delay: number;
12+
let delay: any;
1313

1414
const cancelLatest = () => {
15-
window.clearTimeout(delay);
15+
clearTimeout(delay);
1616
};
1717

1818
onMounted(() => {
1919
cancelLatest();
2020
});
2121
const delaySetBool = (value: boolean, callback: () => void) => {
2222
cancelLatest();
23-
delay = window.setTimeout(() => {
23+
delay = setTimeout(() => {
2424
bool.value = value;
2525
if (callback) {
2626
callback();

components/vc-select/hooks/useLock.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import { onBeforeUpdate } from 'vue';
88
*/
99
export default function useLock(duration = 250): [() => boolean | null, (lock: boolean) => void] {
1010
let lock: boolean | null = null;
11-
let timeout: number;
11+
let timeout: any;
1212

1313
onBeforeUpdate(() => {
14-
window.clearTimeout(timeout);
14+
clearTimeout(timeout);
1515
});
1616

1717
function doLock(locked: boolean) {
1818
if (locked || lock === null) {
1919
lock = locked;
2020
}
2121

22-
window.clearTimeout(timeout);
23-
timeout = window.setTimeout(() => {
22+
clearTimeout(timeout);
23+
timeout = setTimeout(() => {
2424
lock = null;
2525
}, duration);
2626
}

0 commit comments

Comments
 (0)