From 27e52c8979129869964df95ff41732bd836246e7 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 5 May 2015 15:38:57 -0400 Subject: [PATCH] Only attempt to `scrollTop` if element is available. In later versions of Ember, the views and components can be stable and are not guaranteed to be torn down before a new controller is set on them. In this case, the controller is initially set before the element has been rendered to the DOM causing errors when invoking `closest` on undefined. --- core/client/app/views/content-preview-content-view.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/client/app/views/content-preview-content-view.js b/core/client/app/views/content-preview-content-view.js index a9c5d51f60..b11980d941 100644 --- a/core/client/app/views/content-preview-content-view.js +++ b/core/client/app/views/content-preview-content-view.js @@ -13,7 +13,11 @@ var PostContentView = Ember.View.extend({ }, contentObserver: function () { - this.$().closest('.content-preview').scrollTop(0); + var el = this.$(); + + if (el) { + el.closest('.content-preview').scrollTop(0); + } }.observes('controller.content'), willDestroyElement: function () {