File tree Expand file tree Collapse file tree 4 files changed +9
-15
lines changed
Expand file tree Collapse file tree 4 files changed +9
-15
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @readium/navigator" ,
3- "version" : " 2.3.0 " ,
3+ "version" : " 2.4.0-alpha.8 " ,
44 "type" : " module" ,
55 "description" : " Next generation SDK for publications in Web Apps" ,
66 "author" : " readium" ,
Original file line number Diff line number Diff line change @@ -76,14 +76,8 @@ export default class FrameBlobBuilder {
7676
7777 // Load the HTML resource
7878 const link = await this . currentResource . link ( ) ;
79- const txt = await this . currentResource . readAsString ( ) ;
80- if ( ! txt ) throw new Error ( `Failed reading item ${ link . href } ` ) ;
81-
82- const doc = new DOMParser ( ) . parseFromString (
83- txt ,
84- link . mediaType . string as DOMParserSupportedType
85- ) ;
86-
79+ const doc = await this . currentResource . readAsXML ( ) as HTMLDocument ;
80+ if ( ! doc ) throw new Error ( `Failed reading item ${ link . href } ` ) ;
8781 const perror = doc . querySelector ( "parsererror" ) ;
8882 if ( perror ) {
8983 const details = perror . querySelector ( "div" ) ;
Original file line number Diff line number Diff line change @@ -108,15 +108,15 @@ export class HttpResource implements Resource {
108108 return await resp . text ( ) ;
109109 }
110110
111- async readAsXML ( ) : Promise < XMLDocument > {
111+ async readAsXML ( ) : Promise < Document > {
112112 const resp = await this . client ( this . url ) ;
113113 if ( ! resp . ok )
114114 throw new Error (
115115 `http GET request for ${ this . url } failed with HTTP status code ${ resp . status } `
116116 ) ; // TODO
117117 return new DOMParser ( ) . parseFromString (
118118 await resp . text ( ) ,
119- 'application/xml'
119+ this . _link . mediaType . isHTML ? ( this . _link . mediaType . string as 'application/xhtml+xml' | 'text/html' ) : 'text /xml'
120120 ) ;
121121 }
122122}
Original file line number Diff line number Diff line change @@ -27,11 +27,11 @@ export abstract class Resource {
2727 return JSON . parse ( str ) ;
2828 } ) ;
2929 }
30- readAsXML ( ) : Promise < XMLDocument | undefined > {
31- return this . readAsString ( ) . then ( str => {
30+ readAsXML ( ) : Promise < Document | undefined > {
31+ return this . link ( ) . then ( l => this . readAsString ( ) . then ( str => {
3232 if ( str === undefined ) return str ;
33- return new DOMParser ( ) . parseFromString ( str , 'text/xml' ) ;
34- } ) ;
33+ return new DOMParser ( ) . parseFromString ( str , l . mediaType . isHTML ? ( l . mediaType . string as 'application/xhtml+xml' | 'text/html' ) : 'text/xml' ) ;
34+ } ) ) ;
3535 }
3636 abstract close ( ) : void ;
3737}
You can’t perform that action at this time.
0 commit comments