diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-11-26 23:44:08 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-11-26 23:44:08 -0400 |
commit | 003f594f6348b55109dd66416e75fcc2a88faade (patch) | |
tree | b4cb05ed4e145e604356786a1d98926040fe5ff0 /src/util/html.js | |
parent | 768927503b5948b846b9a6cddf4b788ca9792e8c (diff) |
finish up cosmetic style changes
Diffstat (limited to 'src/util/html.js')
-rw-r--r-- | src/util/html.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/util/html.js b/src/util/html.js index 752291e9..0a586223 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -1,5 +1,3 @@ -/** @format */ - // Some really simple functions for formatting HTML content. // COMPREHENSIVE! @@ -116,16 +114,18 @@ export function escapeAttributeValue(value) { export function attributes(attribs) { return Object.entries(attribs) .map(([key, val]) => { - if (typeof val === 'undefined' || val === null) return [key, val, false]; - else if (typeof val === 'string') return [key, val, true]; - else if (typeof val === 'boolean') return [key, val, val]; - else if (typeof val === 'number') return [key, val.toString(), true]; + if (typeof val === 'undefined' || val === null) + return [key, val, false]; + else if (typeof val === 'string') + return [key, val, true]; + else if (typeof val === 'boolean') + return [key, val, val]; + else if (typeof val === 'number') + return [key, val.toString(), true]; else if (Array.isArray(val)) return [key, val.filter(Boolean).join(' '), val.length > 0]; else - throw new Error( - `Attribute value for ${key} should be primitive or array, got ${typeof val}` - ); + throw new Error(`Attribute value for ${key} should be primitive or array, got ${typeof val}`); }) .filter(([_key, _val, keep]) => keep) .map(([key, val]) => |