diff --git a/.changeset/odd-cups-invent.md b/.changeset/odd-cups-invent.md new file mode 100644 index 000000000..ab4ddd7ad --- /dev/null +++ b/.changeset/odd-cups-invent.md @@ -0,0 +1,5 @@ +--- +'@preact/async-loader': patch +--- + +Fix for possible type error in `async-loader` diff --git a/packages/async-loader/async.js b/packages/async-loader/async.js index 4319eb6e5..edb1c1314 100644 --- a/packages/async-loader/async.js +++ b/packages/async-loader/async.js @@ -5,7 +5,7 @@ const PENDING = {}; // Given a VNode, finds its previous element sibling function getPreviousSibling(vnode, inner) { // in an element parent with no preceeding siblings means we're the first child - if (typeof vnode.type === 'string') return null; + if (!vnode || typeof vnode.type === 'string') return null; const parent = vnode.__; if (!parent) return; let children = parent.__k; @@ -16,7 +16,7 @@ function getPreviousSibling(vnode, inner) { if (end === -1) end = children.length; for (let i = end; i--; ) { const child = children[i]; - const dom = (child && child.__e) || getPreviousSibling(child, true); + const dom = child && (child.__e || getPreviousSibling(child, true)); if (dom) return dom; } } diff --git a/packages/cli/tests/images/build.js b/packages/cli/tests/images/build.js index 7f11b9a0a..0eead3ee4 100644 --- a/packages/cli/tests/images/build.js +++ b/packages/cli/tests/images/build.js @@ -17,8 +17,8 @@ exports.default = Object.assign({}, common, { 'ssr-build/ssr-bundle.js.map': 52686, 'ssr-build/asset-manifest.json': 178, 'bundle.259c5.css': 901, - 'bundle.f79fb.js': 21429, - 'bundle.f79fb.js.map': 111801, + 'bundle.85124.js': 21429, + 'bundle.85124.js.map': 111801, 'favicon.ico': 15086, 'index.html': 2034, 'manifest.json': 455,