Skip to content

Commit

Permalink
html: AttributeDict: __delitem__: add support for patch issuer
Browse files Browse the repository at this point in the history
With the `issuer` argument it is possible to make changes that don't get rolled
out to the original issuer of the change. In this particular case this is meant
to be used for radio buttons to synchronize the `checked` property on the
backend with the frontend.

Signed-off-by: Florian Scherf <mail@florianscherf.de>
  • Loading branch information
fscherf committed Jul 7, 2023
1 parent b1b30f3 commit 92a12aa
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lona/html/attribute_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,22 @@ def __setitem__(self, name, value, issuer=None):
issuer=issuer,
)

def __delitem__(self, name):
self.pop(name, None)
def __delitem__(self, name, issuer=None):
with self._node.lock:
if name not in self._attributes:
return

del self._attributes[name]

self._node.document.add_patch(
node_id=self._node.id,
patch_type=self.PATCH_TYPE,
operation=OPERATION.REMOVE,
payload=[
name,
],
issuer=issuer,
)

def __eq__(self, other):
with self._node.lock:
Expand Down

0 comments on commit 92a12aa

Please sign in to comment.