

I tested it with some objects and I can show you following examples when this is happening. Object (Note: This just includes plain objects (e.g.ArrayBufferView (Note: This basically means all typed arrays like Int32Array etc.).RegExp (Note: The lastIndex field is not preserved.).All primitive types (Note: However not symbols).The prototype chain does not get walked and duplicated.In the duplicate, since that's the default condition. Is marked read-only using a property descriptor, it will be read-write Property descriptors, setters, and getters (as well as similar metadata-like features) are not duplicated.The lastIndex field of RegExp objects is not preserved.Things that don't work with structured cloneĮrror and Function objects cannot be duplicated by the structured clone algorithm attempting to do so will throw aĪttempting to clone DOM nodes will likewise throw a DATA_CLONE_ERR exception.Ĭertain parameters of objects are not preserved: It builds up a clone by recursing through the input object while maintaining a map of previously visited references in order to avoid infinitely traversing cycles. It is used internally when transferring data to and from Workers via postMessage() or when storing objects with IndexedDB. The structured clone algorithm is an algorithm defined by the HTML5 specification for copying complex JavaScript objects. The data is serialized using the structured clone algorithm.Īnd then open the description from structured clone algorithm (see last link above) then we can read: If we read the documentation from window.postMessage for the first parameter:ĭata to be sent to the other window. This algorithm is used by window.postMessage. This happens all the time, if something can not be duplicated by the structured clone algorithm.
