Skip to content

Commit

Permalink
fix: handle values that are not string
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Feb 18, 2024
1 parent 9324c99 commit 7b1374b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7b1374b

Please sign in to comment.