@@ -41,6 +41,8 @@ const shouldAbortOnUncaughtException =
4141 getOptionValue ( '--abort-on-uncaught-exception' ) ;
4242const { abort, exit, _rawDebug } = process ;
4343
44+ const TERMINATE = ( ) => null ;
45+
4446// From https://url.spec.whatwg.org/#special-scheme
4547const SPECIAL_SCHEMES = new SafeSet ( [
4648 'file:' ,
@@ -76,7 +78,7 @@ function REACTION_LOG(error) {
7678
7779class Manifest {
7880 /**
79- * @type {Map<string, DependencyMapper> }
81+ * @type {Map<string | null | undefined , DependencyMapper> }
8082 *
8183 * Used to compare a resource to the content body at the resource.
8284 * `true` is used to signify that all integrities are allowed, otherwise,
@@ -139,6 +141,8 @@ class Manifest {
139141 */
140142 constructor ( obj , manifestURL ) {
141143 const scopes = this . #scopeDependencies;
144+ scopes . set ( null , TERMINATE ) ;
145+ scopes . set ( undefined , TERMINATE ) ;
142146 const integrities = this . #resourceIntegrities;
143147 const dependencies = this . #resourceDependencies;
144148 let reaction = REACTION_THROW ;
@@ -205,18 +209,20 @@ class Manifest {
205209 return ( toSpecifier , conditions ) => {
206210 if ( toSpecifier in dependencyMap !== true ) {
207211 if ( cascade === true ) {
208- let scopeHREF ;
212+ /** @type {string | null } */
213+ let scopeHREF = resourceHREF ;
209214 if ( typeof parentDeps === 'undefined' ) {
210215 do {
211- scopeHREF = this . #findScopeHREF( resourceHREF ) ;
216+ scopeHREF = this . #findScopeHREF( scopeHREF ) ;
217+ if ( scopeHREF === resourceHREF ) {
218+ scopeHREF = null ;
219+ }
220+ if ( scopes . has ( scopeHREF ) ) {
221+ break ;
222+ }
212223 } while (
213- scopeHREF !== null &&
214- scopes . has ( scopeHREF ) !== true
224+ scopeHREF !== null
215225 ) ;
216- }
217- if ( scopeHREF === null ) {
218- parentDeps = ( ) => null ;
219- } else {
220226 parentDeps = scopes . get ( scopeHREF ) ;
221227 }
222228 return parentDeps ( toSpecifier ) ;
0 commit comments