UNPKG

ecmarkup

Version:

Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.

24 lines (23 loc) 773 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Builder_1 = require("./Builder"); class GrammarAnnotation extends Builder_1.default { constructor(spec, prod, node) { super(spec, node); this.production = prod; } build() { if (!this.node.firstChild) return; if (this.node.firstChild.nodeType === 3) { this.node.firstChild.textContent = '[' + this.node.firstChild.textContent; } else { const pre = this.spec.doc.createTextNode('['); this.node.insertBefore(pre, this.node.children[0]); } const post = this.spec.doc.createTextNode(']'); this.node.appendChild(post); } } exports.default = GrammarAnnotation;