mount-observer 0.0.28 → 0.0.29
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/README.md +2 -2
- package/Synthesizer.js +11 -5
- package/package.json +1 -1
- package/types.d.ts +1 -0
package/README.md
CHANGED
|
@@ -736,9 +736,9 @@ To support this, we propose these highlights:
|
|
|
736
736
|
1. Adding a static "synthesize" method to the MountObserver api. This would provide a kind of passage-way from the imperative api to the declarative one.
|
|
737
737
|
2. As the *synthesize* method is called repeatedly from different packages that work within that framework, it creates a cluster of MOSEs wrapped inside the "synthesizing" custom element ("be-hive") that the framework developer authors. It appends script elements with type="mountobserver" to the custom element instance sitting in the DOM, that dispatches events from the synthesizing custom element it gets appended to, so subscribers in child Shadow DOM's don't need to add a general mutation observer in order to know when parent shadow roots had a MOSE inserted that it needs to act on. This allows the child Shadow DOM's to inherit (in this case) behaviors/enhancements from the parent Shadow DOM.
|
|
738
738
|
|
|
739
|
-
So framework developers can develop a bespoke custom element that inherits from the "abstract" class "*Synthesizer*" that is part of this package / proposal, that is used to group families of MountObserver's together.
|
|
739
|
+
So framework developers can develop a bespoke custom element that inherits from the "abstract" class "*Synthesizer*" that is part of this package / proposal, that is used to group families of MountObserver's together.
|
|
740
740
|
|
|
741
|
-
Some attributes that the base "Synthesizer"
|
|
741
|
+
Some attributes that the base "Synthesizer" supports are listed below. They are all related to allowing individual ShadowDOM realms to be able to easily opt in or opt out, depending on the level of control/trust that is exerted by a web component / Shadow Root, as far as the HTML it imports in.
|
|
742
742
|
|
|
743
743
|
1. passthrough. Allows for the inheritance of behaviors to flow through from above (or from the root document), while not actually activating any of them within the Shadow DOM realm itself.
|
|
744
744
|
2. exclude. List of specific MOSE id's to block. Allows them to flow through to child Shadow Roots.
|
package/Synthesizer.js
CHANGED
|
@@ -30,20 +30,26 @@ export class Synthesizer extends HTMLElement {
|
|
|
30
30
|
this.#mutationObserver.observe(this, init);
|
|
31
31
|
this.inherit();
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
checkIfAllowed(mose) {
|
|
34
34
|
if (this.hasAttribute('passthrough'))
|
|
35
|
-
return;
|
|
36
|
-
const {
|
|
35
|
+
return false;
|
|
36
|
+
const { id } = mose;
|
|
37
37
|
if (this.hasAttribute('include')) {
|
|
38
38
|
const split = this.getAttribute('include').split(' ');
|
|
39
39
|
if (!split.includes(id))
|
|
40
|
-
return;
|
|
40
|
+
return false;
|
|
41
41
|
}
|
|
42
42
|
if (this.hasAttribute('exclude')) {
|
|
43
43
|
const split = this.getAttribute('exclude').split(' ');
|
|
44
44
|
if (split.includes(id))
|
|
45
|
-
return;
|
|
45
|
+
return false;
|
|
46
46
|
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
activate(mose) {
|
|
50
|
+
if (!this.checkIfAllowed(mose))
|
|
51
|
+
return;
|
|
52
|
+
const { init, do: d } = mose;
|
|
47
53
|
const mi = {
|
|
48
54
|
do: d,
|
|
49
55
|
...init
|
package/package.json
CHANGED