From 6dac1b74e0aed92069319949388de73885ac3b04 Mon Sep 17 00:00:00 2001 From: mishk0 Date: Wed, 19 Aug 2015 12:17:23 +0300 Subject: [PATCH 1/2] fix history replace method --- src/ns.page.history.js | 11 +++++++---- test/spec/ns.page.history.js | 12 ++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ns.page.history.js b/src/ns.page.history.js index e8b37f7e..7b43ac7c 100644 --- a/src/ns.page.history.js +++ b/src/ns.page.history.js @@ -54,10 +54,13 @@ ns.page.history.replace = function(url) { var nsHistory = ns.page.history; - // remove prev - nsHistory._history.pop(); - // insert new - nsHistory._history.push(url); + if (nsHistory._current) { + // remove prev + nsHistory._history.pop(); + // insert new + nsHistory._history.push(url); + } + // save current nsHistory._current = url; }; diff --git a/test/spec/ns.page.history.js b/test/spec/ns.page.history.js index 4055aa6c..b4816c4d 100644 --- a/test/spec/ns.page.history.js +++ b/test/spec/ns.page.history.js @@ -25,4 +25,16 @@ describe('ns.page.history', function() { }); + describe('.replace', function() { + it('не должен записать историю при первом переходе', function() { + ns.page.history.replace('/app'); + expect(ns.page.history.getPrevious()).to.be.equal(undefined); + }); + + it('должен переписать историю', function() { + ns.page.history.push('/app1'); + ns.page.history.replace('/app2'); + expect(ns.page.history.getPrevious()).to.be.equal('/app2'); + }); + }); }); From 492faaadc706c5111f1f10ae59fb328a03b38c6d Mon Sep 17 00:00:00 2001 From: Mikhail Mokrushin Date: Fri, 21 Aug 2015 18:29:01 +0300 Subject: [PATCH 2/2] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7268cf0c..581edb85 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -[![Build Status](https://travis-ci.org/yandex-ui/noscript.png?branch=master)](https://travis-ci.org/yandex-ui/noscript) -[![NPM version](https://badge.fury.io/js/noscript.png)](http://badge.fury.io/js/noscript) -[![Dependency Status](https://david-dm.org/yandex-ui/noscript.png)](https://david-dm.org/yandex-ui/noscript) +[![Build Status](https://travis-ci.org/yandex-ui/noscript.svg?branch=master)](https://travis-ci.org/yandex-ui/noscript) +[![NPM version](https://badge.fury.io/js/noscript.svg)](http://badge.fury.io/js/noscript) +[![Dependency Status](https://david-dm.org/yandex-ui/noscript.svg)](https://david-dm.org/yandex-ui/noscript) # noscript - JS MVC framework ## Документация