From 19e20846bef46a576e2457f46ca499659c5eb24c Mon Sep 17 00:00:00 2001 From: Ryan Marren Date: Wed, 18 Jul 2018 22:00:42 -0400 Subject: [PATCH 1/4] Don't throw front end exception when rendering boolean --- CHANGELOG.md | 4 ++++ dash_renderer/version.py | 2 +- package.json | 2 +- src/TreeContainer.js | 4 ++-- tests/test_render.py | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b90c633..0441e9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.13.1] - 2018-07-18 +### Fixed +- Attempting to render a `Boolean` value to the page no longer crashes the app. + ## [0.13.0] - 2018-06-01 ### Fixed - 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 diff --git a/dash_renderer/version.py b/dash_renderer/version.py index 2d7893e..deea98b 100644 --- a/dash_renderer/version.py +++ b/dash_renderer/version.py @@ -1 +1 @@ -__version__ = '0.13.0' +__version__ = '0.13.1' diff --git a/package.json b/package.json index f5fdb57..4fdc378 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dash-renderer", - "version": "0.13.0", + "version": "0.13.1", "description": "render dash components in react", "main": "src/index.js", "scripts": { diff --git a/src/TreeContainer.js b/src/TreeContainer.js index 5c827d2..5250d6c 100644 --- a/src/TreeContainer.js +++ b/src/TreeContainer.js @@ -21,7 +21,7 @@ TreeContainer.propTypes = { } function render(component) { - if (R.contains(R.type(component), ['String', 'Number', 'Null'])) { + if (R.contains(R.type(component), ['String', 'Number', 'Null', 'Boolean'])) { return component; } @@ -39,7 +39,7 @@ function render(component) { } else if (R.contains( R.type(component.props.children), - ['String', 'Number', 'Null']) + ['String', 'Number', 'Null', 'Boolean']) ) { children = [component.props.children]; diff --git a/tests/test_render.py b/tests/test_render.py index 0a3f946..df4bcc3 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -73,6 +73,7 @@ def test_initial_state(self): app.layout = html.Div([ 'Basic string', 3.14, + True, None, html.Div('Child div with basic string', id='p.c.3', From e41291338eb2501b27a21ecd1c4fde9a2053ea0f Mon Sep 17 00:00:00 2001 From: Ryan Marren Date: Fri, 20 Jul 2018 09:05:58 -0400 Subject: [PATCH 2/4] Fix test case --- tests/test_render.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_render.py b/tests/test_render.py index df4bcc3..f86c5d5 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -225,6 +225,7 @@ def test_initial_state(self): "children": [ "Basic string", 3.14, + True, None, { "namespace": "dash_html_components", From 001dc608c36c02b823548972432c00af23aeba55 Mon Sep 17 00:00:00 2001 From: Ryan Marren Date: Fri, 20 Jul 2018 09:24:03 -0400 Subject: [PATCH 3/4] Fix paths --- tests/test_render.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_render.py b/tests/test_render.py index f86c5d5..6c65c60 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -372,10 +372,10 @@ def test_initial_state(self): ), { "p.c.3": [ - "props", "children", 3 + "props", "children", 4 ], "p.c.4": [ - "props", "children", 4 + "props", "children", 5 ], "p.c.5": [ "props", "children", 5 From fe590d85da7920143d954cd553d80f5f686d56a1 Mon Sep 17 00:00:00 2001 From: Ryan Marren Date: Tue, 24 Jul 2018 00:12:24 -0400 Subject: [PATCH 4/4] Fix test_initial_state test cases --- tests/test_render.py | 116 +++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/tests/test_render.py b/tests/test_render.py index 6c65c60..dc1c68e 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -76,36 +76,36 @@ def test_initial_state(self): True, None, html.Div('Child div with basic string', - id='p.c.3', + id='p.c.4', className="my-class", title='tooltip', style={'color': 'red', 'fontSize': 30} ), - html.Div(id='p.c.4'), + html.Div(id='p.c.5'), html.Div([ - html.Div('Grandchild div', id='p.c.5.p.c.0'), + html.Div('Grandchild div', id='p.c.6.p.c.0'), html.Div([ - html.Div('Great grandchild', id='p.c.5.p.c.1.p.c.0'), + html.Div('Great grandchild', id='p.c.6.p.c.1.p.c.0'), 3.14159, 'another basic string' - ], id='p.c.5.p.c.1'), + ], id='p.c.6.p.c.1'), html.Div([ html.Div( html.Div([ html.Div([ html.Div( - id='p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.0' + id='p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.0' ), '', html.Div( - id='p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.2' + id='p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.2' ) - ], id='p.c.5.p.c.2.p.c.0.p.c.p.c.0') - ], id='p.c.5.p.c.2.p.c.0.p.c'), - id='p.c.5.p.c.2.p.c.0' + ], id='p.c.6.p.c.2.p.c.0.p.c.p.c.0') + ], id='p.c.6.p.c.2.p.c.0.p.c'), + id='p.c.6.p.c.2.p.c.0' ) - ], id='p.c.5.p.c.2') - ], id='p.c.5') + ], id='p.c.6.p.c.2') + ], id='p.c.6') ]) self.startServer(app) @@ -123,16 +123,16 @@ def test_initial_state(self): Child div with basic string -
+
-
-
+
+
Grandchild div
-
-
+
+
Great grandchild
@@ -141,16 +141,16 @@ def test_initial_state(self): another basic string
-
-
-
-
+
+
+
+
-
+
-
+
@@ -172,7 +172,7 @@ def test_initial_state(self): 'style="font-size: 30px; color: red;"' ] permutations = itertools.permutations([ - 'id="p.c.3"', + 'id="p.c.4"', 'class="my-class"', 'title="tooltip"', ], 3) @@ -231,7 +231,7 @@ def test_initial_state(self): "namespace": "dash_html_components", "props": { "children": "Child div with basic string", - "id": "p.c.3", + "id": "p.c.4", 'className': "my-class", 'title': 'tooltip', 'style': { @@ -244,7 +244,7 @@ def test_initial_state(self): "namespace": "dash_html_components", "props": { "children": None, - "id": "p.c.4" + "id": "p.c.5" }, "type": "Div" }, @@ -256,7 +256,7 @@ def test_initial_state(self): "namespace": "dash_html_components", "props": { "children": "Grandchild div", - "id": "p.c.5.p.c.0" + "id": "p.c.6.p.c.0" }, "type": "Div" }, @@ -268,14 +268,14 @@ def test_initial_state(self): "namespace": "dash_html_components", "props": { "children": "Great grandchild", - "id": "p.c.5.p.c.1.p.c.0" + "id": "p.c.6.p.c.1.p.c.0" }, "type": "Div" }, 3.14159, "another basic string" ], - "id": "p.c.5.p.c.1" + "id": "p.c.6.p.c.1" }, "type": "Div" }, @@ -298,7 +298,7 @@ def test_initial_state(self): "namespace": "dash_html_components", "props": { "children": None, - "id": "p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.0" + "id": "p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.0" }, "type": "Div" }, @@ -307,31 +307,31 @@ def test_initial_state(self): "namespace": "dash_html_components", "props": { "children": None, - "id": "p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.2" + "id": "p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.2" }, "type": "Div" } ], - "id": "p.c.5.p.c.2.p.c.0.p.c.p.c.0" + "id": "p.c.6.p.c.2.p.c.0.p.c.p.c.0" }, "type": "Div" } ], - "id": "p.c.5.p.c.2.p.c.0.p.c" + "id": "p.c.6.p.c.2.p.c.0.p.c" }, "type": "Div" }, - "id": "p.c.5.p.c.2.p.c.0" + "id": "p.c.6.p.c.2.p.c.0" }, "type": "Div" } ], - "id": "p.c.5.p.c.2" + "id": "p.c.6.p.c.2" }, "type": "Div" } ], - "id": "p.c.5" + "id": "p.c.6" }, "type": "Div" } @@ -371,60 +371,60 @@ def test_initial_state(self): 'return window.store.getState().paths' ), { - "p.c.3": [ - "props", "children", 4 - ], "p.c.4": [ - "props", "children", 5 + "props", "children", 4 ], "p.c.5": [ "props", "children", 5 ], - "p.c.5.p.c.0": [ - "props", "children", 5, + "p.c.6": [ + "props", "children", 6 + ], + "p.c.6.p.c.0": [ + "props", "children", 6, "props", "children", 0 ], - "p.c.5.p.c.1": [ - "props", "children", 5, + "p.c.6.p.c.1": [ + "props", "children", 6, "props", "children", 1 ], - "p.c.5.p.c.1.p.c.0": [ - "props", "children", 5, + "p.c.6.p.c.1.p.c.0": [ + "props", "children", 6, "props", "children", 1, "props", "children", 0 ], - "p.c.5.p.c.2": [ - "props", "children", 5, + "p.c.6.p.c.2": [ + "props", "children", 6, "props", "children", 2 ], - "p.c.5.p.c.2.p.c.0": [ - "props", "children", 5, + "p.c.6.p.c.2.p.c.0": [ + "props", "children", 6, "props", "children", 2, "props", "children", 0 ], - "p.c.5.p.c.2.p.c.0.p.c": [ - "props", "children", 5, + "p.c.6.p.c.2.p.c.0.p.c": [ + "props", "children", 6, "props", "children", 2, "props", "children", 0, "props", "children" ], - "p.c.5.p.c.2.p.c.0.p.c.p.c.0": [ - "props", "children", 5, + "p.c.6.p.c.2.p.c.0.p.c.p.c.0": [ + "props", "children", 6, "props", "children", 2, "props", "children", 0, "props", "children", "props", "children", 0 ], - "p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.0": [ - "props", "children", 5, + "p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.0": [ + "props", "children", 6, "props", "children", 2, "props", "children", 0, "props", "children", "props", "children", 0, "props", "children", 0 ], - "p.c.5.p.c.2.p.c.0.p.c.p.c.0.p.c.2": [ - "props", "children", 5, + "p.c.6.p.c.2.p.c.0.p.c.p.c.0.p.c.2": [ + "props", "children", 6, "props", "children", 2, "props", "children", 0, "props", "children",