From 7b1374b984673f541b99d7deb29af990b88e962c Mon Sep 17 00:00:00 2001 From: frankpagan Date: Sun, 18 Feb 2024 11:30:34 -0500 Subject: [PATCH] fix: handle values that are not string --- src/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index e6b52e2..8e14edc 100644 --- a/src/index.js +++ b/src/index.js @@ -244,9 +244,13 @@ const CoCreateEvents = { } else { values = element.getAttribute(`${prefix}-value`) || element.getAttribute(`${prefix}-if-value`) || element.getAttribute(prefix); } - if (values) - values = values.split(','); - else { + + if (values) { + if (typeof values === 'string') + values = values.split(','); + else if (!Array.isArray(values)) + values = [values] + } else { values = await element.getValue() if (!Array.isArray(values)) values = [values] @@ -313,7 +317,8 @@ const CoCreateEvents = { // values = values.map(x => x.trim()); values = values.map(x => { - x = x.trim(); // Update x with the trimmed value + if (typeof x === 'string') + x = x.trim(); // Update x with the trimmed value let prop = element.getAttribute(`${prefix}-property`); if (prop) { x = `${prop}:${x}`; // Update x with prop if it exists