Skip to content

Commit 9c17b03

Browse files
committed
Changeset: Require Op opcode and attribs to be strings
1 parent 0ae8fb1 commit 9c17b03

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/static/js/Changeset.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,11 @@ exports.opAssembler = () => {
488488
* @param {Op} op - Operation to add. Ownership remains with the caller.
489489
*/
490490
const append = (op) => {
491-
if (op.attribs != null) serialized += op.attribs;
491+
if (!op.opcode) throw new TypeError('null op');
492+
if (typeof op.attribs !== 'string') throw new TypeError('attribs must be a string');
493+
serialized += op.attribs;
492494
if (op.lines) serialized += `|${exports.numToString(op.lines)}`;
493-
if (op.opcode != null) serialized += op.opcode;
495+
serialized += op.opcode;
494496
serialized += exports.numToString(op.chars);
495497
};
496498

src/static/js/contentcollector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
9292
attribsBuilder = Changeset.smartOpAssembler();
9393
},
9494
textOfLine: (i) => textArray[i],
95-
appendText: (txt, attrString) => {
95+
appendText: (txt, attrString = '') => {
9696
textArray[textArray.length - 1] += txt;
9797
op.attribs = attrString;
9898
op.chars = txt.length;

0 commit comments

Comments
 (0)