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:
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>)
|
||||
var htmlRegex = /<html[^>]+>/gi
|
||||
var htmlAttribsRegex = /\s?[a-z:]+(?:\=(?:\'|\")[^\'\">]+(?:\'|\"))*/gi
|
||||
|
||||
if (html != undefined) {
|
||||
var matches = html.match(htmlRegex)
|
||||
if (matches && matches.length) {
|
||||
matches = matches[0].match(htmlAttribsRegex)
|
||||
@@ -125,6 +127,7 @@ Pjax.prototype = {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tmpEl.documentElement.innerHTML = html
|
||||
this.log("load content", tmpEl.documentElement.attributes, tmpEl.documentElement.innerHTML.length)
|
||||
|
||||
Reference in New Issue
Block a user