From fc1cf8fe274d27d58661156832f75033747d0087 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Sun, 20 Dec 2020 03:55:06 +0200 Subject: [PATCH] Deep copy `token.attrs` to avoid mutating token stream --- lib/renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/renderer.js b/lib/renderer.js index d19b95449..c58435a96 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -64,7 +64,7 @@ default_rules.fence = function (tokens, idx, options, env, slf) { // now we prefer to keep things local. if (info) { i = token.attrIndex('class'); - tmpAttrs = token.attrs ? token.attrs.slice() : []; + tmpAttrs = token.attrs ? JSON.parse(JSON.stringify(token.attrs)) : []; if (i < 0) { tmpAttrs.push([ 'class', options.langPrefix + langName ]);