Widget expressions: Fix handling of Item name being `undefined` & Align behaviour for @ and @@ shorthands in that case (#2965)

Fixes #2956.
This fix creates the limitation that an Item must not be named
`undefined` - for an Item with this name, state tracking won't work.

---------

Signed-off-by: Florian Hotze <dev@florianhotze.com>
pull/2973/head
Florian Hotze 2025-01-04 16:13:18 +01:00 committed by GitHub
parent 4380671878
commit f1c3896897
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -16,12 +16,12 @@ import jsepTemplate from '@jsep-plugin/template'
expr.jsep.plugins.register(jsepRegex, jsepArrow, jsepObject, jsepTemplate)
expr.addUnaryOp('@', (itemName) => {
if (itemName === undefined) return undefined
if (itemName === undefined) return '-'
const item = store.getters.trackedItems[itemName]
return (item.displayState !== undefined) ? item.displayState : item.state
})
expr.addUnaryOp('@@', (itemName) => {
if (itemName === undefined) return undefined
if (itemName === undefined) return '-'
return store.getters.trackedItems[itemName].state
})
expr.addUnaryOp('#', (itemName) => {

View File

@ -23,6 +23,7 @@ const handler = (context) => {
if (typeof prop !== 'string') return {}
const itemName = prop
if (itemName === 'undefined') return { state: '-' }
if (!context.getters.isItemTracked(itemName)) {
context.commit('addToTrackingList', itemName.toString())