add global JS attributes to elements and improve demos

This commit is contained in:
Fabio Pliger
2024-02-02 09:00:47 -06:00
parent fb584c3984
commit 05a5fb7ff2
5 changed files with 78 additions and 123 deletions

View File

@@ -24,6 +24,7 @@ GLOBAL_ATTRIBUTES = [
"title",
"translate",
"virtualkeyboardpolicy",
"className"
]
# class and style are different ones that are handled by pydom.element directly
@@ -78,7 +79,11 @@ class TextElementBase(ElementBase):
def _add_js_properties(cls, *attrs):
"""Add JSProperties to a class as `js_property` class attributes."""
# First we set all the properties as JSProperties
# First we set all the global properties as JSProperties
for attr in GLOBAL_ATTRIBUTES:
setattr(cls, attr, js_property(attr))
# Now the specific class properties
for attr in attrs:
setattr(cls, attr, js_property(attr))
@@ -257,6 +262,7 @@ class br(ElementBase):
class div(TextElementBase):
tag = "div"
_add_js_properties(div)
class img(ElementBase):
tag = "img"