Skip to content

Commit 59635fe

Browse files
iliketocode2ntoll
authored andcommitted
update docs for update_all changes
1 parent 92744e2 commit 59635fe

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

pyscript/web.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@
119119
# Bulk update all elements.
120120
items.update_all(
121121
innerHTML="Hello",
122-
className="updated-item"
122+
classes="updated-item",
123+
style={"color": "blue"},
123124
)
124125
125126
# Index and slice collections.
@@ -1062,7 +1063,7 @@ class ElementCollection:
10621063
item.classes.add("processed")
10631064
10641065
# Bulk update all contained elements.
1065-
items.update_all(innerHTML="Hello", className="updated")
1066+
items.update_all(innerHTML="Hello", classes="updated")
10661067
10671068
# Find matches within the collection.
10681069
buttons = items.find("button")
@@ -1159,18 +1160,19 @@ def find(self, selector):
11591160
elements.extend(_find_and_wrap(element._dom_element, selector))
11601161
return ElementCollection(elements)
11611162

1162-
def update_all(self, **kwargs):
1163+
def update_all(self, classes=None, style=None, **kwargs):
11631164
"""
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.
11651167
11661168
```python
11671169
collection.update_all(innerHTML="Hello")
1170+
collection.update_all(classes="active", style={"color": "red"})
11681171
collection.update_all(className="active", title="Updated")
11691172
```
11701173
"""
11711174
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)
11741176

11751177

11761178
# Special elements with custom methods and mixins.

0 commit comments

Comments
 (0)