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"} `)