From 3de170573b5adc1d5d6677ec1920ded61b70fac7 Mon Sep 17 00:00:00 2001 From: Bujorel Tecu Date: Mon, 12 Sep 2016 10:01:00 -0400 Subject: [PATCH] Guard destroying the component. When running an `ember` application embedded, it might cause the DOM to be cleaned before the `willDestroyElement` hook runs. --- addon/components/bs-datetimepicker.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addon/components/bs-datetimepicker.js b/addon/components/bs-datetimepicker.js index cd6c280..72ed884 100644 --- a/addon/components/bs-datetimepicker.js +++ b/addon/components/bs-datetimepicker.js @@ -90,7 +90,11 @@ export default Component.extend({ this.removeObserver('maxDate'); this.removeObserver('minDate'); - this.$().data('DateTimePicker').destroy(); + // Running the `ember` application embedded might cause the DOM to be cleaned before + let dateTimePicker = this.$().data('DateTimePicker'); + if (dateTimePicker) { + dateTimePicker.destroy(); + } }, actions: {