From b925d7abeb20933bb5e2548e3dfb73ffa6146783 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 30 Sep 2021 16:12:28 +0300 Subject: [PATCH] svgo-worker/index.js: be stricter with the checks SVGO returns `undefined` when an attribute isn't present, not `null`. --- package.json | 8 -------- src/js/svgo-worker/index.js | 7 +++++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index a09fa6ebd..99d7cfbae 100644 --- a/package.json +++ b/package.json @@ -57,14 +57,6 @@ "rules": { "arrow-body-style": "off", "capitalized-comments": "off", - "eqeqeq": [ - "error", - "always", - { - "null": "ignore" - } - ], - "no-eq-null": "off", "no-multi-assign": "off", "no-negated-condition": "off", "no-shadow": "error", diff --git a/src/js/svgo-worker/index.js b/src/js/svgo-worker/index.js index e8f080d37..4a3cf2b14 100644 --- a/src/js/svgo-worker/index.js +++ b/src/js/svgo-worker/index.js @@ -11,10 +11,13 @@ const createDimensionsExtractor = () => { // Node, parentNode enter: ({ name, attributes }, { type }) => { if (name === 'svg' && type === 'root') { - if (attributes.width != null && attributes.height !== null) { + if ( + attributes.width !== undefined && + attributes.height !== undefined + ) { dimensions.width = Number.parseFloat(attributes.width); dimensions.height = Number.parseFloat(attributes.height); - } else if (attributes.viewBox != null) { + } else if (attributes.viewBox !== undefined) { const viewBox = attributes.viewBox.split(/,\s*|\s+/); dimensions.width = Number.parseFloat(viewBox[2]); dimensions.height = Number.parseFloat(viewBox[3]);