Skip to content

Commit 25e4c56

Browse files
authored
Merge pull request #60 from rmarren1/no-id-error
Check that id exists before triggering callback.
2 parents 70bb93e + 0798987 commit 25e4c56

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [0.13.1] - 2018-07-18
6+
### Fixed
7+
- If a callback references an `id` which does not exist in the DOM tree at the time it is executed, throw an informative front-end exception (previously an uninformative front-end exception was thrown). https://github.com/plotly/dash-renderer/issues/57
8+
59
## [0.13.0] - 2018-06-01
610
### Fixed
711
- Previously, if a component called `updateProps` with multiple properties, Dash would fire the callback multiple times (once for each property). Now, the callback is only fired once. https://github.com/plotly/dash-renderer/pull/54

dash_renderer/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.13.0'
1+
__version__ = '0.13.1'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-renderer",
3-
"version": "0.13.0",
3+
"version": "0.13.1",
44
"description": "render dash components in react",
55
"main": "src/index.js",
66
"scripts": {

src/actions/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,21 @@ function updateOutput(
417417
dependency.output.property === outputProp
418418
)
419419
);
420+
const validKeys = keys(paths);
420421
if (inputs.length > 0) {
421422
payload.inputs = inputs.map(inputObject => {
423+
// Make sure the component id exists in the layout
424+
if (!contains(inputObject.id, validKeys)) {
425+
throw ReferenceError(
426+
"An invalid input object was used in an " +
427+
"`Input` of a Dash callback. " +
428+
"The id of this object is `" +
429+
inputObject.id + "` and the property is `" +
430+
inputObject.property +
431+
"`. The list of ids in the current layout is " +
432+
"`[" + validKeys.join(", ") + "]`"
433+
)
434+
}
422435
const propLens = lensPath(
423436
concat(paths[inputObject.id],
424437
['props', inputObject.property]
@@ -432,6 +445,18 @@ function updateOutput(
432445
}
433446
if (state.length > 0) {
434447
payload.state = state.map(stateObject => {
448+
// Make sure the component id exists in the layout
449+
if (!contains(stateObject.id, validKeys)) {
450+
throw ReferenceError(
451+
"An invalid input object was used in a " +
452+
"`State` object of a Dash callback. " +
453+
"The id of this object is `" +
454+
stateObject.id + "` and the property is `" +
455+
stateObject.property +
456+
"`. The list of ids in the current layout is " +
457+
"`[" + validKeys.join(", ") + "]`"
458+
)
459+
}
435460
const propLens = lensPath(
436461
concat(paths[stateObject.id],
437462
['props', stateObject.property]

0 commit comments

Comments
 (0)