mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Support Map
and Set
, with postMessage
, when workers are disabled
The `LoopbackPort` currently doesn't support `Map` and `Set`, which it should since the "structured clone algorithm" used in browsers does support both of them; please see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types
This commit is contained in:
parent
952bc08ec0
commit
73bf45e64b
1 changed files with 17 additions and 1 deletions
|
@ -1656,8 +1656,24 @@ class LoopbackPort {
|
|||
cloned.set(value, result);
|
||||
return result;
|
||||
}
|
||||
if (value instanceof Map) {
|
||||
result = new Map();
|
||||
cloned.set(value, result); // Adding to cache now for cyclic references.
|
||||
for (const [key, val] of value) {
|
||||
result.set(key, cloneValue(val));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (value instanceof Set) {
|
||||
result = new Set();
|
||||
cloned.set(value, result); // Adding to cache now for cyclic references.
|
||||
for (const val of value) {
|
||||
result.add(cloneValue(val));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
result = Array.isArray(value) ? [] : {};
|
||||
cloned.set(value, result); // adding to cache now for cyclic references
|
||||
cloned.set(value, result); // Adding to cache now for cyclic references.
|
||||
// Cloning all value and object properties, however ignoring properties
|
||||
// defined via getter.
|
||||
for (const i in value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue