avoid error "Cannot read property 'match' of null" #198
31
index.js
31
index.js
@@ -109,20 +109,23 @@ Pjax.prototype = {
|
|||||||
// since we are forced to use documentElement.innerHTML (outerHTML can't be used for <html>)
|
// since we are forced to use documentElement.innerHTML (outerHTML can't be used for <html>)
|
||||||
var htmlRegex = /<html[^>]+>/gi
|
var htmlRegex = /<html[^>]+>/gi
|
||||||
var htmlAttribsRegex = /\s?[a-z:]+(?:\=(?:\'|\")[^\'\">]+(?:\'|\"))*/gi
|
var htmlAttribsRegex = /\s?[a-z:]+(?:\=(?:\'|\")[^\'\">]+(?:\'|\"))*/gi
|
||||||
var matches = html.match(htmlRegex)
|
|
||||||
if (matches && matches.length) {
|
if (html != undefined) {
|
||||||
matches = matches[0].match(htmlAttribsRegex)
|
var matches = html.match(htmlRegex)
|
||||||
if (matches.length) {
|
if (matches && matches.length) {
|
||||||
matches.shift()
|
matches = matches[0].match(htmlAttribsRegex)
|
||||||
matches.forEach(function(htmlAttrib) {
|
if (matches.length) {
|
||||||
var attr = htmlAttrib.trim().split("=")
|
matches.shift()
|
||||||
if (attr.length === 1) {
|
matches.forEach(function(htmlAttrib) {
|
||||||
tmpEl.documentElement.setAttribute(attr[0], true)
|
var attr = htmlAttrib.trim().split("=")
|
||||||
}
|
if (attr.length === 1) {
|
||||||
else {
|
tmpEl.documentElement.setAttribute(attr[0], true)
|
||||||
tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1))
|
}
|
||||||
}
|
else {
|
||||||
})
|
tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user