-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make import maps registration priorities and error events in-order #143
Conversation
This PR is blocked by the discussion on #114 (not yet finalized). |
I like Option 2 because it doesn't rely on the "acquiring import maps" boolean. I've expressed some other concerns about Option 2, though, in the issue's comments. Overall I think Option 2 might be best. |
3437ea8
to
b5144e9
Compare
One issue in my mind is freedom of scheduling. The current PR calls However, probably |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduces the script's import map, the import map is ready,
list of pending import map scripts and their related mechanisms similar
to the script's script, the script is ready, and
list of scripts that will execute in order as soon as possible.
Is it possible to reuse the script's script (maybe renamed "the script's result" or "the script
element's result") and "the script is ready" (maybe renamed ("the script
element is ready")? It seems like it would fit in fine since everything in step 26 is guarded by the type.
If we were to follow the existing spec structure more closely, I think:
- The "Append the element to the element’s node document’s list of pending import map scripts." step would move to 26
- The "When the import map is ready" step would move to step 26.
Do you think such a change would make sense?
I think it is kind of nice to get the error event sooner rather than later, but if you have a design that you think would be nicer I'm definitely open to it. |
a097531
to
5bb2dbf
Compare
Sounds good, but needs more checks. Probably, if we want to follow the existing spec structure, we can do one step further:
This is what I and @nyaxt (IIUC) intentionally avoided, because the blocking semantics of import maps (i.e. ordering between import maps and other scripts) is governed quite differently from the existing mechanisms around @domenic and @nyaxt, WDYT? (I'll anyway draft this tomorrow-ish, to see how it would look like) |
Hmm, interesting. I am OK either way, if you think we should go for that full type of merger, or just treat them more similarly inside prepare-a-script (e.g. by reusing |
5bb2dbf
to
817890f
Compare
Done.
I didn't do these, because I found these don't simplify the spec further, and there are substantial differences between |
There is a problem with error handling. "Parse an import map" can throw an error. The current draft in this PR doesn't handle the error at all. I think it probably assumes that "parse an import map" would return null for parsing failures. But we shouldn't just convert any thrown errors into null as that loses the distinction between a parse error (window.onerror) and a fetch error (script.onerror). I think the correct behavior would be to treat this similar to what we do for classic/module scripts, but simpler:
|
Good catch. Then
This is more similar to a So far I don't have ideas for better names; I'll draft commits using |
What will the settings object be used for? |
For checking whether the import map is moved between Documents. |
Hmm, firing (I'll think more about this later though) |
spec.bs
Outdated
1. Increment/decrement <a spec="html">ignore-destructive-writes counter</a> of |element|'s [=node document=]. | ||
1. <a spec="html">Check if we can run script</a> with |settings object|. If this returns "`do not run`" then return. | ||
1. <a spec="html">Prepare to run script</a> given |settings object|. | ||
1. <a spec="html">Clean up after running script</a> given |settings object|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure the only potentially observable thing here would be the "check if we can run script" step.
I guess that would be observable because it would make inserting import maps into non-fully active documents a no-op, which you could then observe by making the document fully active again? (Which I think can only happen with bfcache.) Wow, what an edge case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove these for now.
spec.bs
Outdated
1. <a spec="html">Clean up after running script</a> given |settings object|. | ||
</div> | ||
1. <a spec="html">Report the exception</a> given |import map parse result|'s [=import map parse result/error to rethrow=]. | ||
<p class="issue">There are no relevant [=script=], because [=import map parse result=] isn't a [=script=]. Perhaps <a href="https://github.com/whatwg/html/issues/958">whatwg/html#958</a> might resolve this issue.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this is the best we can do until whatwg/html#958 is solved.
Yeah, I am torn. The "script" concept gets stretched pretty far, especially with new stuff like JSON module scripts. If it helps, I made the following matrix:
* = I think this is currently allowed but there is talk of disallowing it? Can't find the issue |
5d40473
to
8ffbd6c
Compare
Previously, import maps are processed when they are fetched, and therefore
the priority of import maps and order of
error
events are nondeterministic.This PR introduces a mechanism to process import maps in the order of
prepare-a-script
, fixes #114.To do this, this PR
the script's import map
,the import map is ready
,list of pending import map scripts
and their related mechanisms similarto
the script's script
,the script is ready
, andlist of scripts that will execute in order as soon as possible
.pending import maps count
withlist of pending import map scripts
acquiring import maps
) toDocument
wait for import maps
work onDocument
directly instead of onenvironment settings object
.Other behavior changes:
parsing an import map string
now precedes thecheck for scripts elements moved between Documents.
Preview | Diff