mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Merge branch 'main' into poc_ui_blocks
This commit is contained in:
19
pyscript.core/test/code-a-part.html
Normal file
19
pyscript.core/test/code-a-part.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="../dist/core.css">
|
||||
<script type="module">
|
||||
import { hooks } from "../dist/core.js";
|
||||
hooks.main.codeBeforeRun.add('print(0)');
|
||||
hooks.main.codeAfterRun.add('print(2)');
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="py">
|
||||
# raise an error instead to see it on line 1
|
||||
print(1)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
23
pyscript.core/test/no_sab/index.html
Normal file
23
pyscript.core/test/no_sab/index.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../../dist/core.css">
|
||||
<script type="module">
|
||||
import { PyWorker } from '../../dist/core.js';
|
||||
const { sync } = await PyWorker(
|
||||
'./worker.py',
|
||||
{
|
||||
config: {
|
||||
sync_main_only: true
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
document.documentElement.classList.add(
|
||||
await sync.get_class()
|
||||
);
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
3
pyscript.core/test/no_sab/worker.py
Normal file
3
pyscript.core/test/no_sab/worker.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from pyscript import sync
|
||||
|
||||
sync.get_class = lambda: "ok"
|
||||
@@ -98,6 +98,8 @@
|
||||
<p class="collection"></p>
|
||||
<div class="collection"></div>
|
||||
<h3 class="collection"></h3>
|
||||
|
||||
<div id="element_attribute_tests"></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -163,6 +163,30 @@ class TestElement:
|
||||
|
||||
assert called
|
||||
|
||||
def test_html_attribute(self):
|
||||
# GIVEN an existing element on the page with a known empty text content
|
||||
div = pydom["#element_attribute_tests"][0]
|
||||
|
||||
# WHEN we set the html attribute
|
||||
div.html = "<b>New Content</b>"
|
||||
|
||||
# EXPECT the element html and underlying JS Element innerHTML property
|
||||
# to match what we expect and what
|
||||
assert div.html == div._js.innerHTML == "<b>New Content</b>"
|
||||
assert div.text == div._js.textContent == "New Content"
|
||||
|
||||
def test_text_attribute(self):
|
||||
# GIVEN an existing element on the page with a known empty text content
|
||||
div = pydom["#element_attribute_tests"][0]
|
||||
|
||||
# WHEN we set the html attribute
|
||||
div.text = "<b>New Content</b>"
|
||||
|
||||
# EXPECT the element html and underlying JS Element innerHTML property
|
||||
# to match what we expect and what
|
||||
assert div.html == div._js.innerHTML == "<b>New Content</b>"
|
||||
assert div.text == div._js.textContent == "<b>New Content</b>"
|
||||
|
||||
|
||||
class TestCollection:
|
||||
def test_iter_eq_children(self):
|
||||
|
||||
0
pyscript.core/test/test.html
Normal file
0
pyscript.core/test/test.html
Normal file
Reference in New Issue
Block a user