mount-observer 0.1.20 → 0.1.21
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/handlers/EMCScript.js +3 -9
- package/handlers/EMCScript.ts +4 -12
- package/package.json +1 -1
package/handlers/EMCScript.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EvtRt } from '../EvtRt.js';
|
|
2
|
-
import { MountObserver } from '../MountObserver.js';
|
|
3
2
|
import '../ElementMountExtension.js';
|
|
4
3
|
import 'assign-gingerly/object-extension.js';
|
|
5
4
|
/**
|
|
@@ -68,15 +67,9 @@ export class EMCScriptHandler extends EvtRt {
|
|
|
68
67
|
if (!scriptElement.id && scriptElement.parentElement) {
|
|
69
68
|
scriptElement.id = `${scriptElement.parentElement.localName}.${enhKey}`;
|
|
70
69
|
}
|
|
71
|
-
// Construct MountConfig from EMC config
|
|
70
|
+
// Construct MountConfig from EMC config and mount it
|
|
72
71
|
const mountConfig = await this.buildMountConfig(emcConfig);
|
|
73
|
-
|
|
74
|
-
const observer = new MountObserver(mountConfig);
|
|
75
|
-
// Store observer reference for cleanup
|
|
76
|
-
scriptElement.emcObserver = observer;
|
|
77
|
-
// Observe from the script element's parent or root node
|
|
78
|
-
const observeTarget = scriptElement.parentElement || scriptElement.getRootNode();
|
|
79
|
-
await observer.observe(observeTarget);
|
|
72
|
+
await scriptElement.mount(mountConfig);
|
|
80
73
|
}
|
|
81
74
|
/**
|
|
82
75
|
* Build a MountConfig from an EMC config.
|
|
@@ -174,5 +167,6 @@ export class EMCScriptHandler extends EvtRt {
|
|
|
174
167
|
}
|
|
175
168
|
}
|
|
176
169
|
// Register built-in handler
|
|
170
|
+
import { MountObserver } from '../MountObserver.js';
|
|
177
171
|
export const emc = 'builtIns.emcScript';
|
|
178
172
|
MountObserver.define(emc, EMCScriptHandler);
|
package/handlers/EMCScript.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EvtRt } from '../EvtRt.js';
|
|
2
2
|
import { EMC, MountConfig, MountContext } from '../types/mount-observer/types.js';
|
|
3
|
-
import { MountObserver } from '../MountObserver.js';
|
|
4
3
|
import '../ElementMountExtension.js';
|
|
5
4
|
import 'assign-gingerly/object-extension.js';
|
|
6
5
|
|
|
@@ -80,18 +79,9 @@ export class EMCScriptHandler extends EvtRt {
|
|
|
80
79
|
scriptElement.id = `${scriptElement.parentElement.localName}.${enhKey}`;
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
// Construct MountConfig from EMC config
|
|
82
|
+
// Construct MountConfig from EMC config and mount it
|
|
84
83
|
const mountConfig = await this.buildMountConfig(emcConfig);
|
|
85
|
-
|
|
86
|
-
// Create a MountObserver to watch for elements matching the config
|
|
87
|
-
const observer = new MountObserver(mountConfig);
|
|
88
|
-
|
|
89
|
-
// Store observer reference for cleanup
|
|
90
|
-
(scriptElement as any).emcObserver = observer;
|
|
91
|
-
|
|
92
|
-
// Observe from the script element's parent or root node
|
|
93
|
-
const observeTarget = scriptElement.parentElement || scriptElement.getRootNode() as Node;
|
|
94
|
-
await observer.observe(observeTarget);
|
|
84
|
+
await scriptElement.mount(mountConfig);
|
|
95
85
|
}
|
|
96
86
|
|
|
97
87
|
/**
|
|
@@ -211,6 +201,8 @@ export class EMCScriptHandler extends EvtRt {
|
|
|
211
201
|
}
|
|
212
202
|
|
|
213
203
|
// Register built-in handler
|
|
204
|
+
import { MountObserver } from '../MountObserver.js';
|
|
205
|
+
|
|
214
206
|
export const emc = 'builtIns.emcScript';
|
|
215
207
|
|
|
216
208
|
MountObserver.define(emc, EMCScriptHandler);
|