Skip to content

Commit

Permalink
Prefer a map and a join as feel it's easier to understand, and I foun…
Browse files Browse the repository at this point in the history
…d a case in the wild where `Array.prototype.reduce` was overwritten (which admittedly is also a danger with `map`) (#52)
  • Loading branch information
eoghanmurray authored Oct 15, 2020
1 parent 1251091 commit b3e7d5a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ function getCssRulesString(s: CSSStyleSheet): string | null {
try {
const rules = s.rules || s.cssRules;
return rules
? Array.from(rules).reduce(
(prev, cur) => prev + getCssRuleString(cur),
'',
)
? Array.from(rules).map(getCssRuleString).join('')
: null;
} catch (error) {
return null;
Expand Down

0 comments on commit b3e7d5a

Please sign in to comment.