Skip to content

Commit

Permalink
bugfix in exports.addAttrs -- handle undefined token
Browse files Browse the repository at this point in the history
  • Loading branch information
sajozsattila committed Apr 15, 2021
1 parent e0ff0b1 commit 1e2b836
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions markdown-it-attrs.browser.js
Expand Up @@ -684,15 +684,17 @@ exports.getAttrs = function (str, start, options) {


exports.addAttrs = function (attrs, token) {
for (var j = 0, l = attrs.length; j < l; ++j) {
var key = attrs[j][0];

if (key === 'class') {
token.attrJoin('class', attrs[j][1]);
} else if (key === 'css-module') {
token.attrJoin('css-module', attrs[j][1]);
} else {
token.attrPush(attrs[j]);
if (token) {
for (var j = 0, l = attrs.length; j < l; ++j) {
var key = attrs[j][0];

if (key === 'class') {
token.attrJoin('class', attrs[j][1]);
} else if (key === 'css-module') {
token.attrJoin('css-module', attrs[j][1]);
} else {
token.attrPush(attrs[j]);
}
}
}

Expand Down

0 comments on commit 1e2b836

Please sign in to comment.