avoid error "Cannot read property 'match' of null" #198

Closed
Juliangzr wants to merge 1 commits from patch-1 into master

View File

@@ -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)