bem-history
4.0.0 • Public • Published bem-history
What is this?
BEM wrap for History API:
- supports browsers with a native History API and hashchange event;
- provides manipulations with url, browser location and history in the terms of BEM.
Components
uri__querystring
– module for an url parsing;
history
– module provides work with a browser History with two modificators:
provider_history-api
– supports a native History API;
provider_hashchange
– supports fallback on the hashchange event;
location
– high-level module for a window.location
change.
Scheme of library work
Usage
uri__querystring
modules.require(['uri__querystring'], function(Querystring) {
var u = Querystring.Uri.parse('http://example.org:8080/path?test=1&test=2¶m2=22');
u.setPort(80);
u.deleteParam('test', '2');
u.replaceParam('param2', 2);
u.toString();
});
history
modules.require(['history'], function(History) {
var history = new History();
history.changeState('push', { title: 'Title', url: 'http://example.org:8080/path' });
history.changeState('replace', { title: 'Title', url: 'http://example.org:8080/path?test=1' });
});
location
modules.require(['location'], function(location) {
location.change({ url: 'http://example.org:8080/path' });
location.change({ params: { param1: [11,12], param2: 'ololo' } });
window.location.href;
});
Package Sidebar
Install
Weekly Downloads