Skip to content

Commit

Permalink
[blockly] Fix missing event property causes JS error (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-hoehn committed Mar 24, 2024
1 parent a81bb0d commit 32b8b88
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,11 @@ export default function defineOHBlocks_Scripts (f7, isGraalJs, scripts) {
if (contextInfo === 'ruleUID') return ['ctx.ruleUID', javascriptGenerator.ORDER_ATOMIC]
if (contextInfo === 'itemState' || contextInfo === 'oldItemState' || contextInfo === 'itemCommand') {
if (type === 'asNumber') {
return [`parseFloat(event.${contextInfo}.toString())`, javascriptGenerator.ORDER_ATOMIC]
return [`event.${contextInfo} !== undefined ? parseFloat(event.${contextInfo}.toString()) : undefined`, javascriptGenerator.ORDER_ATOMIC]
} else if (type === 'asQuantity') {
return [`Quantity(event.${contextInfo}.toString())`, javascriptGenerator.ORDER_ATOMIC]
return [`event.${contextInfo} !== undefined ? Quantity(event.${contextInfo}.toString() : undefined)`, javascriptGenerator.ORDER_ATOMIC]
} else {
return [`event.${contextInfo}.toString()`, javascriptGenerator.ORDER_ATOMIC]
return [`event.${contextInfo}?.toString()`, javascriptGenerator.ORDER_ATOMIC]
}
}
return [`event.${contextInfo}`, javascriptGenerator.ORDER_ATOMIC]
Expand Down

0 comments on commit 32b8b88

Please sign in to comment.