From 8f7b878149daf039bb5e791bfdbcf9322b5c9867 Mon Sep 17 00:00:00 2001 From: David Montero Date: Tue, 11 Aug 2026 05:45:33 +0200 Subject: [PATCH] fix(canvas): guard the mount-time property loop against the persisted imageData string too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- frontend/src/components/DynamicComponent.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/components/DynamicComponent.tsx b/frontend/src/components/DynamicComponent.tsx index b6a0e501..3f1b3c56 100644 --- a/frontend/src/components/DynamicComponent.tsx +++ b/frontend/src/components/DynamicComponent.tsx @@ -623,6 +623,10 @@ export const DynamicComponent: React.FC = ({ // 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);