Skip to content

Evaluate dynamically added <py-script> tag #690

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

Closed
wants to merge 2 commits into from

Conversation

hoge1e3
Copy link
Contributor

@hoge1e3 hoge1e3 commented Aug 14, 2022

In original version, the element created by document.createElement("py-script") after pyodide runtime initialization does not evaluate script content.

Here is an example (run in browser console):

       let pys=document.createElement("py-script");
       pys.setAttribute("output", "graph"); // <div id="graph"> should be present.
       let tx=document.createTextNode("print(5+10)");
       pys.appendChild(tx);
       document.body.appendChild(pys);

This is because tags in scriptsQueue( added on creation of the tags) runs only on runtime initialization.

This commit changes addToScriptsQueue so that evaluate the script instantly instead of adding to the queue when it is called after runtime initialization. The example shown above produces output 15.

Copy link
Contributor

@fpliger fpliger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoge1e3 thanks for the contribution! The evaluation system needs some design improvements but this is a solid fix for the specific issue and I think we should merge. Can you please add an integration test to the basic integration tests so that we can test before/after?
Thank you!

hoge1e3 and others added 2 commits August 26, 2022 16:30
In original version, the element created by document.createElement("py-script") after pyodide runtime initialization does not evaluate script content because tags in scriptsQueue( added on creation of the <py-script> tags) runs only on runtime initialization.
This commit changes addToScriptsQueue so that evaluate the script instantly instead of adding to the queue when it is called after runtime initialization.
@marimeireles
Copy link
Contributor

Hey'all so I rebased it to match main.
But I don't fully understand this PR.
So... After @hoge1e3 changes we were supposed to see 15 on the browser as the code was supposed to be evaluated, correct?
But this is not happening to me.
Maybe I don't get it? With an explanation on it I can write some tests so we can merge this :)
Cheers

@marimeireles
Copy link
Contributor

Also please start a new branch on your local dev. env. @hoge1e3, with git checkout -b branch_name. It makes it much easier to contribute! :)
Maybe we should have a how to on our docs.

@marimeireles marimeireles added the waiting on reporter Further information is requested from the reported label Sep 12, 2022
@JeffersGlass
Copy link
Contributor

I believe this PR has been superseded by the work in #881; the test_dynamically_add_py_script_tag test confirms that dynamically added <py-script> tags are executed.

@JeffersGlass JeffersGlass added the status: superseded PR that has been superseded by another PR label Nov 10, 2022
@tedpatrick
Copy link
Contributor

Thank you for your PR contribution to PyScript. We are closing PRs older than 90 days with limited activity.

@tedpatrick tedpatrick closed this Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded PR that has been superseded by another PR waiting on reporter Further information is requested from the reported
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy