-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
HTML not getting rendered everytime. #370
Comments
I am seeing this issue as well, with the following HTML document: <html>
<head>
<title>PyScript Test</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<py-script>
print("Testing PyScript")
</py-script>
</body>
</html> Looking at the console, I see the following error:
This error occurred 5 times out of 10 when I tested it. |
This seems to be a problem with the CDN build. |
There's a discussion in #359 |
@pauleveritt I think the issue here is a different issue than #359 |
I think the problem here is that
(https://stackoverflow.com/questions/46217853/get-constructor-name-of-object) This could then break the id creation, because it relies on
One fix could be to use the html tag name to generate the id prefix: checkId() {
const idPrefix = this.tagName.split("-").map(e => {
e = e.toLowerCase();
return e.charAt(0).toUpperCase() + e.slice(1)
}).join("");
if (!this.id) this.id = idPrefix + '-' + guidGenerator();
} This will work for minified code aswell |
Hi, I observe these points
Hi @yannickfunk, thank you for providing the solution. I am new to Javascript, Can you please guide where to put this snippet? I tried adding <script>
checkId() {
const idPrefix = this.tagName.split("-").map(e => {
e = e.toLowerCase();
return e.charAt(0).toUpperCase() + e.slice(1)
}).join("");
if (!this.id) this.id = idPrefix + '-' + guidGenerator();
}
</script> But didnt work. Thank you |
This needs to be fixed inside PyScript itself. You can't fix it inside HTML documents you create. The snippet Yannick provided is meant to be applied here in the PyScript code; please wait while the PyScript devs fix it. |
Hey, just to clarify: Thanks |
No, it will still be "#PyScript-xyz". "PY-SCRIPT".split("-") // => ["PY", "SCRIPT"]
.map(e.toLowercase()) // => ["py", "script"]
.map(e.charAt(0).toUpperCase() + e.slice(1)) // => ["Py", "Script"]
.join("") // => "PyScript" |
Got it, somehow overlooked the first split... thanks for the clarification. |
@marimeireles In case this is missed, could you give the issue title a [BUG] tag and add the bug label? |
@kumargautam99 can you try now? #395 should have temporarily fixed it (although we need to investigate to actually come with a better fix) |
Thanks for looking into it but the issue still persists.
Below is the error message.
*pyodide.asm.js:14 Uncaught (in promise) PythonError: Traceback (most
recent call last): File "<exec>", line 164, in write File "<exec>", line
116, in writeJsException: SyntaxError: Failed to execute 'querySelector' on
'Document': '#-80d2aff4-9486-153b-aff3-39d1e597fc8c' is not a valid
selector. at new_error (pyodide.asm.js:14:238191) at
pyodide.asm.wasm:0xedbcb at pyodide.asm.wasm:0xedccc at
Object.Module.callPyObjectKwargs (pyproxy.gen.ts:374:12) at
Proxy.callKwargs (pyproxy.gen.ts:1167:19) at z.evaluate
(pyscript.js:1:5845)*
[image: image.png]
…On Mon, May 16, 2022 at 9:40 PM Fabio Pliger ***@***.***> wrote:
@kumargautam99 <https://github.com/kumargautam99> can you try now? #395
<#395> should have temporarily
fixed it (although we need to investigate to actually come with a better
fix)
—
Reply to this email directly, view it on GitHub
<#370 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCX32MXAJ3LI2VSVJVQ7DLVKJXQLANCNFSM5V5DKP2A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Can you make sure you try on an incognito browser or can you flush your cache? If it still persists, can you please send some code for us to reproduce? |
Tried both (incognito browser and cache flush), the issue persists. Below is the sample code which i am using inside google chrome. pi = compute_pi(100000) |
@kumargautam99 Not sure I understand. This, pointing to the cdn, works just fine. What am I missing?
Can you paste your full example? |
I tested again with the code I posted above, and I can confirm that the issue is fixed. Thank you for your work on this. |
Awesome! Thank you @rayjolt ! |
Thank you @fpliger and community ! The issue is resolved! |
I tried the sample script for computing the value of pi.
Using the CDN url of pyscript.js and pyscript.css , 80% of the times the render is happening after Loading runtime...
But sometimes it gives the pink color section as output and no content.
Using the pyscript.js and pyscript.css locally, the Loading runtime.. persists for minutes without any output.
The text was updated successfully, but these errors were encountered: