|
119 | 119 | # Bulk update all elements. |
120 | 120 | items.update_all( |
121 | 121 | innerHTML="Hello", |
122 | | - className="updated-item" |
| 122 | + classes="updated-item", |
| 123 | + style={"color": "blue"}, |
123 | 124 | ) |
124 | 125 |
|
125 | 126 | # Index and slice collections. |
@@ -1062,7 +1063,7 @@ class ElementCollection: |
1062 | 1063 | item.classes.add("processed") |
1063 | 1064 |
|
1064 | 1065 | # Bulk update all contained elements. |
1065 | | - items.update_all(innerHTML="Hello", className="updated") |
| 1066 | + items.update_all(innerHTML="Hello", classes="updated") |
1066 | 1067 |
|
1067 | 1068 | # Find matches within the collection. |
1068 | 1069 | buttons = items.find("button") |
@@ -1159,18 +1160,19 @@ def find(self, selector): |
1159 | 1160 | elements.extend(_find_and_wrap(element._dom_element, selector)) |
1160 | 1161 | return ElementCollection(elements) |
1161 | 1162 |
|
1162 | | - def update_all(self, **kwargs): |
| 1163 | + def update_all(self, classes=None, style=None, **kwargs): |
1163 | 1164 | """ |
1164 | | - Explicitly update all elements with the given attributes. |
| 1165 | + Explicitly update all elements with the given `classes`, `style`, and |
| 1166 | + `attributes`. Delegates to each element's `update` method. |
1165 | 1167 |
|
1166 | 1168 | ```python |
1167 | 1169 | collection.update_all(innerHTML="Hello") |
| 1170 | + collection.update_all(classes="active", style={"color": "red"}) |
1168 | 1171 | collection.update_all(className="active", title="Updated") |
1169 | 1172 | ``` |
1170 | 1173 | """ |
1171 | 1174 | for element in self._elements: |
1172 | | - for name, value in kwargs.items(): |
1173 | | - setattr(element, name, value) |
| 1175 | + element.update(classes=classes, style=style, **kwargs) |
1174 | 1176 |
|
1175 | 1177 |
|
1176 | 1178 | # Special elements with custom methods and mixins. |
|
0 commit comments