From d1717cdb12dc58fd06959c72ffb5a82b7f666801 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 2 Sep 2015 15:33:44 -0400 Subject: [PATCH] FIX: Safer JS code --- .../javascripts/discourse/components/menu-panel.js.es6 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/components/menu-panel.js.es6 b/app/assets/javascripts/discourse/components/menu-panel.js.es6 index 18a36917c..e92e85579 100644 --- a/app/assets/javascripts/discourse/components/menu-panel.js.es6 +++ b/app/assets/javascripts/discourse/components/menu-panel.js.es6 @@ -125,9 +125,13 @@ export default Ember.Component.extend({ clearInterval(this._resizeInterval); this._resizeInterval = setInterval(() => { Ember.run(() => { - const contentHeight = parseInt(this.$('.panel-body-contents').height()); - if (contentHeight !== this._lastHeight) { this.performLayout(); } - this._lastHeight = contentHeight; + const $panelBodyContents = this.$('.panel-body-contents'); + + if ($panelBodyContents.length) { + const contentHeight = parseInt($panelBodyContents.height()); + if (contentHeight !== this._lastHeight) { this.performLayout(); } + this._lastHeight = contentHeight; + } }); }, 500); }