Skip to content

Commit

Permalink
Correctly detect elements coming from different realms
Browse files Browse the repository at this point in the history
This does not support elements coming from a third realm, different from the one we are running and the one the document belongs to, but this is even less common than having to deal with crossrealm elements to begin with. (And impossible on Firefox)
  • Loading branch information
edave64 committed Jul 18, 2024
1 parent 3d0b71c commit 2c46366
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 2c46366

Please sign in to comment.