johnfactotum / foliate-js

Render e-books in the browser
https://johnfactotum.github.io/foliate-js/reader.html
MIT License
420 stars 60 forks source link

cannot open epub #39

Closed routeone34 closed 3 weeks ago

routeone34 commented 3 weeks ago

Just information.

epub.js: line218 //const altRep = x.attrs['alt-rep'] const altRep = x.attrs?.['alt-rep']

johnfactotum commented 3 weeks ago

I'm probably missing something because if I'm reading it correctly, it looks like x.attrs is Object.fromEntries(Array.from(el.attributes)), which should never be null or undefined.

Can you provide more information? Like a minimal reproducible example, or at least what sort of error you're seeing.

routeone34 commented 3 weeks ago

I don't know the specification of epub exactly. A book with the attached opf cannot be opened with the original code.

content.opf.txt

routeone34 commented 3 weeks ago

console.log of the case is below.


reader.js:219 TypeError: Cannot read properties of undefined (reading 'alt-rep') at makeLanguageMap (epub.js:218:31) at getMetadata (epub.js:265:16) at EPUB.init (epub.js:1010:48) at async makeBook (view.js:103:20) at async View.open (view.js:234:37) at async Reader.open (reader.js:109:9) at async open (reader.js:209:5)