From 710954ee96389e4f81627e3eeaf28abfec1eed64 Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Wed, 29 May 2019 17:37:10 +0300 Subject: [PATCH] fix: handle cases when properties `undefined` in `replaceSymbols` (#62) --- .travis.yml | 4 ++-- src/replaceSymbols.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9389a5..fd6eb9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ cache: matrix: include: - - node_js: "11" + - node_js: "12" env: JOB_PART=pretest - node_js: "6" env: JOB_PART=test @@ -25,7 +25,7 @@ matrix: env: JOB_PART=test - node_js: "10" env: JOB_PART=test - - node_js: "11" + - node_js: "12" env: JOB_PART=test before_script: diff --git a/src/replaceSymbols.js b/src/replaceSymbols.js index dc29308..9e53448 100644 --- a/src/replaceSymbols.js +++ b/src/replaceSymbols.js @@ -2,12 +2,13 @@ import replaceValueSymbols from "./replaceValueSymbols.js"; const replaceSymbols = (css, replacements) => { css.walk(node => { - if (node.type === "decl") { + if (node.type === "decl" && node.value) { node.value = replaceValueSymbols(node.value, replacements); - } else if (node.type === "rule") { + } else if (node.type === "rule" && node.selector) { node.selector = replaceValueSymbols(node.selector, replacements); } else if ( node.type === "atrule" && + node.params && ["media", "supports"].includes(node.name.toLowerCase()) ) { node.params = replaceValueSymbols(node.params, replacements);