[next] allow document.createElement(py-script) (#1662)

This commit is contained in:
Andrea Giammarchi
2023-08-31 14:23:01 +02:00
committed by GitHub
parent 74cd7c840a
commit 4cc9647dc6
3 changed files with 49 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ import { Hook } from "../node_modules/polyscript/esm/worker/hooks.js";
import { robustFetch as fetch } from "./fetch.js";
const { defineProperty } = Object;
const { assign, defineProperty } = Object;
const getText = (body) => body.text();
@@ -231,10 +231,17 @@ define("py", {
class PyScriptElement extends HTMLElement {
constructor() {
if (!super().id) this.id = getID();
this._pyodide = Promise.withResolvers();
this.srcCode = "";
this.executed = false;
assign(super(), {
_pyodide: Promise.withResolvers(),
srcCode: "",
executed: false,
});
}
get id() {
return super.id || (super.id = getID());
}
set id(value) {
super.id = value;
}
async connectedCallback() {
if (!this.executed) {