Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
917c6f6bcb | ||
|
|
b201b96a37 | ||
|
|
eff7cfd452 | ||
|
|
7976f06043 | ||
|
|
ee530f4c0a | ||
|
|
bf71894395 | ||
|
|
beaa21fb3a | ||
|
|
b96b0f41a7 | ||
|
|
6e113b2d06 | ||
|
|
46912e6797 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,3 +1,13 @@
|
|||||||
|
# 0.2.4 - 2016-06-28
|
||||||
|
|
||||||
|
- Fixed: ``refresh`` should now work (use `this.parseDOM` for refresh)
|
||||||
|
([#67](https://github.com/MoOx/pjax/pull/67) - @compressed)
|
||||||
|
- Fixed: Some attributes, such as `itemscope` have no corresponding value.
|
||||||
|
This change allows them to still be set.
|
||||||
|
([#67](https://github.com/MoOx/pjax/pull/67) - @compressed)
|
||||||
|
- Added: ``cacheBust`` option
|
||||||
|
([#71](https://github.com/MoOx/pjax/pull/71) - @tremby)
|
||||||
|
|
||||||
# 0.2.3 - 2016-03-24
|
# 0.2.3 - 2016-03-24
|
||||||
|
|
||||||
- Fixed: ``currentUrlFullReload`` option now works
|
- Fixed: ``currentUrlFullReload`` option now works
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ new Pjax({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
_Note that remove class include `Animated--reverse` which is a simple way to not have
|
_Note that remove class include `Animated--reverse` which is a simple way to not have
|
||||||
@@ -381,6 +382,12 @@ It's called every time a page is switched, even for history buttons.
|
|||||||
|
|
||||||
Value (in px) to scrollTo when a page is switched.
|
Value (in px) to scrollTo when a page is switched.
|
||||||
|
|
||||||
|
##### `cacheBust` (Boolean, default true)
|
||||||
|
|
||||||
|
When set to true,
|
||||||
|
append a timestamp query string segment to the requested URLs
|
||||||
|
in order to skip browser cache.
|
||||||
|
|
||||||
##### `debug` (Boolean, default to false)
|
##### `debug` (Boolean, default to false)
|
||||||
|
|
||||||
Enable verbose mode & doesn't use fallback when there is an error.
|
Enable verbose mode & doesn't use fallback when there is an error.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pjax",
|
"name": "pjax",
|
||||||
"version": "0.2.2",
|
"version": "0.2.4",
|
||||||
"description": "Easily enable fast Ajax navigation on any website (using pushState + xhr)",
|
"description": "Easily enable fast Ajax navigation on any website (using pushState + xhr)",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"pjax",
|
"pjax",
|
||||||
|
|||||||
5
index.js
5
index.js
@@ -94,7 +94,12 @@ Pjax.prototype = {
|
|||||||
matches.shift()
|
matches.shift()
|
||||||
matches.forEach(function(htmlAttrib) {
|
matches.forEach(function(htmlAttrib) {
|
||||||
var attr = htmlAttrib.trim().split("=")
|
var attr = htmlAttrib.trim().split("=")
|
||||||
|
if (attr.length === 1) {
|
||||||
|
tmpEl.documentElement.setAttribute(attr[0], true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1))
|
tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ module.exports = function(options){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.options.scrollTo = (typeof this.options.scrollTo === 'undefined') ? 0 : this.options.scrollTo;
|
this.options.scrollTo = (typeof this.options.scrollTo === 'undefined') ? 0 : this.options.scrollTo;
|
||||||
|
this.options.cacheBust = (typeof this.options.cacheBust === 'undefined') ? true : this.options.cacheBust
|
||||||
this.options.debug = this.options.debug || false
|
this.options.debug = this.options.debug || false
|
||||||
|
|
||||||
// we can’t replace body.outerHTML or head.outerHTML
|
// we can’t replace body.outerHTML or head.outerHTML
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
|
|
||||||
var parseDom = require("./parse-dom")
|
|
||||||
|
|
||||||
module.exports = function(el) {
|
module.exports = function(el) {
|
||||||
parseDom(el || document)
|
this.parseDOM(el || document)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,12 @@ module.exports = function(location, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
request.open("GET", location + (!/[?&]/.test(location) ? "?" : "&") + (new Date().getTime()), true)
|
// Add a timestamp as part of the query string if cache busting is enabled
|
||||||
|
if (this.options.cacheBust) {
|
||||||
|
location += (!/[?&]/.test(location) ? "?" : "&") + new Date().getTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
request.open("GET", location, true)
|
||||||
request.setRequestHeader("X-Requested-With", "XMLHttpRequest")
|
request.setRequestHeader("X-Requested-With", "XMLHttpRequest")
|
||||||
request.send(null)
|
request.send(null)
|
||||||
return request
|
return request
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pjax",
|
"name": "pjax",
|
||||||
"version": "0.2.3",
|
"version": "0.2.4",
|
||||||
"description": "Easily enable fast Ajax navigation on any website (using pushState + xhr)",
|
"description": "Easily enable fast Ajax navigation on any website (using pushState + xhr)",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"pjax",
|
"pjax",
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
"jscs": "^1.6.2",
|
"jscs": "^1.6.2",
|
||||||
"jshint": "^2.5.6",
|
"jshint": "^2.5.6",
|
||||||
"npmpub": "^3.1.0",
|
"npmpub": "^3.1.0",
|
||||||
|
"opn-cli": "^3.1.0",
|
||||||
"serve": "1.4.0",
|
"serve": "1.4.0",
|
||||||
"tape": "^3.0.0",
|
"tape": "^3.0.0",
|
||||||
"testling": "^1.6.1"
|
"testling": "^1.6.1"
|
||||||
@@ -37,9 +38,10 @@
|
|||||||
"test": "npm run lint && npm run standalone && npm run tests",
|
"test": "npm run lint && npm run standalone && npm run tests",
|
||||||
"test--html": "testling --html > tests/scripts/index.html",
|
"test--html": "testling --html > tests/scripts/index.html",
|
||||||
"coverage": "browserify -t coverify tests/**/*.js | testling | coverify",
|
"coverage": "browserify -t coverify tests/**/*.js | testling | coverify",
|
||||||
"example": "echo '\n==> Open http://localhost:3000/example in your browser.'; serve .",
|
"example": "opn http://localhost:3000/example/; serve .",
|
||||||
"prepublish": "npm run standalone",
|
"prepublish": "npm run standalone",
|
||||||
"release": "npm test && npmpub --skip-test"
|
"#release": "testling does not work in a process launch by npm... :facepalm:",
|
||||||
|
"release": "echo \"npmpub --skip-test --dry && npm test && npmpub --skip-test --skip-cleanup\""
|
||||||
},
|
},
|
||||||
"testling": {
|
"testling": {
|
||||||
"files": "tests/**/*.js",
|
"files": "tests/**/*.js",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ tape("test parse initalization options function", function(t) {
|
|||||||
t.deepEqual(typeof body_1.options.analytics,"function");
|
t.deepEqual(typeof body_1.options.analytics,"function");
|
||||||
|
|
||||||
t.deepEqual(body_1.options.scrollTo,0);
|
t.deepEqual(body_1.options.scrollTo,0);
|
||||||
|
t.deepEqual(body_1.options.cacheBust,true);
|
||||||
t.deepEqual(body_1.options.debug,false);
|
t.deepEqual(body_1.options.debug,false);
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,27 @@ var tape = require("tape")
|
|||||||
|
|
||||||
var request = require("../../lib/request.js")
|
var request = require("../../lib/request.js")
|
||||||
|
|
||||||
|
// Polyfill responseURL property into XMLHttpRequest if it doesn't exist,
|
||||||
|
// just for the purposes of this test
|
||||||
|
// This polyfill is not complete; it won't show the updated location if a
|
||||||
|
// redirection occurred, but it's fine for our purposes.
|
||||||
|
if (!('responseURL' in XMLHttpRequest.prototype)) {
|
||||||
|
var nativeOpen = XMLHttpRequest.prototype.open
|
||||||
|
XMLHttpRequest.prototype.open = function (method, url) {
|
||||||
|
this.responseURL = url
|
||||||
|
return nativeOpen.apply(this, arguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tape("test xhr request", function(t) {
|
tape("test xhr request", function(t) {
|
||||||
request("https://api.github.com/", function(result) {
|
t.test("- request is made, gets a result, and is cache-busted", function(t) {
|
||||||
|
var requestCacheBust = request.bind({
|
||||||
|
options: {
|
||||||
|
cacheBust: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
var r = requestCacheBust("https://api.github.com/", function(result) {
|
||||||
|
t.equal(r.responseURL.indexOf("?"), 23, "XHR URL is cache-busted when configured to be")
|
||||||
try {
|
try {
|
||||||
result = JSON.parse(result)
|
result = JSON.parse(result)
|
||||||
}
|
}
|
||||||
@@ -14,3 +33,16 @@ tape("test xhr request", function(t) {
|
|||||||
t.end()
|
t.end()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
t.test("- request is not cache-busted when configured not to be", function(t) {
|
||||||
|
var requestNoCacheBust = request.bind({
|
||||||
|
options: {
|
||||||
|
cacheBust: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
var r = requestNoCacheBust("https://api.github.com/", function() {
|
||||||
|
t.equal(r.responseURL, "https://api.github.com/", "XHR URL is left untouched")
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user