Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dangerouslySetInnerHTML={undefined} throws #380

Open
birtles opened this issue Jul 22, 2024 · 2 comments
Open

dangerouslySetInnerHTML={undefined} throws #380

birtles opened this issue Jul 22, 2024 · 2 comments

Comments

@birtles
Copy link

birtles commented Jul 22, 2024

The type of dangerouslySetInnerHTML is:

dangerouslySetInnerHTML?: {
  __html: string;
};

However, when setting dangerouslySetInnerHTML to undefined I hit this code here:

if (Array.isArray(rendered)) {
let count = 0;
let resolved = rendered;
// Resolving nested Promises with a maximum depth of 25
while (
resolved.some((element) => typeof element.then === 'function') &&
count++ < 25
) {
resolved = (await Promise.all(resolved)).flat();
}
return resolved.join('');
}

Here element is undefined and I get Cannot read properties of undefined (reading 'then').

Using typeof element?.then === 'function' seems to fix it for me.

@marvinhagemeister
Copy link
Member

marvinhagemeister commented Jul 22, 2024

I'm not able to reproduce the described error on my end. Are you on the latest version? Can you share a snippet that reproduces the error for you?

@birtles
Copy link
Author

birtles commented Jul 22, 2024

Oh, sorry about that. I was hitting this via Astro's Preact package and it seemed to come from this changeset: withastro/astro#11464

I'll see if I can work out what is going on when I get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants