@webqit/oohtml 4.1.4 → 4.1.5

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.1.4",
17
+ "version": "4.1.5",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  "postpublish": "git push && git push --tags"
40
40
  },
41
41
  "dependencies": {
42
- "@webqit/quantum-js": "^4.5.6",
42
+ "@webqit/quantum-js": "^4.5.8",
43
43
  "@webqit/realdom": "^2.1.24",
44
44
  "@webqit/util": "^0.8.11"
45
45
  },
@@ -87,8 +87,10 @@ export default class DOMContexts {
87
87
 
88
88
  const rootNode = this[ '#' ].host.getRootNode();
89
89
  const temp = event => {
90
- if ( event.answered ) return;
90
+ event.stopImmediatePropagation();
91
+ // Always set thus whether answered or not
91
92
  event.meta.target = event.target;
93
+ if ( event.answered ) return;
92
94
  if ( !waitListMappings.get( rootNode ) ) { waitListMappings.set( rootNode, new Set ); }
93
95
  if ( event.type === 'contextrequest' && event.live ) {
94
96
  waitListMappings.get( rootNode ).add( event );
@@ -134,7 +134,7 @@ function realtime( config ) {
134
134
  record.entrants.forEach( entry => {
135
135
  if ( entry.matches( config.templateSelector ) ) {
136
136
  const htmlModule = HTMLModule.instance( entry );
137
- htmlModule.ownerContext = entry.scoped ? record.target : record.target.getRootNode();
137
+ htmlModule.ownerContext = entry.scoped ? entry.parentNode : entry.getRootNode();
138
138
  const ownerContextModulesObj = getDefs( htmlModule.ownerContext );
139
139
  if ( htmlModule.defId ) { Observer.set( ownerContextModulesObj, htmlModule.defId, entry ); }
140
140
  // The ownerContext's defs - ownerContextModulesObj - has to be populated
@@ -149,13 +149,13 @@ function realtime( config ) {
149
149
  if ( entry.matches( config.templateSelector ) ) {
150
150
  const htmlModule = HTMLModule.instance( entry );
151
151
  const ownerContextModulesObj = getDefs( htmlModule.ownerContext );
152
- if ( htmlModule.defId ) { Observer.deleteProperty( ownerContextModulesObj, htmlModule.defId ); }
152
+ if ( htmlModule.defId && htmlModule.ownerContext.isConnected ) { Observer.deleteProperty( ownerContextModulesObj, htmlModule.defId ); }
153
153
  detachImportsContext( htmlModule.ownerContext );
154
154
  } else {
155
155
  detachImportsContext( entry );
156
156
  }
157
157
  } );
158
- }, { live: true, subtree: 'cross-roots', timing: 'sync', staticSensitivity: true } );
158
+ }, { live: true, subtree: 'cross-roots', timing: 'sync', staticSensitivity: true, eventDetails: true } );
159
159
 
160
160
  // ------------
161
161
  // IMPORTS
@@ -313,11 +313,12 @@ function realtime( config ) {
313
313
  if ( entry.isConnected ) { setupBinding( entry, attrName, _( entry, 'attrOriginals' ).get( attrName )/* Saved original value */ || attrValue/* Lest it's ID */, newNamespaceObj ); }
314
314
  };
315
315
  record.exits.forEach( entry => {
316
- if (!entry.isConnected) return;
317
- const namespaceObj = getOwnNamespaceObject.call( window, entry );
318
- // Detach ID and IDREF associations
319
- for ( const node of new Set( [ ...Object.values( namespaceObj ), ...( _( namespaceObj ).get( 'idrefs' ) || [] ) ] ) ) {
320
- for ( const attrName of attrList ) { reAssociate( node, attrName, namespaceObj ); }
316
+ if ( entry.isConnected ) {
317
+ const namespaceObj = getOwnNamespaceObject.call( window, entry );
318
+ // Detach ID and IDREF associations
319
+ for ( const node of new Set( [ ...Object.values( namespaceObj ), ...( _( namespaceObj ).get( 'idrefs' ) || [] ) ] ) ) {
320
+ for ( const attrName of attrList ) { reAssociate( node, attrName, namespaceObj ); }
321
+ }
321
322
  }
322
323
  // Detach ID associations
323
324
  const contextsApi = entry[ configs.CONTEXT_API.api.contexts ];
@@ -341,10 +342,20 @@ function realtime( config ) {
341
342
 
342
343
  // DOM realtime
343
344
  realdom.realtime( window.document ).query( `[${ attrList.map( attrName => window.CSS.escape( attrName ) ).join( '],[' ) }]`, record => {
345
+ // We do some caching to prevent redundanct lookups
346
+ const namespaceNodesToTest = { forID: new Map, forOther: new Map, };
344
347
  for ( const attrName of attrList ) {
348
+ // Point to the right cache
349
+ const _namespaceNodesToTest = attrName === config.attr.lid ? namespaceNodesToTest.forID : namespaceNodesToTest.forOther;
345
350
  record.exits.forEach( entry => {
346
- const namespaceNodeToTest = ( attrName === config.attr.lid ? entry.parentNode : entry )?.closest/*can be documentFragment when Shadow DOM*/?.( config.namespaceSelector ) || entry.getRootNode().host;
347
- if ( ( namespaceNodeToTest && !namespaceNodeToTest.isConnected ) || !entry.hasAttribute( attrName ) ) return;
351
+ if ( !entry.hasAttribute( attrName ) ) return;
352
+ // Point to the right namespace node
353
+ let namespaceNodeToTest = _namespaceNodesToTest.get( entry );
354
+ if ( typeof namespaceNodeToTest === 'undefined' ) {
355
+ namespaceNodeToTest = ( attrName === config.attr.lid ? entry.parentNode : entry )?.closest/*can be documentFragment when Shadow DOM*/?.( config.namespaceSelector ) || entry.getRootNode().host;
356
+ _namespaceNodesToTest.set( entry, namespaceNodeToTest );
357
+ }
358
+ if ( namespaceNodeToTest && !namespaceNodeToTest.isConnected ) return;
348
359
  cleanupBinding( entry, attrName, () => entry.getAttribute( attrName )/* Current resolved value as-is */ );
349
360
  } );
350
361
  record.entrants.forEach( entry => {
@@ -352,6 +363,8 @@ function realtime( config ) {
352
363
  setupBinding( entry, attrName, () => entry.getAttribute( attrName )/* Raw value (as-is) that will be saved as original */ );
353
364
  } );
354
365
  }
366
+ namespaceNodesToTest.forID.clear();
367
+ namespaceNodesToTest.forOther.clear();
355
368
  }, { live: true, subtree: 'cross-roots', timing: 'sync' } );
356
369
  // Attr realtime
357
370
  realdom.realtime( window.document, 'attr' ).observe( attrList, records => {