fix(canvas): don't clobber a display's live ImageData with the persisted string

Saved projects carry imageData: '' in the SSD1306's properties (the
generated metadata lists it as a text prop). The property-sync effect
assigned that string onto the web component, replacing the element's
live ImageData and crashing wokwi-elements' firstUpdated with
'putImageData: parameter 1 is not of type ImageData' on every project
load. Only a real ImageData may pass through now.
This commit is contained in:
David Montero 2026-08-11 05:19:26 +02:00
parent 49ac373068
commit 7ecc791187
1 changed files with 5 additions and 0 deletions

View File

@ -382,6 +382,11 @@ export const DynamicComponent: React.FC<DynamicComponentProps> = ({
Object.entries(properties).forEach(([key, value]) => {
try {
// Display framebuffers round-trip through saved projects as strings
// ('' — the generated metadata lists imageData as a text prop).
// Assigning that string clobbers the element's live ImageData and
// crashes wokwi-elements' firstUpdated (putImageData TypeError).
if (key === 'imageData' && !(value instanceof ImageData)) return;
let coerced: any = value;
if (typeof value === 'string') {
const def = metadata.defaultValues?.[key];