@webqit/oohtml 4.3.13 → 4.3.14

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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "wicg-proposal"
15
15
  ],
16
16
  "homepage": "https://webqit.io/tooling/oohtml",
17
- "version": "4.3.13",
17
+ "version": "4.3.14",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -53,7 +53,7 @@ export default class HTMLImportsContext extends DOMContext {
53
53
  event.meta.controller = Observer.reduce( this.#modules, path, Observer.get, ( m ) => {
54
54
  if ( Array.isArray( m ) ) {
55
55
  if ( !m.length ) {
56
- event.respondWith( undefined );
56
+ event.respondWith();
57
57
  return;
58
58
  }
59
59
  // Paths with wildcard
@@ -81,18 +81,26 @@ export default class HTMLImportsContext extends DOMContext {
81
81
  this.host = host;
82
82
  const { window: { webqit: { Observer } } } = env;
83
83
  // ----------------
84
+ // Resolve
85
+ const resolve = () => {
86
+ for (const key of new Set([...Object.keys(this.localModules), ...Object.keys(this.inheritedModules), ...Object.keys(this.#modules)])) {
87
+ if ( !Observer.has( this.localModules, key ) && !Observer.has( this.inheritedModules, key ) ) {
88
+ Observer.deleteProperty( this.#modules, key );
89
+ } else if (key === '#' && Observer.has( this.localModules, key ) && Observer.has( this.inheritedModules, key ) ) {
90
+ Observer.set( this.#modules, key, [...Observer.get( this.localModules, key ), ...Observer.get( this.inheritedModules, key )] );
91
+ } else {
92
+ const _module = Observer.get( this.localModules, key ) || Observer.get( this.inheritedModules, key );
93
+ if ( Observer.get( this.#modules, key ) !== _module ) {
94
+ Observer.set( this.#modules, key, _module );
95
+ }
96
+ }
97
+ }
98
+ };
99
+ // ----------------
84
100
  // Observe local
85
101
  this.#modules = { ...this.localModules };
86
102
  this.#controller1?.abort();
87
- this.#controller1 = Observer.observe( this.localModules, ( mutations ) => {
88
- for ( const m of mutations ) {
89
- if ( m.type === 'delete' ) {
90
- if ( this.inheritedModules && Observer.has( this.inheritedModules, m.key ) ) {
91
- Observer.set( this.#modules, m.key, Observer.get( this.inheritedModules, m.key ) );
92
- } else Observer.deleteProperty( this.#modules, m.key );
93
- } else Observer.set( this.#modules, m.key, m.value );
94
- }
95
- }, { timing: 'sync' } );
103
+ this.#controller1 = Observer.observe( this.localModules, () => resolve('local'), { timing: 'sync' } );
96
104
  // ----------------
97
105
  // If host has importscontext attr, compute that
98
106
  const $config = this.configs.HTML_IMPORTS;
@@ -105,28 +113,25 @@ export default class HTMLImportsContext extends DOMContext {
105
113
  if ( moduleRef === prevRef ) return;
106
114
  prevRef = moduleRef;
107
115
  // This superModules contextrequest is automatically aborted by the injected signal below
116
+ this.#inheritedModules = {};
108
117
  const request = { ...this.constructor.createRequest( moduleRef ? `${moduleRef}/*` : '*' ), live: true, signal, diff: true };
109
118
  this.host.parentNode[ this.configs.CONTEXT_API.api.contexts ].request( request, ( m ) => {
110
- const _delete = ( key ) => {
111
- Reflect.deleteProperty( this.inheritedModules, key );
112
- if ( !Observer.has( this.localModules, key ) ) {
113
- Observer.deleteProperty( this.#modules, key );
114
- }
115
- };
116
- const _set = ( key, value ) => {
117
- Reflect.set( this.inheritedModules, key, value );
118
- if ( !Observer.has( this.localModules, key ) ) {
119
- Observer.set( this.#modules, key, value );
120
- }
121
- };
122
119
  if ( !m ) {
123
- Object.keys( this.inheritedModules ).forEach( _delete );
120
+ this.#inheritedModules = {};
121
+ resolve('inherited');
122
+ } else if ( m.type === 'delete' ) {
123
+ delete this.#inheritedModules[m.key];
124
+ if ( !Reflect.has( this.localModules, m.key ) ) {
125
+ Observer.deleteProperty( this.#modules, m.key );
126
+ }
124
127
  } else {
125
- if ( m.type === 'delete' ) {
126
- _delete( m.key );
127
- } else _set( m.key, m.value );
128
+ this.#inheritedModules[m.key] = m.value;
129
+ if ( !Reflect.has( this.localModules, m.key ) && Reflect.get( this.#modules, m.key ) !== m.value ) {
130
+ Observer.set( this.#modules, m.key, m.value );
131
+ }
128
132
  }
129
133
  } );
134
+ resolve('inherited');
130
135
  }, { live: true, timing: 'sync', oldValue: true, lifecycleSignals: true } );
131
136
  }
132
137
  // ----------------
@@ -158,7 +158,7 @@ export default function() {
158
158
  if ( Array.isArray( slottableElements ) ) { slottableElements = new Set( slottableElements ) }
159
159
  // This state must be set before the diffing below and the serialization done at createAnchorNode()
160
160
  this.el.setAttribute( 'data-nodecount', slottableElements.size );
161
- this[ '#' ].autoRestore( () => {
161
+ this[ '#' ].autoRestore( () => {
162
162
  this[ '#' ].slottedElements.forEach( slottedElement => {
163
163
  const slottedElementOriginal = _( slottedElement ).get( 'original@imports' );
164
164
  // If still available in source, simply leave unchanged