ecmarkup
Version:
Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.
28 lines (27 loc) • 1.04 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const Builder_1 = require("./Builder");
class H1 extends Builder_1.default {
static async enter() {
// do nothing
}
static async exit({ node, clauseStack }) {
const parent = clauseStack[clauseStack.length - 1] || null;
if (parent === null || parent.header !== node) {
return;
}
const headerClone = node.cloneNode(true);
for (const a of headerClone.querySelectorAll('a')) {
a.replaceWith(...a.childNodes);
}
parent.titleHTML = headerClone.innerHTML;
parent.title = headerClone.textContent;
if (parent.number) {
// we want to prepend some HTML but setting `innerHTML` on the node will blow away the existing children,
// which messes up other stuff which expects those to keep their identity
node.insertAdjacentHTML('afterbegin', parent.getSecnumHTML());
}
}
}
H1.elements = ['H1'];
exports.default = H1;
;