8000 Patch js.document out of the box (#1880) · shivashankarv/pyscript@8e5605f · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e5605f

Browse files
Patch js.document out of the box (pyscript#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>
1 parent 06e1fde commit 8e5605f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pyscript.core/src/stdlib/pyscrip 8000 t/magic_js.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
RUNNING_IN_WORKER = not hasattr(globalThis, "document")
66

77
if RUNNING_IN_WORKER:
8+
import js
89
import polyscript
910

1011
PyWorker = NotSupported(
@@ -13,6 +14,7 @@
1314
)
1415
window = polyscript.xworker.window
1516
document = window.document
17+
js.document = document
1618
sync = polyscript.xworker.sync
1719

1820
# in workers the display does not have a default ID

pyscript.core/test/worker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
print("sleeping")
77
sync.sleep(1)
88
print("awake")
9+
10+
import js
11+
12+
js.document.body.append("document patch ")

0 commit comments

Comments
 (0)
0