diff --git a/packages/stage/src/MoveableOptionsManager.ts b/packages/stage/src/MoveableOptionsManager.ts index df863c6bc..256c2f4ae 100644 --- a/packages/stage/src/MoveableOptionsManager.ts +++ b/packages/stage/src/MoveableOptionsManager.ts @@ -90,7 +90,7 @@ export default class MoveableOptionsManager extends EventEmitter { * @param selectedElList 选中的元素列表,需要排除在对齐元素之外 * @param allElList 全部元素列表 */ - protected setElementGuidelines(selectedElList: HTMLElement[], allElList: HTMLElement[]): void { + protected setElementGuidelines(selectedElList: HTMLElement[], allElList: Element[]): void { this.elementGuidelines.forEach((node) => { node.remove(); }); @@ -224,7 +224,7 @@ export default class MoveableOptionsManager extends EventEmitter { * @param allElList 全部元素列表 * @returns frame 辅助对齐元素集合的页面片 */ - private createGuidelineElements(selectedElList: HTMLElement[], allElList: HTMLElement[]): DocumentFragment { + private createGuidelineElements(selectedElList: HTMLElement[], allElList: Element[]): DocumentFragment { const frame = globalThis.document.createDocumentFragment(); for (const node of allElList) { @@ -246,7 +246,7 @@ export default class MoveableOptionsManager extends EventEmitter { * @param eleList 元素列表 * @returns 是否在元素列表里面 */ - private isInElementList(ele: HTMLElement, eleList: HTMLElement[]): boolean { + private isInElementList(ele: Element, eleList: Element[]): boolean { for (const eleItem of eleList) { if (ele === eleItem) return true; } diff --git a/packages/stage/src/StageDragResize.ts b/packages/stage/src/StageDragResize.ts index f5397eb21..70acef51e 100644 --- a/packages/stage/src/StageDragResize.ts +++ b/packages/stage/src/StageDragResize.ts @@ -132,7 +132,7 @@ export default class StageDragResize extends MoveableOptionsManager { this.dragResizeHelper.setMode(this.mode); // 设置选中元素的周围元素,用于选中元素跟周围元素对齐辅助 - const elementGuidelines: HTMLElement[] = Array.prototype.slice.call(this.target?.parentElement?.children) || []; + const elementGuidelines: Element[] = Array.from(this.target?.parentElement?.children || []); this.setElementGuidelines([this.target as HTMLElement], elementGuidelines); return this.getOptions(false, { diff --git a/packages/stage/src/StageMultiDragResize.ts b/packages/stage/src/StageMultiDragResize.ts index 77fbc575a..5f81e3341 100644 --- a/packages/stage/src/StageMultiDragResize.ts +++ b/packages/stage/src/StageMultiDragResize.ts @@ -80,8 +80,7 @@ export default class StageMultiDragResize extends MoveableOptionsManager { this.dragResizeHelper.updateGroup(els); // 设置周围元素,用于选中元素跟周围元素的对齐辅助 - const elementGuidelines: HTMLElement[] = - Array.prototype.slice.call(this.targetList[0].parentElement?.children) || []; + const elementGuidelines: Element[] = Array.from(this.targetList[0].parentElement?.children || []); this.setElementGuidelines(this.targetList, elementGuidelines); this.moveableForMulti?.destroy(); diff --git a/packages/stage/src/util.ts b/packages/stage/src/util.ts index 63a557079..ea443a59e 100644 --- a/packages/stage/src/util.ts +++ b/packages/stage/src/util.ts @@ -30,7 +30,7 @@ const getParents = (el: Element, relative: Element) => { return parents; }; -export const getOffset = (el: TargetElement): Offset => { +export const getOffset = (el: Element): Offset => { const htmlEl = el as HTMLElement; const { offsetParent } = htmlEl;