[next] Place a target in the body (#1658)

This commit is contained in:
Andrea Giammarchi
2023-08-30 14:43:48 +02:00
committed by GitHub
parent 93539c9b5a
commit 0f2deeb71a
3 changed files with 17 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@@ -199,7 +199,11 @@ define("py", {
? queryTarget(target.value)
: document.createElement("script-py");
if (!hasTarget) element.after(show);
if (!hasTarget) {
const { head, body } = document;
if (head.contains(element)) body.append(show);
else element.after(show);
}
if (!show.id) show.id = getID();
// allows the code to retrieve the target element via

View File

@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<script type="module" src="../core.js"></script>
<script type="py">
from pyscript import display
display('hello\nworld')
</script>
</head>
</html>