fix(canvas): guard the mount-time property loop against the persisted imageData string too

c201f5d9 guarded the property-sync effect, but the mount effect has its
own raw Object.entries(properties) loop that runs first and assigned the
saved imageData: '' onto the fresh element — so the firstUpdated
putImageData crash survived. Same guard, second call site.
This commit is contained in:
David Montero 2026-08-11 05:45:33 +02:00
parent 7ecc791187
commit 8f7b878149
1 changed files with 4 additions and 0 deletions

View File

@ -623,6 +623,10 @@ export const DynamicComponent: React.FC<DynamicComponentProps> = ({
// Set initial properties
Object.entries(properties).forEach(([key, value]) => {
try {
// Same guard as the property-sync effect above: the persisted
// imageData string must never replace the element's live ImageData
// (it crashes wokwi-elements' firstUpdated on mount).
if (key === 'imageData' && !(value instanceof ImageData)) return;
(element as any)[key] = value;
} catch (error) {
console.warn(`Failed to set initial property ${key}:`, error);