Skip to content

Commit 8891a71

Browse files
committed
use stringigfy_id
1 parent dfdb605 commit 8891a71

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

dash/_callback_context.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import flask
88

99
from . import exceptions
10-
from ._utils import AttributeDict
10+
from ._utils import AttributeDict, stringify_id
1111

1212

1313
context_value = contextvars.ContextVar("callback_context")
@@ -251,10 +251,8 @@ def timing_information(self):
251251
@has_context
252252
def set_props(self, component_id: typing.Union[str, dict], props: dict):
253253
ctx_value = _get_context_value()
254-
if isinstance(component_id, dict):
255-
ctx_value.updated_props[json.dumps(component_id)] = props
256-
else:
257-
ctx_value.updated_props[component_id] = props
254+
_id = stringify_id(component_id)
255+
ctx_value.updated_props[_id] = props
258256

259257

260258
callback_context = CallbackContext()

dash/dependencies.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import json
21
from dash.development.base_component import Component
32

43
from ._validate import validate_callback
54
from ._grouping import flatten_grouping, make_grouping_by_index
5+
from ._utils import stringify_id
66

77

88
class _Wildcard: # pylint: disable=too-few-public-methods
@@ -44,19 +44,7 @@ def __repr__(self):
4444
return f"<{self.__class__.__name__} `{self}`>"
4545

4646
def component_id_str(self):
47-
i = self.component_id
48-
49-
def _dump(v):
50-
return json.dumps(v, sort_keys=True, separators=(",", ":"))
51-
52-
def _json(k, v):
53-
vstr = v.to_json() if hasattr(v, "to_json") else json.dumps(v)
54-
return f"{json.dumps(k)}:{vstr}"
55-
56-
if isinstance(i, dict):
57-
return "{" + ",".join(_json(k, i[k]) for k in sorted(i)) + "}"
58-
59-
return i
47+
return stringify_id(self.component_id)
6048

6149
def to_dict(self):
6250
return {"id": self.component_id_str(), "property": self.component_property}

0 commit comments

Comments
 (0)