Skip to content

Commit d6cc262

Browse files
authored
refactor: replement deprecated fields (#7519)
1 parent 9d7c171 commit d6cc262

File tree

23 files changed

+30
-45
lines changed

23 files changed

+30
-45
lines changed

antd-tools/generator-types/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ async function readMarkdown(options: Options): Promise<Map<String, VueTag>> {
2121
return formatter(mdParser(fileContent), componentName, kebabComponentName, options.tagPrefix);
2222
})
2323
.filter(item => item) as VueTag[][];
24-
const tags: Map<String, VueTag> = new Map();
24+
const tags = new Map<String, VueTag>();
2525
flatMap(data, item => item).forEach(mergedTag => mergeTag(tags, mergedTag));
2626
return tags;
2727
}
2828

2929
function readTypings(options: Options): Map<String, VueTag> {
30-
const tags: Map<String, VueTag> = new Map();
30+
const tags = new Map<String, VueTag>();
3131
const fileContent = readFileSync(options.typingsPath, 'utf-8');
3232
fileContent
3333
.split('\n')
@@ -61,7 +61,7 @@ function mergeTag(tags: Map<String, VueTag>, mergedTag: VueTag) {
6161

6262
function mergeTags(mergedTagsArr: Map<String, VueTag>[]): VueTag[] {
6363
if (mergedTagsArr.length === 1) return [...mergedTagsArr[0].values()];
64-
const tags: Map<String, VueTag> = new Map();
64+
const tags = new Map<String, VueTag>();
6565
if (mergedTagsArr.length === 0) return [];
6666
mergedTagsArr.forEach(mergedTags => {
6767
mergedTags.forEach(mergedTag => mergeTag(tags, mergedTag));

antd-tools/generator-types/src/parser.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type Articals = Artical[];
2121
function readLine(input: string) {
2222
const end = input.indexOf('\n');
2323

24-
return input.substr(0, end !== -1 ? end : input.length);
24+
return input.substring(0, end !== -1 ? end : input.length);
2525
}
2626

2727
function splitTableLine(line: string) {
@@ -47,7 +47,7 @@ function tableParse(input: string) {
4747
};
4848

4949
while (start < end) {
50-
const target = input.substr(start);
50+
const target = input.substring(start);
5151
const line = readLine(target);
5252

5353
if (!/^\|/.test(target)) {
@@ -79,7 +79,7 @@ export function mdParser(input: string): Articals {
7979
const end = input.length;
8080

8181
while (start < end) {
82-
const target = input.substr(start);
82+
const target = input.substring(start);
8383

8484
let match;
8585
if ((match = TITLE_REG.exec(target))) {
@@ -91,7 +91,7 @@ export function mdParser(input: string): Articals {
9191

9292
start += match.index + match[0].length;
9393
} else if ((match = TABLE_REG.exec(target))) {
94-
const { table, usedLength } = tableParse(target.substr(match.index));
94+
const { table, usedLength } = tableParse(target.substring(match.index));
9595
artical.push({
9696
type: 'table',
9797
table,

antd-tools/getTSCommonConfig.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
'use strict';
22

33
const fs = require('fs');
4-
const assign = require('object-assign');
54
const { getProjectPath } = require('./utils/projectHelper');
65

76
module.exports = function () {
87
let my = {};
98
if (fs.existsSync(getProjectPath('tsconfig.json'))) {
109
my = require(getProjectPath('tsconfig.json'));
1110
}
12-
return assign(
11+
return Object.assign(
1312
{
1413
noUnusedParameters: true,
1514
noUnusedLocals: true,

components/_util/getScroll.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function getScroll(
1212
const method = top ? 'scrollTop' : 'scrollLeft';
1313
let result = 0;
1414
if (isWindow(target)) {
15-
result = target[top ? 'pageYOffset' : 'pageXOffset'];
15+
result = target[top ? 'scrollY' : 'scrollX'];
1616
} else if (target instanceof Document) {
1717
result = target.documentElement[method];
1818
} else if (target instanceof HTMLElement) {

components/_util/scrollTo.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export default function scrollTo(y: number, options: ScrollToOptions = {}) {
2222
const time = timestamp - startTime;
2323
const nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration);
2424
if (isWindow(container)) {
25-
(container as Window).scrollTo(window.pageXOffset, nextScrollTop);
26-
} else if (container instanceof Document || container.constructor.name === 'HTMLDocument') {
25+
(container as Window).scrollTo(window.scrollX, nextScrollTop);
26+
} else if (container instanceof Document) {
2727
(container as Document).documentElement.scrollTop = nextScrollTop;
2828
} else {
2929
(container as HTMLElement).scrollTop = nextScrollTop;

components/_util/triggerEvent.ts

-8
This file was deleted.

components/checkbox/Group.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default defineComponent({
4141
});
4242
});
4343
const triggerUpdate = ref(Symbol());
44-
const registeredValuesMap = ref<Map<Symbol, string>>(new Map());
44+
const registeredValuesMap = ref(new Map<Symbol, string>());
4545
const cancelValue = (id: Symbol) => {
4646
registeredValuesMap.value.delete(id);
4747
triggerUpdate.value = Symbol();

components/menu/src/Menu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default defineComponent({
112112
return !override;
113113
}),
114114
);
115-
const store = shallowRef<Map<string, StoreMenuInfo>>(new Map());
115+
const store = shallowRef(new Map<string, StoreMenuInfo>());
116116
const siderCollapsed = inject(SiderCollapsedKey, ref(undefined));
117117
const inlineCollapsed = computed(() => {
118118
if (siderCollapsed.value !== undefined) {

components/menu/src/hooks/useItems.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function convertItemsToNodes(
116116
export default function useItems(props: MenuProps) {
117117
const itemsNodes = shallowRef([]);
118118
const hasItmes = shallowRef(false);
119-
const store = shallowRef<Map<string, StoreMenuInfo>>(new Map());
119+
const store = shallowRef(new Map<string, StoreMenuInfo>());
120120
watch(
121121
() => props.items,
122122
() => {

components/rate/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function getScroll(w: Window) {
2-
let ret = w.pageXOffset;
2+
let ret = w.scrollX;
33
const method = 'scrollLeft';
44
if (typeof ret !== 'number') {
55
const d = w.document;

components/tree/demo/search.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Searchable Tree.
2727
>
2828
<template #title="{ title }">
2929
<span v-if="title.indexOf(searchValue) > -1">
30-
{{ title.substr(0, title.indexOf(searchValue)) }}
30+
{{ title.substring(0, title.indexOf(searchValue)) }}
3131
<span style="color: #f50">{{ searchValue }}</span>
32-
{{ title.substr(title.indexOf(searchValue) + searchValue.length) }}
32+
{{ title.substring(title.indexOf(searchValue) + searchValue.length) }}
3333
</span>
3434
<span v-else>{{ title }}</span>
3535
</template>

components/vc-image/src/PreviewGroup.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const Group = defineComponent({
9595
? mergeDefaultValue(props.preview, defaultValues)
9696
: defaultValues;
9797
});
98-
const previewUrls = reactive<Map<number, PreviewUrl>>(new Map());
98+
const previewUrls = reactive(new Map<number, PreviewUrl>());
9999
const current = ref<number>();
100100

101101
const previewVisible = computed(() => preview.value.visible);

components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default defineComponent<TimeUnitColumnProps>({
2525
const { open } = useInjectPanel();
2626

2727
const ulRef = shallowRef<HTMLElement>(null);
28-
const liRefs = ref<Map<number, HTMLElement | null>>(new Map());
28+
const liRefs = ref(new Map<number, HTMLElement | null>());
2929
const scrollRef = ref<Function>();
3030

3131
watch(

components/vc-slider/src/common/createSlider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export default function createSlider(Component) {
210210
if (vertical) {
211211
return reverse ? rect.bottom : rect.top;
212212
}
213-
return window.pageXOffset + (reverse ? rect.right : rect.left);
213+
return window.scrollX + (reverse ? rect.right : rect.left);
214214
},
215215
getSliderLength() {
216216
const slider = this.sliderRef;

components/vc-slider/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function getHandleCenterPosition(vertical: boolean, handle: HTMLElement)
5858
const coords = handle.getBoundingClientRect();
5959
return vertical
6060
? coords.top + coords.height * 0.5
61-
: window.pageXOffset + coords.left + coords.width * 0.5;
61+
: window.scrollX + coords.left + coords.width * 0.5;
6262
}
6363

6464
export function ensureValueInRange(val: number, { max, min }: { max?: number; min?: number }) {

components/vc-tree-select/hooks/useDataEntities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { shallowRef, watchEffect } from 'vue';
88
import { warning } from '../../vc-util/warning';
99

1010
export default (treeData: ShallowRef<any>, fieldNames: Ref<FieldNames>) => {
11-
const valueEntities = shallowRef<Map<RawValueType, DataEntity>>(new Map());
11+
const valueEntities = shallowRef(new Map<RawValueType, DataEntity>());
1212
const keyEntities = shallowRef<Record<string, DataEntity>>({});
1313
watchEffect(() => {
1414
const fieldNamesValue = fieldNames.value;

components/vc-tree/utils/treeUtil.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function fillFieldNames(fieldNames?: FieldNames): Required<FieldNames> {
4040
* Warning if TreeNode do not provides key
4141
*/
4242
export function warningWithoutKey(treeData: DataNode[], fieldNames: FieldNames) {
43-
const keys: Map<string, boolean> = new Map();
43+
const keys = new Map<string, boolean>();
4444

4545
function dig(list: DataNode[], path = '') {
4646
(list || []).forEach(treeNode => {

components/vc-util/Dom/css.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,14 @@ export function getOffset(node: any) {
101101
const box = node.getBoundingClientRect();
102102
const docElem = document.documentElement;
103103

104-
// < ie8 不支持 win.pageXOffset, 则使用 docElem.scrollLeft
105104
return {
106105
left:
107106
box.left +
108-
(window.pageXOffset || docElem.scrollLeft) -
107+
(window.scrollX || docElem.scrollLeft) -
109108
(docElem.clientLeft || document.body.clientLeft || 0),
110109
top:
111110
box.top +
112-
(window.pageYOffset || docElem.scrollTop) -
111+
(window.scrollY || docElem.scrollTop) -
113112
(docElem.clientTop || document.body.clientTop || 0),
114113
};
115114
}

components/vc-util/isMobile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default () => {
99
agent,
1010
) ||
1111
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(
12-
agent?.substr(0, 4),
12+
agent?.substring(0, 4),
1313
)
1414
);
1515
};

package.json

-5
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@
216216
"mockdate": "^2.0.2",
217217
"moment": "^2.29.1",
218218
"nprogress": "^0.2.0",
219-
"object-assign": "^4.1.1",
220219
"postcss": "^8.2.12",
221220
"postcss-loader": "^6.0.0",
222221
"prettier": "^2.2.0",
@@ -308,10 +307,6 @@
308307
"dist/*",
309308
"*.css"
310309
],
311-
"vetur": {
312-
"tags": "vetur/tags.json",
313-
"attributes": "vetur/attributes.json"
314-
},
315310
"config": {
316311
"commitizen": {
317312
"path": "node_modules/cz-git",

site/src/components/vue-colorful/components/common/Interactive.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const getRelativePosition = (
3636
const pointer = isTouch(event) ? getTouchPoint(event.touches, touchId) : (event as MouseEvent);
3737

3838
return {
39-
left: clamp((pointer.pageX - (rect.left + getParentWindow(node).pageXOffset)) / rect.width),
40-
top: clamp((pointer.pageY - (rect.top + getParentWindow(node).pageYOffset)) / rect.height),
39+
left: clamp((pointer.pageX - (rect.left + getParentWindow(node).scrollX)) / rect.width),
40+
top: clamp((pointer.pageY - (rect.top + getParentWindow(node).scrollY)) / rect.height),
4141
};
4242
};
4343

site/src/components/vue-colorful/hooks/useStyleSheet.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getNonce } from '../utils/nonce';
66
// Bundler is configured to load this as a processed minified CSS-string
77
import styles from '../css/styles.css';
88

9-
const styleElementMap: Map<Document, HTMLStyleElement> = new Map();
9+
const styleElementMap = new Map<Document, HTMLStyleElement>();
1010

1111
/**
1212
* Injects CSS code into the document's <head>

site/src/layouts/header/Menu.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default defineComponent({
5656
location: { pathname },
5757
} = window;
5858
const currentProtocol = `${window.location.protocol}//`;
59-
const currentHref = window.location.href.substr(currentProtocol.length);
59+
const currentHref = window.location.href.substring(currentProtocol.length);
6060
6161
if (isLocalStorageNameSupported()) {
6262
localStorage.setItem('locale', isZhCN(pathname) ? 'en-US' : 'zh-CN');

0 commit comments

Comments
 (0)