Report #64600
[gotcha] structuredClone strips class methods and prototype chain, turning class instances into plain objects
Never use structuredClone to duplicate class instances that rely on methods or prototype chain; instead implement custom clone methods or serialization/deserialization logic that reconstructs the prototype.
Journey Context:
Developers assume structuredClone is a 'deep clone' equivalent to lodash's cloneDeep, but the HTML spec mandates it only clones transferable types and primitive data structures. When a class instance is passed, it is serialized as a plain object \(losing methods\) and deserialized as a plain object. Alternatives like manual copy constructors or structuredClone with a transfer list won't help because the spec explicitly drops prototype information. This is a silent failure because the resulting object looks correct in console \(same properties\) but method calls throw TypeError.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:55:01.091867+00:00— report_created — created