Skip to content

Commit 3c371f7

Browse files
rschristianpsabharwal123Sparrowhawk
authored
fix: async loader missing undefined check (#1763)
* fix: Bail from `getPreviousSibling` if VNode undefined Co-authored-by: psabharwal123 <[email protected]> Co-authored-by: Sparrowhawk <[email protected]> * docs: Adding changeset * test: Update build hashes Co-authored-by: psabharwal123 <[email protected]> Co-authored-by: Sparrowhawk <[email protected]>
1 parent fb100b3 commit 3c371f7

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.changeset/odd-cups-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@preact/async-loader': patch
3+
---
4+
5+
Fix for possible type error in `async-loader`

packages/async-loader/async.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const PENDING = {};
55
// Given a VNode, finds its previous element sibling
66
function getPreviousSibling(vnode, inner) {
77
// in an element parent with no preceeding siblings means we're the first child
8-
if (typeof vnode.type === 'string') return null;
8+
if (!vnode || typeof vnode.type === 'string') return null;
99
const parent = vnode.__;
1010
if (!parent) return;
1111
let children = parent.__k;
@@ -16,7 +16,7 @@ function getPreviousSibling(vnode, inner) {
1616
if (end === -1) end = children.length;
1717
for (let i = end; i--; ) {
1818
const child = children[i];
19-
const dom = (child && child.__e) || getPreviousSibling(child, true);
19+
const dom = child && (child.__e || getPreviousSibling(child, true));
2020
if (dom) return dom;
2121
}
2222
}

packages/cli/tests/images/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ exports.default = Object.assign({}, common, {
1717
'ssr-build/ssr-bundle.js.map': 52686,
1818
'ssr-build/asset-manifest.json': 178,
1919
'bundle.259c5.css': 901,
20-
'bundle.f79fb.js': 21429,
21-
'bundle.f79fb.js.map': 111801,
20+
'bundle.85124.js': 21429,
21+
'bundle.85124.js.map': 111801,
2222
'favicon.ico': 15086,
2323
'index.html': 2034,
2424
'manifest.json': 455,

0 commit comments

Comments
 (0)