Bug fixes
This commit is contained in:
@@ -31,7 +31,7 @@ module.exports = function(el) {
|
|||||||
// execute
|
// execute
|
||||||
parent.appendChild(script)
|
parent.appendChild(script)
|
||||||
// avoid pollution only in head or body tags
|
// avoid pollution only in head or body tags
|
||||||
if (["head", "body"].indexOf(parent.tagName.toLowerCase()) > 0) {
|
if (parent instanceof HTMLHeadElement || parent instanceof HTMLBodyElement) {
|
||||||
parent.removeChild(script)
|
parent.removeChild(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,7 @@ module.exports = function(options) {
|
|||||||
options.switches = options.switches || {}
|
options.switches = options.switches || {}
|
||||||
options.switchesOptions = options.switchesOptions || {}
|
options.switchesOptions = options.switchesOptions || {}
|
||||||
options.history = options.history || true
|
options.history = options.history || true
|
||||||
options.analytics = (typeof options.analytics === "function" || options.analytics === false) ?
|
options.analytics = (typeof options.analytics === "function" || options.analytics === false) ? options.analytics : defaultAnalytics
|
||||||
options.analytics :
|
|
||||||
function() {
|
|
||||||
if (window._gaq) {
|
|
||||||
_gaq.push(["_trackPageview"])
|
|
||||||
}
|
|
||||||
if (window.ga) {
|
|
||||||
ga("send", "pageview", {page: location.pathname, title: document.title})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options.scrollTo = (typeof options.scrollTo === "undefined") ? 0 : options.scrollTo
|
options.scrollTo = (typeof options.scrollTo === "undefined") ? 0 : options.scrollTo
|
||||||
options.scrollRestoration = (typeof options.scrollRestoration !== "undefined") ? options.scrollRestoration : true
|
options.scrollRestoration = (typeof options.scrollRestoration !== "undefined") ? options.scrollRestoration : true
|
||||||
options.cacheBust = (typeof options.cacheBust === "undefined") ? true : options.cacheBust
|
options.cacheBust = (typeof options.cacheBust === "undefined") ? true : options.cacheBust
|
||||||
@@ -38,3 +29,12 @@ module.exports = function(options) {
|
|||||||
|
|
||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defaultAnalytics() {
|
||||||
|
if (window._gaq) {
|
||||||
|
_gaq.push(["_trackPageview"])
|
||||||
|
}
|
||||||
|
if (window.ga) {
|
||||||
|
ga("send", "pageview", {page: location.pathname, title: document.title})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports = function(location, options, callback) {
|
|||||||
if (request.status === 200) {
|
if (request.status === 200) {
|
||||||
callback(request.responseText, request, location)
|
callback(request.responseText, request, location)
|
||||||
}
|
}
|
||||||
else {
|
else if (request.status !== 0) {
|
||||||
callback(null, request, location)
|
callback(null, request, location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ module.exports = function(location, options, callback) {
|
|||||||
|
|
||||||
// Send the proper header information for POST forms
|
// Send the proper header information for POST forms
|
||||||
if (requestPayload && requestMethod === "POST") {
|
if (requestPayload && requestMethod === "POST") {
|
||||||
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
|
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||||
}
|
}
|
||||||
|
|
||||||
request.send(requestPayload)
|
request.send(requestPayload)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module.exports = function(target) {
|
module.exports = function(target) {
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
return target
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
var to = Object(target)
|
var to = Object(target)
|
||||||
|
|||||||
Reference in New Issue
Block a user