Skip to content

Commit

Permalink
1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Jan 22, 2018
1 parent 923f489 commit 0b4031c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 99 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "page",
"description": "Tiny client-side router",
"version": "1.8.0",
"version": "1.8.1",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
119 changes: 21 additions & 98 deletions page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.page=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (process){
/* globals require, module */

'use strict';
Expand Down Expand Up @@ -201,8 +200,11 @@
pageWindow.document.addEventListener(clickEvent, onclick, false);
}
hashbang = !!options.hashbang;
if(hashbang && hasWindow && !hasHistory) {
pageWindow.addEventListener('hashchange', onpopstate, false);
}
if (!dispatch) return;

var url;
if(isLocation) {
var loc = pageWindow.location;
Expand Down Expand Up @@ -232,6 +234,7 @@
running = false;
hasDocument && pageWindow.document.removeEventListener(clickEvent, onclick, false);
hasWindow && pageWindow.removeEventListener('popstate', onpopstate, false);
hasWindow && pageWindow.removeEventListener('hashchange', onpopstate, false);
};

/**
Expand Down Expand Up @@ -599,7 +602,9 @@
/**
* Handle "click" events.
*/

/* jshint -W054 */
var hasProcess = new Function('return typeof process')() !== 'undefined';
/* jshint +W054 */
function onclick(e) {
if (1 !== which(e)) return;

Expand All @@ -626,7 +631,7 @@

// ensure non-hash for the same path
var link = el.getAttribute('href');
if (!hashbang && isLocation && el.pathname === location.pathname && (el.hash || '#' === link)) return;
if(!hashbang && samePath(el) && (el.hash || '#' === link)) return;

// Check for mailto: in the href
if (link && link.indexOf('mailto:') > -1) return;
Expand All @@ -648,7 +653,7 @@
path = path[0] !== '/' ? '/' + path : path;

// strip leading "/[drive letter]:" on NW.js on Windows
if (typeof process !== 'undefined' && path.match(/^\/[a-zA-Z]:\//)) {
if (hasProcess && path.match(/^\/[a-zA-Z]:\//)) {
path = path.replace(/^\/[a-zA-Z]:\//, '/');
}

Expand Down Expand Up @@ -704,20 +709,26 @@
loc.port === url.port;
}

function samePath(url) {
if(!isLocation) return false;
var loc = pageWindow.location;
return url.pathname === loc.pathname &&
url.search === loc.search;
}

/**
* Gets the `base`, which depends on whether we are using History or
* hashbang routing.
*/
function getBase() {
if(!!base) return base;
var loc = hasWindow && pageWindow.location;
return (hasWindow && hashbang && loc.protocol === 'file:') ? loc.pathname : base;
var loc = pageWindow.location;

This comment has been minimized.

Copy link
@zinigor

zinigor Jan 22, 2018

Contributor

It looks like the change from #455 got somehow overwritten by older code, this change has to be the other way around.

This comment has been minimized.

Copy link
@matthewp

matthewp Jan 22, 2018

Author Collaborator

Oh, I think the problem is you made your change in page.js and not in index.js. index.js does override page.js when built.

This comment has been minimized.

Copy link
@zinigor

zinigor Jan 22, 2018

Contributor

Ah, I got it, sorry about that. Do you want me to create another PR?

This comment has been minimized.

Copy link
@matthewp

matthewp Jan 22, 2018

Author Collaborator

Yes please.

This comment has been minimized.

Copy link
@zinigor

zinigor Jan 22, 2018

Contributor

Done, #457.

return (hashbang && loc.protocol === 'file:') ? loc.pathname : base;
}

page.sameOrigin = sameOrigin;

}).call(this,require('_process'))
},{"_process":4,"path-to-regexp":3}],2:[function(require,module,exports){
},{"path-to-regexp":3}],2:[function(require,module,exports){
module.exports = Array.isArray || function (arr) {
return Object.prototype.toString.call(arr) == '[object Array]';
};
Expand Down Expand Up @@ -1114,93 +1125,5 @@ function pathToRegexp (path, keys, options) {
return stringToRegexp(path, keys, options)
}

},{"isarray":2}],4:[function(require,module,exports){
// shim for using process in browser

var process = module.exports = {};

process.nextTick = (function () {
var canSetImmediate = typeof window !== 'undefined'
&& window.setImmediate;
var canMutationObserver = typeof window !== 'undefined'
&& window.MutationObserver;
var canPost = typeof window !== 'undefined'
&& window.postMessage && window.addEventListener
;

if (canSetImmediate) {
return function (f) { return window.setImmediate(f) };
}

var queue = [];

if (canMutationObserver) {
var hiddenDiv = document.createElement("div");
var observer = new MutationObserver(function () {
var queueList = queue.slice();
queue.length = 0;
queueList.forEach(function (fn) {
fn();
});
});

observer.observe(hiddenDiv, { attributes: true });

return function nextTick(fn) {
if (!queue.length) {
hiddenDiv.setAttribute('yes', 'no');
}
queue.push(fn);
};
}

if (canPost) {
window.addEventListener('message', function (ev) {
var source = ev.source;
if ((source === window || source === null) && ev.data === 'process-tick') {
ev.stopPropagation();
if (queue.length > 0) {
var fn = queue.shift();
fn();
}
}
}, true);

return function nextTick(fn) {
queue.push(fn);
window.postMessage('process-tick', '*');
};
}

return function nextTick(fn) {
setTimeout(fn, 0);
};
})();

process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];

function noop() {}

process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;

process.binding = function (name) {
throw new Error('process.binding is not supported');
};

// TODO(shtylman)
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};

},{}]},{},[1])(1)
},{"isarray":2}]},{},[1])(1)
});

0 comments on commit 0b4031c

Please sign in to comment.