-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Based on the condition below the keyForValue call based on the default Enum's _keyForValue will always return null here for null obj
sdl_javascript_suite/lib/js/src/rpc/RpcStruct.js
Lines 141 to 146 in 1e0e6be
| } else if ( | |
| (tClass.prototype instanceof Enum && tClass.keyForValue(obj) === null) | |
| || (tClass.prototype instanceof RpcStruct && obj !== null && obj.constructor !== tClass) | |
| ) { | |
| throw new Error(`${obj.name} must be of type ${tClass.name}`); | |
| } |
Then because the condition is
true, the code fails in line 145 with the error
TypeError: Cannot read property 'name' of null
Currently, all Enum classes use default _keyForValue for checks in their keyForValue methods so it is impossible to set null for all Enum properties (mandatory or optional) in all Structs and Messages
Steps to reproduce:
- Create for example the new instance of
KeyboardPropertiesstructure - Try to set
KeyboardLayoutparameter (according to the spec this parameter is not mandatory) by callingsetKeyboardLayoutmethod withnullvalue - ER:
nullis successfully set, AR: the TypeError
new SDL.rpc.structs.KeyboardProperties().setKeyboardLayout(null) // this fails with TypeError: Cannot read property 'name' of nullMetadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working