aboutsummaryrefslogtreecommitdiff
path: root/element/native.js
blob: f68add007f0d31df6972c06920217b6e7ada61a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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);