mirror of
https://github.com/pyscript/pyscript.git
synced 2026-03-27 02:00:24 -04:00
Add text to pydom.Element (#1911)
* add missing test for html attribute * add test for text attribute * fix text attribute test * [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> Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user