From fde8467c0244a684dd8e38d5050b9144b0ba50cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20K=C3=A1ntor?= Date: Wed, 7 Mar 2018 16:21:12 +0100 Subject: [PATCH] fix(base component): Don't remove non-elements --- src/components/base_component.js | 2 +- src/manual_test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/base_component.js b/src/components/base_component.js index 086724e0..cc2d003b 100644 --- a/src/components/base_component.js +++ b/src/components/base_component.js @@ -110,7 +110,7 @@ const create_bind_function = (args, instance_args) => (selection) => { if (element === null || (element && element.node && !document.contains(element.node()))) return state_handler.subscribe(me) - element.remove() + if (element) element.remove() element = create_element( args.init, format_arguments(instance_args), selection) render_() diff --git a/src/manual_test.js b/src/manual_test.js index 3d89803c..db610468 100644 --- a/src/manual_test.js +++ b/src/manual_test.js @@ -11,6 +11,9 @@ render_dashboard(` dashboard "Cereals": - h1 text: "Cereals" - h2 text: "By calories" + - dropdown my_var=foo: + - {"value": "foo", "text": "Foo"} + - {"value": "bar", "text": "Bar"} - bar chart: - attr:query: '{"columns": [(sort_by(-(.calories | tonumber)) | .[] | [.name, .calories])]}' - data: https://gist.githubusercontent.com/ZeningQu/6184eaf8faa533e320abc938c4738c3e/raw/40f237de825061faa8721c2293b79c46979780b4/cereals.csv @@ -18,7 +21,4 @@ dashboard "Cereals": - 4 columns: - attr:query: '.[] | {"component": "rows", "data": [{"component": "text", "args": {"tagName": "h3"}, "data": .name}, {"component": "chart", "args": {"type": "pie"}, "data": {"columns": [["protein", .protein], ["carbo", .carbo], ["sugars", .sugars], ["fat", .fat]]}}]}' - data: https://gist.githubusercontent.com/ZeningQu/6184eaf8faa533e320abc938c4738c3e/raw/40f237de825061faa8721c2293b79c46979780b4/cereals.csv - - dropdown my_var=foo: - - {"value": "foo", "text": "Foo"} - - {"value": "bar", "text": "Bar"} `)