diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index 85ee35700..426835915 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -488,9 +488,11 @@ exports.opAssembler = () => { * @param {Op} op - Operation to add. Ownership remains with the caller. */ const append = (op) => { - if (op.attribs != null) serialized += op.attribs; + if (!op.opcode) throw new TypeError('null op'); + if (typeof op.attribs !== 'string') throw new TypeError('attribs must be a string'); + serialized += op.attribs; if (op.lines) serialized += `|${exports.numToString(op.lines)}`; - if (op.opcode != null) serialized += op.opcode; + serialized += op.opcode; serialized += exports.numToString(op.chars); }; diff --git a/src/static/js/contentcollector.js b/src/static/js/contentcollector.js index 3d2bd9aa8..54c628804 100644 --- a/src/static/js/contentcollector.js +++ b/src/static/js/contentcollector.js @@ -92,7 +92,7 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author) attribsBuilder = Changeset.smartOpAssembler(); }, textOfLine: (i) => textArray[i], - appendText: (txt, attrString) => { + appendText: (txt, attrString = '') => { textArray[textArray.length - 1] += txt; op.attribs = attrString; op.chars = txt.length;