Make domLense error on non-element targets

This commit is contained in:
Talia 2024-01-24 15:06:12 +01:00
parent 44b6343de6
commit 1c03da8815

View file

@ -12,8 +12,6 @@ class ChildObserver extends MutationObserver {
} }
} }
const childObserver = new ChildObserver()
export const lense = (methods, extra) => { export const lense = (methods, extra) => {
if (extra) return lense(extra)(methods) if (extra) return lense(extra)(methods)
@ -70,7 +68,10 @@ export const lense = (methods, extra) => {
} }
} }
return element => new Proxy(element, traps) return element => {
if (!(element instanceof Element)) throw(new Error("Creating domLense on non-element"))
return new Proxy(element, traps)
}
} }
export default lense export default lense