You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
result =Json.Decode.decodeValue (Json.Decode.dict Json.Decode.string) jsValue
when jsValue has been created in JavaScript using Object.create(null) and sent through flags or a port.
Attempting the decoding above results in a runtime exception with this error:
Uncaught TypeError: value.hasOwnProperty is not a function
at _Json_runHelp (VM37 workspace:1461)
at _Json_runHelp (VM37 workspace:1478)
at Function.f (VM37 workspace:1400)
at A2 (VM37 workspace:56)
at $author$project$Main$init (VM37 workspace:10540)
at VM37 workspace:8540
at VM37 workspace:20
at _Platform_initialize (VM37 workspace:1877)
at VM37 workspace:3973
at Object.init (VM37 workspace:20)
Object.create(null) is sometimes used to create a JavaScript dictionary . The difference with {} is that {} contains fields from the Object prototype, where Object.create(null) has no prototype and no fields at all.
This distinction, at least in JavaScript, can be important when you use this value as a set and only care about whether the field exists.
This distinction is irrelevant when decoding, but this runtime error makes it impossible to send values that in JS-land needed to be created this way without somehow cloning them beforehand.
The text was updated successfully, but these errors were encountered:
SSCCE
when
jsValue
has been created in JavaScript usingObject.create(null)
and sent through flags or a port.Attempting the decoding above results in a runtime exception with this error:
I created an Ellie here that you can interact with: https://ellie-app.com/8ZWrTfBzWRZa1
Additional Details
Object.create(null)
is sometimes used to create a JavaScript dictionary . The difference with{}
is that{}
contains fields from the Object prototype, whereObject.create(null)
has no prototype and no fields at all.This distinction, at least in JavaScript, can be important when you use this value as a set and only care about whether the field exists.
This distinction is irrelevant when decoding, but this runtime error makes it impossible to send values that in JS-land needed to be created this way without somehow cloning them beforehand.
The text was updated successfully, but these errors were encountered: