diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-11-10 18:41:23 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-11-10 18:41:23 +0100 |
| commit | bf1fef8933e090ec92dbb04c66f9c868044c242f (patch) | |
| tree | edb96ae970a131771f914c6de9ba7e188961d6a5 /element/native.js | |
init commit
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); |