@webqit/oohtml 4.3.10 → 4.3.12

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.10",
17
+ "version": "4.3.12",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -18,15 +18,16 @@ import { _init } from '../util.js';
18
18
  */
19
19
  export default function init( $config = {} ) {
20
20
  const { config, window } = _init.call( this, 'context-api', $config, {
21
+ elements: { roots: 'root,webflo-embedded', },
21
22
  attr: { contextname: 'contextname', },
22
23
  api: { contexts: 'contexts', },
23
24
  } );
24
25
  const waitListMappings = new Map, dispatchEvent = window.EventTarget.prototype.dispatchEvent;
25
26
  Object.defineProperty( window.EventTarget.prototype, 'dispatchEvent', { value: function( ...args ) {
26
- const event = args[0], rootNode = this.getRootNode?.();
27
+ const event = args[0], rootNode = this?.closest?.(config.elements.roots) || this.getRootNode?.();
27
28
  if ( [ 'contextclaim', 'contextrequest' ].includes( event.type ) && rootNode ) {
28
29
  if ( event.meta ) event.meta.target = this;
29
- const temp = event => {
30
+ const temp = (event) => {
30
31
  event.stopImmediatePropagation();
31
32
  // Always set this whether answered or not
32
33
  if ( event.meta ) event.meta.target = event.target;
@@ -52,11 +52,17 @@ export default class HTMLImportsContext extends DOMContext {
52
52
  const options = { live: event.live, signal: event.signal, descripted: true };
53
53
  event.meta.controller = Observer.reduce( this.#modules, path, Observer.get, ( m ) => {
54
54
  if ( Array.isArray( m ) ) {
55
+ if ( !m.length ) {
56
+ event.respondWith( undefined );
57
+ return;
58
+ }
55
59
  // Paths with wildcard
56
60
  for ( const n of m ) {
57
61
  event.respondWith( n );
58
62
  }
59
- } else event.respondWith( m.value );
63
+ } else {
64
+ event.respondWith( m.value );
65
+ }
60
66
  }, options );
61
67
  }
62
68
 
@@ -101,16 +107,24 @@ export default class HTMLImportsContext extends DOMContext {
101
107
  // This superModules contextrequest is automatically aborted by the injected signal below
102
108
  const request = { ...this.constructor.createRequest( moduleRef ? `${moduleRef}/*` : '*' ), live: true, signal, diff: true };
103
109
  this.host.parentNode[ this.configs.CONTEXT_API.api.contexts ].request( request, ( m ) => {
104
- if ( m.type === 'delete' ) {
105
- Reflect.deleteProperty( this.inheritedModules, m.key );
106
- if ( !Observer.has( this.localModules, m.key ) ) {
107
- Observer.deleteProperty( this.#modules, m.key );
110
+ const _delete = ( key ) => {
111
+ Reflect.deleteProperty( this.inheritedModules, key );
112
+ if ( !Observer.has( this.localModules, key ) ) {
113
+ Observer.deleteProperty( this.#modules, key );
108
114
  }
109
- } else {
110
- Reflect.set( this.inheritedModules, m.key, m.value );
111
- if ( !Observer.has( this.localModules, m.key ) ) {
112
- Observer.set( this.#modules, m.key, m.value );
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 );
113
120
  }
121
+ };
122
+ if ( !m ) {
123
+ Object.keys( this.inheritedModules ).forEach( _delete );
124
+ } else {
125
+ if ( m.type === 'delete' ) {
126
+ _delete( m.key );
127
+ } else _set( m.key, m.value );
114
128
  }
115
129
  } );
116
130
  }, { live: true, timing: 'sync', oldValue: true, lifecycleSignals: true } );
@@ -168,7 +168,7 @@ export default class HTMLModule {
168
168
  if ( !this.parent ) return [];
169
169
  const { window: { webqit: { Observer } } } = env;
170
170
  let extendedId = ( this.host.getAttribute( this.config.attr.extends ) || '' ).trim();
171
- let inheritedIds = ( this.host.getAttribute( this.config.attr.inherits ) || '' ).trim();
171
+ let inheritedIds = ( this.host.getAttribute( this.config.attr.inherits ) || '' ).trim().split( ' ' ).map( id => id.trim() ).filter( x => x );
172
172
  const handleInherited = records => {
173
173
  records.forEach( record => {
174
174
  if ( Observer.get( this.defs, record.key ) !== record.oldValue ) return;
@@ -184,8 +184,8 @@ export default class HTMLModule {
184
184
  if ( extendedId ) {
185
185
  realtimes.push( Observer.reduce( parentDefsObj, [ extendedId, this.config.api.defs, Infinity ], Observer.get, handleInherited, { live: true } ) );
186
186
  }
187
- if ( ( inheritedIds = inheritedIds.split( ' ' ).map( id => id.trim() ).filter( x => x ) ).length ) {
188
- realtimes.push( Observer.get( parentDefsObj, inheritedIds, handleInherited, { live: true } ) );
187
+ if ( inheritedIds.length ) {
188
+ realtimes.push( Observer.get( parentDefsObj, inheritedIds.includes( '*' ) ? Infinity : inheritedIds, handleInherited, { live: true } ) );
189
189
  }
190
190
  return realtimes;
191
191
  }