* use nanohref

* use nanohistory
This commit is contained in:
Yoshua Wuyts
2017-04-14 17:10:21 +02:00
committed by GitHub
parent 2faba85b84
commit 30429d5970
4 changed files with 7 additions and 58 deletions
+5 -6
View File
@@ -1,14 +1,13 @@
var documentReady = require('document-ready')
var nanohistory = require('nanohistory')
var nanorouter = require('nanorouter')
var nanomount = require('nanomount')
var nanomorph = require('nanomorph')
var nanohref = require('nanohref')
var nanoraf = require('nanoraf')
var nanobus = require('nanobus')
var assert = require('assert')
var onHistoryChange = require('./lib/history')
var onHref = require('./lib/href')
module.exports = Choo
function Choo (opts) {
@@ -66,7 +65,7 @@ function Choo (opts) {
bus.on('render', rerender)
if (opts.history !== false) {
onHistoryChange(function (href) {
nanohistory(function (href) {
bus.emit('pushState')
})
@@ -79,7 +78,7 @@ function Choo (opts) {
})
if (opts.href !== false) {
onHref(function (location) {
nanohref(function (location) {
var href = location.href
var currHref = window.location.href
if (href === currHref) return
@@ -103,7 +102,7 @@ function Choo (opts) {
var newTree = start()
documentReady(function () {
var root = document.querySelector(selector)
assert.ok(root, 'could not query selector: ' + selector)
assert.ok(root, 'choo.mount: could not query selector: ' + selector)
nanomount(root, newTree)
tree = root
})