From d2d902be4085a517077be3a88f60486327373736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Rivet?= Date: Wed, 10 Apr 2019 22:18:57 -0400 Subject: [PATCH] Issue148 - `0` children regression in dash==0.40.0 (#150) --- CHANGELOG.md | 4 ++++ src/TreeContainer.js | 2 +- tests/test_render.py | 22 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f8b184ef9..c61267b55e 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/). +## [Unreleased] +### Fixed +- Fix regression for `children=0` case [#148](https://github.com/plotly/dash-renderer/issues/148) + ## [0.22.0] - 2019-04-10 ### Added - Added support for clientside callbacks [#143](https://github.com/plotly/dash-renderer/pull/143) diff --git a/src/TreeContainer.js b/src/TreeContainer.js index 6083a30171..e6244ae55c 100644 --- a/src/TreeContainer.js +++ b/src/TreeContainer.js @@ -33,7 +33,7 @@ const createContainer = component => isSimpleComponent(component) ? class TreeContainer extends Component { getChildren(components) { - if (!components) { + if (isNil(components)) { return null; } diff --git a/tests/test_render.py b/tests/test_render.py index 61fb8c8cba..9b2e04abc2 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -104,7 +104,7 @@ def request_queue_assertions( if expected_length is not None: self.assertEqual(len(request_queue), expected_length) - + def test_initial_state(self): app = Dash(__name__) app.layout = html.Div([ @@ -475,6 +475,26 @@ def test_initial_state(self): assert_clean_console(self) + def test_array_of_falsy_child(self): + app = Dash(__name__) + app.layout = html.Div(id='nully-wrapper', children=[0]) + + self.startServer(app) + + self.wait_for_text_to_equal('#nully-wrapper', '0') + + assert_clean_console(self) + + def test_of_falsy_child(self): + app = Dash(__name__) + app.layout = html.Div(id='nully-wrapper', children=0) + + self.startServer(app) + + self.wait_for_text_to_equal('#nully-wrapper', '0') + + assert_clean_console(self) + def test_simple_callback(self): app = Dash(__name__) app.layout = html.Div([