mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Tweak filterByPredicate to avoid calling transform when children array is empty.
This commit is contained in:
parent
37154a5dff
commit
4ec9b2049b
2 changed files with 9 additions and 4 deletions
|
|
@ -1571,8 +1571,10 @@ function filterByPredicate(tokens, allowed, transform) {
|
||||||
if (allowed(token)) {
|
if (allowed(token)) {
|
||||||
result.push(token);
|
result.push(token);
|
||||||
}
|
}
|
||||||
var transformed = transform ? transform(token.children) : token.children;
|
if (token.children.length > 0) {
|
||||||
pending.unshift.apply(pending, _toConsumableArray(transformed));
|
var transformed = transform ? transform(token.children) : token.children;
|
||||||
|
pending.unshift.apply(pending, _toConsumableArray(transformed));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,8 +116,11 @@ function filterByPredicate(tokens, allowed, transform) {
|
||||||
if (allowed(token)) {
|
if (allowed(token)) {
|
||||||
result.push(token);
|
result.push(token);
|
||||||
}
|
}
|
||||||
const transformed = transform ? transform(token.children) : token.children;
|
if (token.children.length > 0) {
|
||||||
pending.unshift(...transformed);
|
const transformed =
|
||||||
|
transform ? transform(token.children) : token.children;
|
||||||
|
pending.unshift(...transformed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue