30 lines
616 B
JavaScript
Raw Normal View History

2015-04-29 11:02:32 +02:00
'use strict';
2015-04-21 19:38:17 +02:00
2015-04-29 11:02:32 +02:00
var invariant = require('react/lib/invariant');
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
2015-04-21 19:38:17 +02:00
var History = {
/**
* The current number of entries in the history.
*
* Note: This property is read-only.
*/
length: 1,
/**
* Sends the browser back one entry in the history.
*/
back: function back() {
2015-04-29 11:02:32 +02:00
invariant(canUseDOM, 'Cannot use History.back without a DOM');
2015-04-21 19:38:17 +02:00
// Do this first so that History.length will
// be accurate in location change listeners.
History.length -= 1;
window.history.back();
}
};
module.exports = History;