diff --git a/pyscript.core/src/stdlib/pyweb/pydom.py b/pyscript.core/src/stdlib/pyweb/pydom.py index a9110faa..6a2a4289 100644 --- a/pyscript.core/src/stdlib/pyweb/pydom.py +++ b/pyscript.core/src/stdlib/pyweb/pydom.py @@ -125,6 +125,14 @@ class Element(BaseElement): def html(self, value): self._js.innerHTML = value + @property + def text(self): + return self._js.textContent + + @text.setter + def text(self, value): + self._js.textContent = value + @property def content(self): # TODO: This breaks with with standard template elements. Define how to best diff --git a/pyscript.core/test/pyscript_dom/index.html b/pyscript.core/test/pyscript_dom/index.html index 60e044f5..553be596 100644 --- a/pyscript.core/test/pyscript_dom/index.html +++ b/pyscript.core/test/pyscript_dom/index.html @@ -98,6 +98,8 @@

+ +
diff --git a/pyscript.core/test/pyscript_dom/tests/test_dom.py b/pyscript.core/test/pyscript_dom/tests/test_dom.py index 49c96a5a..d3a23c80 100644 --- a/pyscript.core/test/pyscript_dom/tests/test_dom.py +++ b/pyscript.core/test/pyscript_dom/tests/test_dom.py @@ -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 = "New Content" + + # EXPECT the element html and underlying JS Element innerHTML property + # to match what we expect and what + assert div.html == div._js.innerHTML == "New Content" + 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 = "New Content" + + # 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" + class TestCollection: def test_iter_eq_children(self): diff --git a/pyscript.core/types/3rd-party/codemirror.d.ts b/pyscript.core/types/3rd-party/codemirror.d.ts index 2a1a953a..cb0ff5c3 100644 --- a/pyscript.core/types/3rd-party/codemirror.d.ts +++ b/pyscript.core/types/3rd-party/codemirror.d.ts @@ -1 +1 @@ -export * from "codemirror"; +export {}; diff --git a/pyscript.core/types/3rd-party/codemirror_commands.d.ts b/pyscript.core/types/3rd-party/codemirror_commands.d.ts index 1862cebc..cb0ff5c3 100644 --- a/pyscript.core/types/3rd-party/codemirror_commands.d.ts +++ b/pyscript.core/types/3rd-party/codemirror_commands.d.ts @@ -1 +1 @@ -export * from "@codemirror/commands"; +export {}; diff --git a/pyscript.core/types/3rd-party/codemirror_lang-python.d.ts b/pyscript.core/types/3rd-party/codemirror_lang-python.d.ts index 76b718d3..cb0ff5c3 100644 --- a/pyscript.core/types/3rd-party/codemirror_lang-python.d.ts +++ b/pyscript.core/types/3rd-party/codemirror_lang-python.d.ts @@ -1 +1 @@ -export * from "@codemirror/lang-python"; +export {}; diff --git a/pyscript.core/types/3rd-party/codemirror_language.d.ts b/pyscript.core/types/3rd-party/codemirror_language.d.ts index 632a9f72..cb0ff5c3 100644 --- a/pyscript.core/types/3rd-party/codemirror_language.d.ts +++ b/pyscript.core/types/3rd-party/codemirror_language.d.ts @@ -1 +1 @@ -export * from "@codemirror/language"; +export {}; diff --git a/pyscript.core/types/3rd-party/codemirror_state.d.ts b/pyscript.core/types/3rd-party/codemirror_state.d.ts index 9dd5c97d..cb0ff5c3 100644 --- a/pyscript.core/types/3rd-party/codemirror_state.d.ts +++ b/pyscript.core/types/3rd-party/codemirror_state.d.ts @@ -1 +1 @@ -export * from "@codemirror/state"; +export {}; diff --git a/pyscript.core/types/3rd-party/codemirror_view.d.ts b/pyscript.core/types/3rd-party/codemirror_view.d.ts index 3669d051..cb0ff5c3 100644 --- a/pyscript.core/types/3rd-party/codemirror_view.d.ts +++ b/pyscript.core/types/3rd-party/codemirror_view.d.ts @@ -1 +1 @@ -export * from "@codemirror/view"; +export {};