ecmarkup
Version:
Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.
37 lines (31 loc) • 906 B
JavaScript
;
const Builder = require('./Builder');
module.exports = class Note extends Builder {
constructor(spec, node, clause) {
super(spec, node);
this.clause = clause;
if (this.node.hasAttribute('id')) {
this.id = node.getAttribute('id');
}
}
build(number) {
if (this.id) {
// biblio is added during the build step as we don't know
// the number at build time. Could probably be fixed.
this.spec.biblio.notes[this.id] = {
location: '',
id: this.id,
number: number || 1,
clauseId: this.clause.id
};
}
const noteSpan = this.spec.doc.createElement('span');
noteSpan.setAttribute('class', 'note');
if (number !== undefined) {
noteSpan.textContent = 'Note ' + number;
} else {
noteSpan.textContent = 'Note';
}
this.node.insertBefore(noteSpan, this.node.firstChild);
}
};