diff --git a/src/blot/abstract/parent.ts b/src/blot/abstract/parent.ts index 2b1c5fd..c8ea687 100644 --- a/src/blot/abstract/parent.ts +++ b/src/blot/abstract/parent.ts @@ -351,7 +351,7 @@ class ParentBlot extends ShadowBlot implements Parent { node.parentNode != null && // @ts-expect-error Fix me later node.tagName !== 'IFRAME' && - document.body.compareDocumentPosition(node) & + (node.ownerDocument ?? document).body.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY ) { return; diff --git a/src/registry.ts b/src/registry.ts index 45cc4ec..6092a30 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -83,7 +83,11 @@ export default class Registry implements RegistryInterface { } else if (query & Scope.LEVEL & Scope.INLINE) { match = this.types.inline; } - } else if (query instanceof Element) { + } else if ( + query instanceof HTMLElement || + query instanceof + (query.ownerDocument?.defaultView?.HTMLElement ?? HTMLElement) + ) { const names = (query.getAttribute('class') || '').split(/\s+/); names.some((name) => { match = this.classes[name];