Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 4.15 KB

HTML Integration.md

File metadata and controls

35 lines (22 loc) · 4.15 KB

HTML Integration for import()

The following outlines the spec changes to the HTML Standard that would be necessary to support the import() proposal in a web browser host environment.

Script Infrastructure

The Scripting Definitions section, which defines HTML's concepts of script, classic script, and module script, would be modified as follows:

  • The base URL, cryptographic nonce, and parser state properties, currently on module scripts, would move to the base script type

The procedure to create a classic script would be updated to take these three properties, which it sets on the created classic script. All of its callers would be updated:

  • The script fetching algorithms would be updated to pass the appropriate values that they were passed (similar to module scripts), and their callers in turn would be updated to derive them appropriately as they do for module scripts
  • The inline classic script setup algorithm would pass along the values derived from the script element (similar to modules)
  • The javascript: URL processing algorithm would pass along the address variable, no cryptographic nonce, and "not parser-inserted"
  • The timer initialization steps used by setTimeout and setInterval would pass along the caller realm's API base URL, no cryptographic nonce, and "not parser-inserted"

Integration with the JavaScript module system

The integration with the JavaScript module system would be updated in a few ways.

The introductory sentence of resolve a module specifier would changed to say and link to script, instead of module script, as with the base URL changes above, it can now accept both.

The algorithm for HostResolveImportedModule would be updated with the new parameter name, referencingScriptOrModule, and the variable name referencing module script would be changed to referencing script.

We would define a new section for HostFetchImportedModule. The implementation would be as follows:

HostFetchImportedModule(referencingScriptOrModule, specifier)

  1. Let referencing script be referencingScriptOrModule.[[HostDefined]].
  2. Let settings object be referencing script's settings object.
  3. Let url be the result of resolving a module specifier given referencing script and specifier. If the result is failure, asynchronously complete this algorithm with a TypeError exception and abort these steps.
  4. Let credentials mode be "omit".
  5. If referencing script is a module script, set credentials mode to referencing script's credentials mode.
  6. Fetch a module script tree given url, settings object, "script", referencing script's cryptographic nonce, referencing script's parser state, and credentials mode. If fetching a module script tree asynchronously completes with null, asynchronously complete this algorithm with an abrupt completion whose value is a new TypeError. Otherwise, asynchronously complete this algorithm with a normal completion whose value is undefined.