apprun 3.33.0 → 3.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/component.ts CHANGED
@@ -43,29 +43,29 @@ export class Component<T = any, E = any> {
43
43
  const el = (typeof this.element === 'string' && this.element) ?
44
44
  document.getElementById(this.element) || document.querySelector(this.element) : this.element;
45
45
 
46
- if (el) {
47
- const tracking_attr = '_c';
48
- if (!this.unload) {
49
- el.removeAttribute && el.removeAttribute(tracking_attr);
50
- } else if (el['_component'] !== this || el.getAttribute(tracking_attr) !== this.tracking_id) {
51
- this.tracking_id = new Date().valueOf().toString();
52
- el.setAttribute(tracking_attr, this.tracking_id);
53
- if (typeof MutationObserver !== 'undefined') {
54
- if (!this.observer) this.observer = new MutationObserver(changes => {
55
- if (changes[0].oldValue === this.tracking_id || !document.body.contains(el)) {
56
- this.unload(this.state);
57
- this.observer.disconnect();
58
- this.observer = null;
59
- }
60
- });
61
- this.observer.observe(document.body, {
62
- childList: true, subtree: true,
63
- attributes: true, attributeOldValue: true, attributeFilter: [tracking_attr]
64
- });
65
- }
46
+ if (!el) return;
47
+ const tracking_attr = '_c';
48
+ if (!this.unload) {
49
+ el.removeAttribute && el.removeAttribute(tracking_attr);
50
+ } else if (el['_component'] !== this || el.getAttribute(tracking_attr) !== this.tracking_id) {
51
+ this.tracking_id = new Date().valueOf().toString();
52
+ el.setAttribute(tracking_attr, this.tracking_id);
53
+ if (typeof MutationObserver !== 'undefined') {
54
+ if (!this.observer) this.observer = new MutationObserver(changes => {
55
+ if (changes[0].oldValue === this.tracking_id || !document.body.contains(el)) {
56
+ this.unload(this.state);
57
+ this.observer.disconnect();
58
+ this.observer = null;
59
+ }
60
+ });
61
+ this.observer.observe(document.body, {
62
+ childList: true, subtree: true,
63
+ attributes: true, attributeOldValue: true, attributeFilter: [tracking_attr]
64
+ });
66
65
  }
67
- el['_component'] = this;
68
66
  }
67
+ el['_component'] = this;
68
+
69
69
  if (!vdom && html) {
70
70
  html = directive(html, this);
71
71
  if (this.options.transition && document && document['startViewTransition']) {
package/src/directive.ts CHANGED
@@ -78,19 +78,17 @@ const directive = (vdom, component) => {
78
78
  if (Array.isArray(vdom)) {
79
79
  return vdom.map(element => directive(element, component));
80
80
  } else {
81
- let { tag, props, children } = vdom;
82
- if (tag) {
83
- if (props) Object.keys(props).forEach(key => {
84
- if (key.startsWith('$')) {
85
- apply_directive(key, props, tag, component);
86
- delete props[key];
87
- }
88
- });
89
- if (children) children = directive(children, component);
90
- return { tag, props, children };
91
- } else {
92
- return vdom;
93
- }
81
+ let { type, tag, props, children } = vdom;
82
+ tag = tag || type;
83
+ children = children || props?.children;
84
+ if (props) Object.keys(props).forEach(key => {
85
+ if (key.startsWith('$')) {
86
+ apply_directive(key, props, tag, component);
87
+ delete props[key];
88
+ }
89
+ });
90
+ if (children) directive(children, component);
91
+ return vdom;
94
92
  }
95
93
  }
96
94