1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00

Merge pull request #819 from wiscat/fix_epubcfi_null

fix EpubCFI(null) Uncaught TypeError: Cannot read property 'startCont…
This commit is contained in:
Fred Chasen 2018-09-07 13:37:35 -07:00 committed by GitHub
commit ac6807b26b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,11 +77,11 @@ class EpubCFI {
if (this.isCfiString(cfi)) {
return "string";
// Is a range object
} else if (typeof cfi === "object" && (type(cfi) === "Range" || typeof(cfi.startContainer) != "undefined")){
} else if (cfi && typeof cfi === "object" && (type(cfi) === "Range" || typeof(cfi.startContainer) != "undefined")){
return "range";
} else if (typeof cfi === "object" && typeof(cfi.nodeType) != "undefined" ){ // || typeof cfi === "function"
} else if (cfi && typeof cfi === "object" && typeof(cfi.nodeType) != "undefined" ){ // || typeof cfi === "function"
return "node";
} else if (typeof cfi === "object" && cfi instanceof EpubCFI){
} else if (cfi && typeof cfi === "object" && cfi instanceof EpubCFI){
return "EpubCFI";
} else {
return false;