@webqit/oohtml 4.5.7 → 4.5.8

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.5.7",
17
+ "version": "4.5.8",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -71,7 +71,7 @@ export default class HTMLModule {
71
71
  const { window } = env, { webqit: { Observer } } = window;
72
72
  let dirty, allFragments = this.defs[ '#' ] || [];
73
73
  entries.forEach( entry => {
74
- if ( entry.nodeType !== 1 ) return;
74
+ if ( !entry || entry.nodeType !== 1 ) return;
75
75
  const isTemplate = entry.matches( this.config.templateSelector );
76
76
  const defId = ( entry.getAttribute( isTemplate ? this.config.attr.def : this.config.attr.fragmentdef ) || '' ).trim();
77
77
  if ( isConnected ) {
@@ -133,13 +133,20 @@ export default class HTMLModule {
133
133
  *
134
134
  * @return Promise
135
135
  */
136
+ #fetchedURLs = new Set;
137
+ #fetchInFlight;
136
138
  load( src ) {
137
139
  const { window } = env;
138
- if ( this.host.content.children.length ) return Promise.resolve();
140
+ if ( this.#fetchedURLs.has( src ) ) {
141
+ // Cache busting is needed to
142
+ return Promise.resolve();
143
+ }
144
+ this.#fetchedURLs.add( src );
145
+ if ( this.#fetchedURLs.size === 1 && this.host.content.children.length ) {
146
+ return Promise.resolve();
147
+ }
139
148
  // Ongoing request?
140
- if ( this.fetchInFlight?.src === src ) return this.fetchInFlight.request;
141
- this.fetchInFlight?.controller.abort();
142
-
149
+ this.#fetchInFlight?.controller.abort();
143
150
  // The promise
144
151
  const controller = new AbortController();
145
152
  const fire = ( type, detail ) => this.host.dispatchEvent( new window.CustomEvent( type, { detail } ) );
@@ -151,11 +158,11 @@ export default class HTMLModule {
151
158
  return this.host;
152
159
  } ).catch( e => {
153
160
  console.error( `Error fetching the bundle at "${ src }": ${ e.message }` );
154
- this.fetchInFlight = null;
161
+ this.#fetchInFlight = null;
155
162
  fire( 'loaderror' );
156
163
  return this.host;
157
164
  } );
158
- this.fetchInFlight = { src, request, controller };
165
+ this.#fetchInFlight = { request, controller };
159
166
  return request;
160
167
  }
161
168