Previously, we intended to reject second and subsequent import maps by checking whether node document's pending import map script is non-null, but this didn't work because after import maps are registered pending import map script is cleared.
This PR fixes this by clearing acquiring import maps on preparing the first import map, rejecting second and subsequent import maps on preparation with error events.
Alternative considered:
It might be better to set Document's import map to an empty import map on second import map, because it would prevent developers more effectively from depending on the behavior of multiple import maps cases.
However, this was more complicated to specify (e.g. the first import map should be canceled on preparing the second import map and is hard to receive error events).
Previously, we intended to reject second and subsequent import maps by checking whether
node document's pending import map script is non-null
, but this didn't work because after import maps are registeredpending import map script
is cleared. This PR fixes this by clearingacquiring import maps
on preparing the first import map, rejecting second and subsequent import maps on preparation with error events.Alternative considered: It might be better to set Document's import map to an empty import map on second import map, because it would prevent developers more effectively from depending on the behavior of multiple import maps cases. However, this was more complicated to specify (e.g. the first import map should be canceled on preparing the second import map and is hard to receive error events).
WPT: https://github.com/web-platform-tests/wpt/pull/27117 Chromium CL: https://chromium-review.googlesource.com/c/chromium/src/+/2618838
Preview | Diff