diff --git a/src/commands/view/ShowOffset.ts b/src/commands/view/ShowOffset.ts index 2f90c7d6e..a7953aadd 100644 --- a/src/commands/view/ShowOffset.ts +++ b/src/commands/view/ShowOffset.ts @@ -18,6 +18,10 @@ export default { const zoom = this.em.getZoomDecimal(); const el = opt.el as HTMLElement | undefined; + // if (!(el instanceof HTMLElement)) { + // return; + // } + if (!config.showOffsets || !el || isTextNode(el) || (!config.showOffsetsSelected && state == 'Fixed')) { editor.stopCommand(`${this.id}`, opts); return; diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 909ed0344..b99157769 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -37,6 +37,9 @@ export const attrUp = (el?: HTMLElement, attrs: ObjectAny = {}) => el && el.setAttribute && each(attrs, (value, key) => el.setAttribute(key, value)); export const isVisible = (el?: HTMLElement) => { + if (!el || !(el instanceof HTMLElement)) { + return false; + } return el && !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length); };