semi-working bundle

This commit is contained in:
Leo Horie 2016-05-14 01:01:35 -04:00
parent 41cfda2719
commit 5265697cb2
20 changed files with 1391 additions and 123 deletions

View file

@ -3,9 +3,12 @@
var buildQueryString = require("../querystring/build")
var parseQueryString = require("../querystring/parse")
module.exports = function($window, prefix) {
module.exports = function($window) {
var supportsPushState = typeof $window.history.pushState === "function" && $window.location.protocol !== "file:"
var prefix = "#!"
function setPrefix(value) {prefix = value}
function normalize(fragment) {
var data = $window.location[fragment].replace(/(?:%[a-f89][a-f0-9])+/gim, decodeURIComponent)
if (fragment === "pathname" && data[0] !== "/") data = "/" + data
@ -93,5 +96,13 @@ module.exports = function($window, prefix) {
return resolveRoute
}
return {getPath: getPath, setPath: setPath, defineRoutes: defineRoutes}
function link(vnode) {
vnode.dom.setAttribute("href", prefix + vnode.attrs.href)
vnode.dom.onclick = function(e) {
e.preventDefault()
setPath(vnode.attrs.href)
}
}
return {setPrefix: setPrefix, getPath: getPath, setPath: setPath, defineRoutes: defineRoutes, link: link}
}