From caf3a2b5c8a08518f26a492fdf81a15890f393ff Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Wed, 8 Oct 2014 01:05:37 -0700 Subject: [PATCH] Fix scrollBehavior='none' on path update Fixes #369. Test Plan: npm test --- modules/mixins/ScrollContext.js | 6 +++--- modules/mixins/__tests__/ScrollContext-test.js | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/mixins/ScrollContext.js b/modules/mixins/ScrollContext.js index e4c714ee13..13a91e5e1d 100644 --- a/modules/mixins/ScrollContext.js +++ b/modules/mixins/ScrollContext.js @@ -76,10 +76,10 @@ var ScrollContext = { updateScroll: function (path, actionType) { var behavior = this.getScrollBehavior(); - var position = this._scrollPositions[path]; - if (behavior && position) - behavior.updateScrollPosition(position, actionType); + if (behavior != null && this._scrollPositions.hasOwnProperty(path)) { + behavior.updateScrollPosition(this._scrollPositions[path], actionType); + } }, /** diff --git a/modules/mixins/__tests__/ScrollContext-test.js b/modules/mixins/__tests__/ScrollContext-test.js index 84d8461f18..bfdb499705 100644 --- a/modules/mixins/__tests__/ScrollContext-test.js +++ b/modules/mixins/__tests__/ScrollContext-test.js @@ -29,6 +29,12 @@ describe('ScrollContext', function () { it('has a null scroll behavior', function () { expect(component.getScrollBehavior()).toBe(null); }); + + it('does not throw when updating scroll position', function () { + expect(function() { + component.updateScroll('/'); + }).toNotThrow(); + }); }); describe('when using scrollBehavior="browser"', function () {