Skip to content

fetch the descendants of and link a module script only handles [[ParseError]] case #11338

@allstarschh

Description

@allstarschh

What is the issue with the HTML Standard?

In fetch the descendants and link a module script, it will call LoadRequestedModules to fetch the descendants, which will in turn call HostLoadImportedModules.
And if there's any exception thrown during HostLoadImportedModules, it will call FinishLoadingImportedModule.
But only the ParseError case, which is handled in step 14.3.3 of HostLoadImportedModules, will be passed to the loadState.[[ParseError]]

If loadState is not undefined and loadState.[[ParseError]] is null, set loadState.[[ParseError]] to parseError.

Then the loadPromise from LoadRequestedModules will be rejected, in step 7.1 of fetch the descendants and link a module script

If state.[[ParseError]] is not null, set moduleScript's error to rethrow to state.[[ParseError]] and run onComplete given moduleScript.

But what about the other errors thrown during HostLoadImportedModules? For example, when the module type allowed returns false, or when the resolutionError is thrown in Step 9. These doesn't set the [[ParseError]] state, hence when the loadPromise is rejected in fetch the descendants and link a module script, it will run step 7.2.

Otherwise, run onComplete given null.

This will lead to the onerror handler of the script will be called,

The change is made from #8253, but contradicts the original behavior.
Originally, resolution errors and errors for module types were treated as parse errors.
https://web.archive.org/web/20221130124954/https://html.spec.whatwg.org/#validate-requested-module-specifiers

The wpt, [/import-maps/bare-specifiers.sub.html], and [/html/semantics/scripting-1/the-script-element/import-attributes/invalid-type-attribute-error.html] still expect the legacy behavior

CCing @nicolo-ribaudo

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions