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

I had a problem when trying to use the library, issue reported in  Issue ID #187
This commit is contained in:
Juliangzr
2018-11-29 14:12:06 -03:00
committed by GitHub
parent 2c6506af65
commit 5169e34186

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)