From 59f4ba669f995843701627a03cf5aad91ee8e2c2 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Wed, 4 Aug 2021 17:00:00 +0200 Subject: [PATCH] Add `has` metamethod to proxies This change allows proxies to be used with `with` for easier HTML/SVG generation. --- skooma.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skooma.js b/skooma.js index df0363b..d155b4c 100644 --- a/skooma.js +++ b/skooma.js @@ -49,7 +49,10 @@ const node = (name, args, options) => { return element } -const nameSpacedProxy = (options={}) => new Proxy(Window, { get: (target, prop, receiver) => { return (...args) => node(prop, args, options) }}) +const nameSpacedProxy = (options={}) => new Proxy(Window, { + get: (target, prop, receiver) => { return (...args) => node(prop, args, options) }, + has: (target, prop) => true, +}) export const html = nameSpacedProxy({nameFilter: name => name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}) export const svg = nameSpacedProxy({xmlns: "http://www.w3.org/2000/svg"})