wcb/src/utils/deserialize.mjs
Ayo 737ef54763
Some checks are pending
Tests / Unit (push) Waiting to run
Tests / E2E (push) Waiting to run
fix: boolean props w/ bare attr as true
2026-07-19 18:14:13 +02:00

19 lines
394 B
JavaScript

/**
*
* @param value
* @param type
*/
export function deserialize(value, type) {
switch (type) {
case 'boolean':
// bare presence follows the HTML convention: `<el flag>` / `flag=""` is true.
if (value === '') return true
// falls through
case 'number':
case 'object':
case 'undefined':
return JSON.parse(value)
default:
return value
}
}