diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97f9903..12d27e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - name: Restore yarn cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} diff --git a/src/styleSheetSerializer.js b/src/styleSheetSerializer.js index 3714bfb..aa0748d 100644 --- a/src/styleSheetSerializer.js +++ b/src/styleSheetSerializer.js @@ -2,13 +2,19 @@ const css = require('@adobe/css-tools'); const { getCSS, getHashes } = require('./utils'); let cache = new WeakSet(); + const getNodes = (node, nodes = []) => { - if (typeof node === 'object') { - nodes.push(node); + if (!node || typeof node !== 'object') { + return nodes; } - if (node.children) { - Array.from(node.children).forEach((child) => getNodes(child, nodes)); + nodes.push(node); + + if (node.children && typeof node.children === 'object') { + try { + Array.from(node.children).forEach((child) => getNodes(child, nodes)); + } catch (_) { + } } return nodes;