Skip to content

Commit 0dc6f33

Browse files
authored
Merge pull request #62 from rmarren1/true-false-error
Don't throw front end exception when rendering boolean
2 parents 25e4c56 + 23f2ed2 commit 0dc6f33

File tree

3 files changed

+65
-59
lines changed

3 files changed

+65
-59
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.2] - 2018-07-24
6+
### Fixed
7+
- Attempting to render a `Boolean` value to the page no longer crashes the app.
8+
59
## [0.13.1] - 2018-07-18
610
### Fixed
711
- 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

src/TreeContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ TreeContainer.propTypes = {
2121
}
2222

2323
function render(component) {
24-
if (R.contains(R.type(component), ['String', 'Number', 'Null'])) {
24+
if (R.contains(R.type(component), ['String', 'Number', 'Null', 'Boolean'])) {
2525
return component;
2626
}
2727

@@ -39,7 +39,7 @@ function render(component) {
3939

4040
} else if (R.contains(
4141
R.type(component.props.children),
42-
['String', 'Number', 'Null'])
42+
['String', 'Number', 'Null', 'Boolean'])
4343
) {
4444

4545
children = [component.props.children];

tests/test_render.py

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -73,38 +73,39 @@ def test_initial_state(self):
7373
app.layout = html.Div([
7474
'Basic string',
7575
3.14,
76+
True,
7677
None,
7778
html.Div('Child div with basic string',
78-
id='p.c.3',
79+
id='p.c.4',
7980
className="my-class",
8081
title='tooltip',
8182
style={'color': 'red', 'fontSize': 30}
8283
),
83-
html.Div(id='p.c.4'),
84+
html.Div(id='p.c.5'),
8485
html.Div([
85-
html.Div('Grandchild div', id='p.c.5.p.c.0'),
86+
html.Div('Grandchild div', id='p.c.6.p.c.0'),
8687
html.Div([
87-
html.Div('Great grandchild', id='p.c.5.p.c.1.p.c.0'),
88+
html.Div('Great grandchild', id='p.c.6.p.c.1.p.c.0'),
8889
3.14159,
8990
'another basic string'
90-
], id='p.c.5.p.c.1'),
91+
], id='p.c.6.p.c.1'),
9192
html.Div([
9293
html.Div(
9394
html.Div([
9495
html.Div([
9596
html.Div(
96-
id='p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.0'
97+
id='p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.0'
9798
),
9899
'',
99100
html.Div(
100-
id='p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.2'
101+
id='p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.2'
101102
)
102-
], id='p.c.5.p.c.2.p.c.0.p.c.p.c.0')
103-
], id='p.c.5.p.c.2.p.c.0.p.c'),
104-
id='p.c.5.p.c.2.p.c.0'
103+
], id='p.c.6.p.c.2.p.c.0.p.c.p.c.0')
104+
], id='p.c.6.p.c.2.p.c.0.p.c'),
105+
id='p.c.6.p.c.2.p.c.0'
105106
)
106-
], id='p.c.5.p.c.2')
107-
], id='p.c.5')
107+
], id='p.c.6.p.c.2')
108+
], id='p.c.6')
108109
])
109110

110111
self.startServer(app)
@@ -122,16 +123,16 @@ def test_initial_state(self):
122123
Child div with basic string
123124
</div>
124125
125-
<div id="p.c.4">
126+
<div id="p.c.5">
126127
</div>
127128
128-
<div id="p.c.5">
129-
<div id="p.c.5.p.c.0">
129+
<div id="p.c.6">
130+
<div id="p.c.6.p.c.0">
130131
Grandchild div
131132
</div>
132133
133-
<div id="p.c.5.p.c.1">
134-
<div id="p.c.5.p.c.1.p.c.0">
134+
<div id="p.c.6.p.c.1">
135+
<div id="p.c.6.p.c.1.p.c.0">
135136
Great grandchild
136137
</div>
137138
@@ -140,16 +141,16 @@ def test_initial_state(self):
140141
another basic string
141142
</div>
142143
143-
<div id="p.c.5.p.c.2">
144-
<div id="p.c.5.p.c.2.p.c.0">
145-
<div id="p.c.5.p.c.2.p.c.0.p.c">
146-
<div id="p.c.5.p.c.2.p.c.0.p.c.p.c.0">
144+
<div id="p.c.6.p.c.2">
145+
<div id="p.c.6.p.c.2.p.c.0">
146+
<div id="p.c.6.p.c.2.p.c.0.p.c">
147+
<div id="p.c.6.p.c.2.p.c.0.p.c.p.c.0">
147148
148-
<div id="p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.0">
149+
<div id="p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.0">
149150
</div>
150151
151152
152-
<div id="p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.2">
153+
<div id="p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.2">
153154
</div>
154155
155156
</div>
@@ -171,7 +172,7 @@ def test_initial_state(self):
171172
'style="font-size: 30px; color: red;"'
172173
]
173174
permutations = itertools.permutations([
174-
'id="p.c.3"',
175+
'id="p.c.4"',
175176
'class="my-class"',
176177
'title="tooltip"',
177178
], 3)
@@ -224,12 +225,13 @@ def test_initial_state(self):
224225
"children": [
225226
"Basic string",
226227
3.14,
228+
True,
227229
None,
228230
{
229231
"namespace": "dash_html_components",
230232
"props": {
231233
"children": "Child div with basic string",
232-
"id": "p.c.3",
234+
"id": "p.c.4",
233235
'className': "my-class",
234236
'title': 'tooltip',
235237
'style': {
@@ -242,7 +244,7 @@ def test_initial_state(self):
242244
"namespace": "dash_html_components",
243245
"props": {
244246
"children": None,
245-
"id": "p.c.4"
247+
"id": "p.c.5"
246248
},
247249
"type": "Div"
248250
},
@@ -254,7 +256,7 @@ def test_initial_state(self):
254256
"namespace": "dash_html_components",
255257
"props": {
256258
"children": "Grandchild div",
257-
"id": "p.c.5.p.c.0"
259+
"id": "p.c.6.p.c.0"
258260
},
259261
"type": "Div"
260262
},
@@ -266,14 +268,14 @@ def test_initial_state(self):
266268
"namespace": "dash_html_components",
267269
"props": {
268270
"children": "Great grandchild",
269-
"id": "p.c.5.p.c.1.p.c.0"
271+
"id": "p.c.6.p.c.1.p.c.0"
270272
},
271273
"type": "Div"
272274
},
273275
3.14159,
274276
"another basic string"
275277
],
276-
"id": "p.c.5.p.c.1"
278+
"id": "p.c.6.p.c.1"
277279
},
278280
"type": "Div"
279281
},
@@ -296,7 +298,7 @@ def test_initial_state(self):
296298
"namespace": "dash_html_components",
297299
"props": {
298300
"children": None,
299-
"id": "p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.0"
301+
"id": "p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.0"
300302
},
301303
"type": "Div"
302304
},
@@ -305,31 +307,31 @@ def test_initial_state(self):
305307
"namespace": "dash_html_components",
306308
"props": {
307309
"children": None,
308-
"id": "p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.2"
310+
"id": "p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.2"
309311
},
310312
"type": "Div"
311313
}
312314
],
313-
"id": "p.c.5.p.c.2.p.c.0.p.c.p.c.0"
315+
"id": "p.c.6.p.c.2.p.c.0.p.c.p.c.0"
314316
},
315317
"type": "Div"
316318
}
317319
],
318-
"id": "p.c.5.p.c.2.p.c.0.p.c"
320+
"id": "p.c.6.p.c.2.p.c.0.p.c"
319321
},
320322
"type": "Div"
321323
},
322-
"id": "p.c.5.p.c.2.p.c.0"
324+
"id": "p.c.6.p.c.2.p.c.0"
323325
},
324326
"type": "Div"
325327
}
326328
],
327-
"id": "p.c.5.p.c.2"
329+
"id": "p.c.6.p.c.2"
328330
},
329331
"type": "Div"
330332
}
331333
],
332-
"id": "p.c.5"
334+
"id": "p.c.6"
333335
},
334336
"type": "Div"
335337
}
@@ -369,60 +371,60 @@ def test_initial_state(self):
369371
'return window.store.getState().paths'
370372
),
371373
{
372-
"p.c.3": [
373-
"props", "children", 3
374-
],
375374
"p.c.4": [
376375
"props", "children", 4
377376
],
378377
"p.c.5": [
379378
"props", "children", 5
380379
],
381-
"p.c.5.p.c.0": [
382-
"props", "children", 5,
380+
"p.c.6": [
381+
"props", "children", 6
382+
],
383+
"p.c.6.p.c.0": [
384+
"props", "children", 6,
383385
"props", "children", 0
384386
],
385-
"p.c.5.p.c.1": [
386-
"props", "children", 5,
387+
"p.c.6.p.c.1": [
388+
"props", "children", 6,
387389
"props", "children", 1
388390
],
389-
"p.c.5.p.c.1.p.c.0": [
390-
"props", "children", 5,
391+
"p.c.6.p.c.1.p.c.0": [
392+
"props", "children", 6,
391393
"props", "children", 1,
392394
"props", "children", 0
393395
],
394-
"p.c.5.p.c.2": [
395-
"props", "children", 5,
396+
"p.c.6.p.c.2": [
397+
"props", "children", 6,
396398
"props", "children", 2
397399
],
398-
"p.c.5.p.c.2.p.c.0": [
399-
"props", "children", 5,
400+
"p.c.6.p.c.2.p.c.0": [
401+
"props", "children", 6,
400402
"props", "children", 2,
401403
"props", "children", 0
402404
],
403-
"p.c.5.p.c.2.p.c.0.p.c": [
404-
"props", "children", 5,
405+
"p.c.6.p.c.2.p.c.0.p.c": [
406+
"props", "children", 6,
405407
"props", "children", 2,
406408
"props", "children", 0,
407409
"props", "children"
408410
],
409-
"p.c.5.p.c.2.p.c.0.p.c.p.c.0": [
410-
"props", "children", 5,
411+
"p.c.6.p.c.2.p.c.0.p.c.p.c.0": [
412+
"props", "children", 6,
411413
"props", "children", 2,
412414
"props", "children", 0,
413415
"props", "children",
414416
"props", "children", 0
415417
],
416-
"p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.0": [
417-
"props", "children", 5,
418+
"p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.0": [
419+
"props", "children", 6,
418420
"props", "children", 2,
419421
"props", "children", 0,
420422
"props", "children",
421423
"props", "children", 0,
422424
"props", "children", 0
423425
],
424-
"p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.2": [
425-
"props", "children", 5,
426+
"p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.2": [
427+
"props", "children", 6,
426428
"props", "children", 2,
427429
"props", "children", 0,
428430
"props", "children",

0 commit comments

Comments
 (0)