add address test and improve error messaging when ElementBase gets a bad input as style

This commit is contained in:
Fabio Pliger
2024-02-27 11:41:10 -06:00
parent 6dccf08834
commit 51dc0909ac
2 changed files with 9 additions and 1 deletions

View File

@@ -77,9 +77,13 @@ class ElementBase(pydom.Element):
super().__init__(document.createElement(self.tag))
# set all the style properties provided in input
if style:
if isinstance(style, dict):
for key, value in style.items():
self.style[key] = value
elif style is None:
pass
else:
raise ValueError(f"Style should be a dictionary, received {style} (type {type(style)}) instead.")
# IMPORTANT!!! This is used to auto-harvest all input arguments and set them as properties
self._init_properties(**kwargs)