Skip to content

Commit

Permalink
Avoid mutating newImportMap
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavweiss committed Aug 7, 2024
1 parent 5fa401b commit 17c1ab0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -108854,8 +108854,15 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp

<p class="note">We're mutating this copy and removing items from it when they are used to
ignore scope-specific rules. That enables keeping less-specific rules that would match the same
specifier.</p>
</li>
specifier. The same is true for <var>newImportMapScopes</var> and <var>newImportMapImports</var>
below.</p>
</li>

<li><p>Let <var>newImportMapScopes</var> be a deep copy of <var>newImportMap</var>'s <span
data-x="concept-import-map-scopes">scopes</span>.</p></li>

<li><p>Let <var>newImportMapImports</var> be a deep copy of <var>newImportMap</var>'s <span
data-x="concept-import-map-imports">imports</span>.</p></li>

<li><p><span data-x="set iterate">For each</span> <var>pair</var> of
<var>resolvedSetCopy</var>:</p>
Expand All @@ -108875,8 +108882,6 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
concatenate">concatenating</span> <var>tokens</var> on on U+002F ("<code
data-x="">/</code>").</p></li>

<li><p>Let <var>newImportMapScopes</var> be <var>newImportMap</var>'s <span
data-x="concept-import-map-scopes">scopes</span>.</p></li>
<li>
<p>If <var>current path</var> <span data-x="map exists">exists</span> in
<var>newImportMapScopes</var>, then:</p>
Expand All @@ -108900,8 +108905,7 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
</ol>
</li>
<li><p><span data-x="map iterate">For each</span> <var>scopePrefix</var> →
<var>scopeImports</var> of <var>newImportMap</var>'s <span
data-x="concept-import-map-scopes">scopes</span>:</p>
<var>scopeImports</var> of <var>newImportMapScopes</var>:</p>
<ol>
<li><p>If <var>scopePrefix</var> <span data-x="map exists">exists</span> in
<var>oldImportMap</var>'s <span data-x="concept-import-map-scopes">scopes</span>, then
Expand Down Expand Up @@ -108933,13 +108937,12 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
</li>

<li><p><span data-x="list iterate">For each</span> <var>pair</var> of
<var>resolvedSetCopy</var>, remove <var>newImportMap</var>'s <span
data-x="concept-import-map-imports">imports</span>[<var>specifier</var>].</p></li>
<var>resolvedSetCopy</var>, remove <var>newImportMapImports</var>[<var>specifier</var>].</p></li>

<li><p>Set <var>oldImportMap</var>'s <span data-x="concept-import-map-imports">imports</span> to
the result of <span data-x="merge module specifier maps">merge module specifier maps</span>,
given <var>newImportMap</var>'s <span data-x="concept-import-map-imports">imports</span> and
<var>oldImportMap</var>'s <span data-x="concept-import-map-imports">imports</span>.</p></li>
given <var>newImportMapImports</var> and <var>oldImportMap</var>'s <span
data-x="concept-import-map-imports">imports</span>.</p></li>
</ol>

<p class="note">The above algorithm merges a new import map into the given <span>environment
Expand Down

0 comments on commit 17c1ab0

Please sign in to comment.