diff options
Diffstat (limited to 'element/native.js')
| -rw-r--r-- | element/native.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/element/native.js b/element/native.js new file mode 100644 index 0000000..f68add0 --- /dev/null +++ b/element/native.js @@ -0,0 +1,34 @@ +import { create as create_element } from './index.js' + +class Native { + constructor(tag) { + this.tag = tag; + } + + new(options) { + const children = options?.children ?? [] + + if (options) { + delete options.children; + } + + const element = create_element(this.tag, options); + + children.forEach(child => { + element.append(child); + }) + + return element; + } +} + + +const target = {}; + +const handler = { + get(target, prop, receiver) { + return new Native(prop); + } +}; + +export const native = new Proxy(target, handler); |