mirror of
https://github.com/titaniumnetwork-dev/Ultraviolet.git
synced 2025-05-15 20:40:01 -04:00
t
This commit is contained in:
parent
82f5f76588
commit
2c06fed426
25 changed files with 1131 additions and 604 deletions
|
@ -90,33 +90,4 @@ class JS extends EventEmitter {
|
|||
};
|
||||
};
|
||||
|
||||
class NodeEvent extends EventEmitter {
|
||||
constructor(node, parent = null) {
|
||||
super();
|
||||
this._node = node;
|
||||
for (let key in node) {
|
||||
Object.defineProperty(this, key, {
|
||||
get: () => node[key],
|
||||
sel: val => node[key] = val,
|
||||
});
|
||||
};
|
||||
this.parent = parent;
|
||||
};
|
||||
iterate(handler) {
|
||||
for (const key in this._node) {
|
||||
if (key === 'parent') continue;
|
||||
if (Array.isArray(this._node[key])) {
|
||||
this._node[key].forEach(entry => {
|
||||
const child = new this.constructor(entry, this._node);
|
||||
handler(child);
|
||||
});
|
||||
} else {
|
||||
const child = new this.constructor(entry, this._node);
|
||||
walk(this._node[key], this._node, handler);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export default JS;
|
||||
export { NodeEvent };
|
||||
export default JS;
|
Loading…
Add table
Add a link
Reference in a new issue