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)
This commit is contained in:
@@ -35,10 +35,7 @@ function getCssRulesString(s: CSSStyleSheet): string | null {
|
|||||||
try {
|
try {
|
||||||
const rules = s.rules || s.cssRules;
|
const rules = s.rules || s.cssRules;
|
||||||
return rules
|
return rules
|
||||||
? Array.from(rules).reduce(
|
? Array.from(rules).map(getCssRuleString).join('')
|
||||||
(prev, cur) => prev + getCssRuleString(cur),
|
|
||||||
'',
|
|
||||||
)
|
|
||||||
: null;
|
: null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user