epubavocado
Version:
I am an EPUB object model aspiring to be standards compliant.
39 lines (38 loc) • 1.01 kB
JavaScript
import { Entity } from './mixins/entity.js';
import { Resource } from './mixins/resource.js';
import { splitRelAttribute } from '../util.js';
import { select } from '../xpath.js';
export class ContainerLink extends Resource(Entity) {
rel() {
const rel = this._resolve('./@rel');
if (rel) {
return splitRelAttribute(rel);
}
return [];
}
}
export class Rootfile extends Entity {
fullPath() {
return this._resolve('./@full-path');
}
mediaType() {
return this._resolve('./@media-type');
}
}
export class Container extends Entity {
constructor(doc) {
super(select('/ocf:container', doc));
}
version() {
return this._resolve('./@version');
}
rootfiles() {
return this._resolveAll('./ocf:rootfiles/ocf:rootfile', Rootfile);
}
links() {
return this._resolveAll('./ocf:links/ocf:link', ContainerLink);
}
defaultRendition() {
return this.rootfiles()[0];
}
}