mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 02:37:41 -05:00
[next] Provide less magic around the display (#1673)
This commit is contained in:
committed by
GitHub
parent
489a2bb20e
commit
cabb1c72b6
@@ -36,7 +36,7 @@ else {
|
||||
if (/^https?:\/\//.test(config)) config = await fetch(config).then(getText);
|
||||
|
||||
// generic helper to disambiguate between custom element and script
|
||||
const isScript = (element) => element.tagName === "SCRIPT";
|
||||
const isScript = ({ tagName }) => tagName === "SCRIPT";
|
||||
|
||||
// helper for all script[type="py"] out there
|
||||
const before = (script) => {
|
||||
@@ -91,14 +91,12 @@ const registerModule = ({ XWorker: $XWorker, interpreter, io }) => {
|
||||
}
|
||||
|
||||
// enrich the Python env with some JS utility for main
|
||||
defineProperty(globalThis, "_pyscript", {
|
||||
value: {
|
||||
PyWorker,
|
||||
get id() {
|
||||
return isScript(currentElement)
|
||||
? currentElement.target.id
|
||||
: currentElement.id;
|
||||
},
|
||||
interpreter.registerJsModule("_pyscript_js", {
|
||||
PyWorker,
|
||||
get target() {
|
||||
return isScript(currentElement)
|
||||
? currentElement.target.id
|
||||
: currentElement.id;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user