WICG / import-maps

How to control the behavior of JavaScript imports
https://html.spec.whatwg.org/multipage/webappapis.html#import-maps
Other
2.66k stars 69 forks source link

"Execute a script" block appears to be reachable #243

Closed jeremyroman closed 3 years ago

jeremyroman commented 3 years ago

The draft inserts an "Assert: Never reached." into the "execute a script block" algorithm, but it appears that nothing prevents this algorithm from running.

Three possible resolutions:

  1. It is in fact unreachable; add a note explaining why.
  2. Change from an assert to an early-out, or otherwise handle the case of the "execute a script block" algorithm running.
  3. Modify other algorithms to make "execute a script block" unreachable for import map scripts.
domfarolino commented 3 years ago

I believe https://wicg.github.io/import-maps/#ref-for-concept-script-type%E2%91%A2 makes it so type=importmaps scripts are never exected.

I think scripts are only ever executed when they are added to one of the 3 (I think) lists of scripts that will execute [...] and their ready to be parser-executed flag is is set, or unless handled explicitly elsewhere in prepare a script step 28.

This spec adds a new "case" to step 28 (although it seems to reference it as step 26 which seems outdated) that handles the "readiness" of a type=importmap script, which does not include executing the script, so I think this is why the execute algorithm is unreachable.

jeremyroman commented 3 years ago

Ah, I think you're right. I missed an early-out in one of those branches and that you do avoid the "otherwise" branch in step 28. I was pretty sure I was missing something but it's a little inscrutable if you haven't stared at it long enough. Thanks.

A brief note might be helpful, but I'm not sure to concisely summarize either, so, mrrr.