mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Updated request to parse DOM is xml is responseXML is not present
This commit is contained in:
parent
105a3a36d6
commit
239109dadb
4 changed files with 19 additions and 5 deletions
9
dist/epub.js
vendored
9
dist/epub.js
vendored
|
@ -2485,7 +2485,14 @@ EPUBJS.core.request = function(url, type, withCredentials, headers) {
|
||||||
var r;
|
var r;
|
||||||
|
|
||||||
if(type == 'xml'){
|
if(type == 'xml'){
|
||||||
r = this.responseXML;
|
|
||||||
|
// If this.responseXML wasn't set, try to parse using a DOMParser from text
|
||||||
|
if(!this.responseXML){
|
||||||
|
r = new DOMParser().parseFromString(this.response, "text/xml");
|
||||||
|
} else {
|
||||||
|
r = this.responseXML;
|
||||||
|
}
|
||||||
|
|
||||||
}else
|
}else
|
||||||
if(type == 'json'){
|
if(type == 'json'){
|
||||||
r = JSON.parse(this.response);
|
r = JSON.parse(this.response);
|
||||||
|
|
2
dist/epub.min.js
vendored
2
dist/epub.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -52,7 +52,14 @@ EPUBJS.core.request = function(url, type, withCredentials, headers) {
|
||||||
var r;
|
var r;
|
||||||
|
|
||||||
if(type == 'xml'){
|
if(type == 'xml'){
|
||||||
r = this.responseXML;
|
|
||||||
|
// If this.responseXML wasn't set, try to parse using a DOMParser from text
|
||||||
|
if(!this.responseXML){
|
||||||
|
r = new DOMParser().parseFromString(this.response, "text/xml");
|
||||||
|
} else {
|
||||||
|
r = this.responseXML;
|
||||||
|
}
|
||||||
|
|
||||||
}else
|
}else
|
||||||
if(type == 'json'){
|
if(type == 'json'){
|
||||||
r = JSON.parse(this.response);
|
r = JSON.parse(this.response);
|
||||||
|
|
|
@ -286,7 +286,7 @@ asyncTest("Get all TOC", 1, function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("Get TOC time by href", 1, function() {
|
asyncTest("Get TOC item by href", 1, function() {
|
||||||
|
|
||||||
var book = ePub("../books/moby-dick/OPS/package.opf");
|
var book = ePub("../books/moby-dick/OPS/package.opf");
|
||||||
book.loaded.navigation.then(function(){
|
book.loaded.navigation.then(function(){
|
||||||
|
@ -297,7 +297,7 @@ asyncTest("Get TOC time by href", 1, function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("Get TOC time by ID", 1, function() {
|
asyncTest("Get TOC item by ID", 1, function() {
|
||||||
|
|
||||||
var book = ePub("../books/moby-dick/OPS/package.opf");
|
var book = ePub("../books/moby-dick/OPS/package.opf");
|
||||||
book.loaded.navigation.then(function(){
|
book.loaded.navigation.then(function(){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue