mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Patch js.document out of the box (#1880)
* Patch js.document out of the box * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
06e1fdecc2
commit
8e5605fa42
@@ -5,6 +5,7 @@ from pyscript.util import NotSupported
|
||||
RUNNING_IN_WORKER = not hasattr(globalThis, "document")
|
||||
|
||||
if RUNNING_IN_WORKER:
|
||||
import js
|
||||
import polyscript
|
||||
|
||||
PyWorker = NotSupported(
|
||||
@@ -13,6 +14,7 @@ if RUNNING_IN_WORKER:
|
||||
)
|
||||
window = polyscript.xworker.window
|
||||
document = window.document
|
||||
js.document = document
|
||||
sync = polyscript.xworker.sync
|
||||
|
||||
# in workers the display does not have a default ID
|
||||
|
||||
@@ -6,3 +6,7 @@ display("Hello World", target="test", append=True)
|
||||
print("sleeping")
|
||||
sync.sleep(1)
|
||||
print("awake")
|
||||
|
||||
import js
|
||||
|
||||
js.document.body.append("document patch ")
|
||||
|
||||
Reference in New Issue
Block a user