avoid error "Cannot read property 'match' of null" #198
3
index.js
3
index.js
@@ -109,6 +109,8 @@ 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
|
||||||
|
|
||||||
|
if (html != undefined) {
|
||||||
var matches = html.match(htmlRegex)
|
var matches = html.match(htmlRegex)
|
||||||
if (matches && matches.length) {
|
if (matches && matches.length) {
|
||||||
matches = matches[0].match(htmlAttribsRegex)
|
matches = matches[0].match(htmlAttribsRegex)
|
||||||
@@ -125,6 +127,7 @@ Pjax.prototype = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmpEl.documentElement.innerHTML = html
|
tmpEl.documentElement.innerHTML = html
|
||||||
this.log("load content", tmpEl.documentElement.attributes, tmpEl.documentElement.innerHTML.length)
|
this.log("load content", tmpEl.documentElement.attributes, tmpEl.documentElement.innerHTML.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user