-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Execution Order of Tags Not Guaranteed if Using src
#1804
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
Comments
it's probably a matter of queue when it comes to custom types ... polyscript handles non-custom types slightly differently so that this might still be a polyscript issue after all, as PyScript just uses its registry to define the type. Multiple scripts of same type are still a not super common use case though, so let's see if we want to prioritize this before the coming RC. |
Investigating a little more, I think this is PyScript specific. It seems the inline tags are always executed before any In PyScript, I can mix up the following tags in any order: <script type="py" src="one.py"></script> <!-- print('src one') -->
<script type="py">print('Inline one')</script>
<script type="py" src="two.py"></script> <!-- print('src two') -->
<script type="py">print('Inline two')</script>
<script type="py" src="three.py"></script> <!-- print('src three') -->
<script type="py">print('Inline three')</script> And I always get:
But in PolyScript, they are executed in overall page order, regardless of whether they're inline or use <script type="pyodide" src="one.py"></script> <!-- print('src one') -->
<script type="pyodide">print('inline one')</script>
<script type="pyodide" src="two.py"></script> <!-- print('src two') -->
<script type="pyodide">print('inline two')</script>
<script type="pyodide" src="three.py"></script> <!-- print('src three') -->
<script type="pyodide">print('inline three')</script> prints:
|
I can solve this in PyScript but it's a polyscript custom type issue ... polyscript queue per interpreter all executing things: there's no such mechanism for custom types (IIRC) and I think if non custom type works like that, so should custom types too. I'll try to fix this today, thanks for the investigation though! |
@JeffersGlass this has been fixed and tested in polyscript so it will get in next time we update PyScript too ... which arguably could be today as well but ... you know, don't release on Friday and stuff 😄 |
plot twist ... it might be today: #1805 |
it's in and published to |
Try this in the current build (1):
This breaks, with
NameError: name 'x' is not defined
.I would have expected the scripts to run in DOM order per-type, regardless of whether they used
src
or not,Things that do Work
(2) Using inline before
src
(WORKS)(3) Neither uses
src
(WORKS)(4) Both use
src
(WORKS)Using MicroPython (5)
All four of the samples above (the broken one and the ones which work) show the same behavior using
script type='mpy'
instead ofpy
.PolyScript (6)
Doing the following in pure Polyscript works fine, so I think it's an issue in PyScript specifically?
The text was updated successfully, but these errors were encountered: