Skip to content

Commit b3e7d5a

Browse files
authored
Prefer a map and a join as feel it's easier to understand, and I found a case in the wild where Array.prototype.reduce was overwritten (which admittedly is also a danger with map) (#52)
1 parent 1251091 commit b3e7d5a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/snapshot.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ function getCssRulesString(s: CSSStyleSheet): string | null {
3535
try {
3636
const rules = s.rules || s.cssRules;
3737
return rules
38-
? Array.from(rules).reduce(
39-
(prev, cur) => prev + getCssRuleString(cur),
40-
'',
41-
)
38+
? Array.from(rules).map(getCssRuleString).join('')
4239
: null;
4340
} catch (error) {
4441
return null;

0 commit comments

Comments
 (0)