[BUGFIX] Correct evaluation of custom properties

This commit is contained in:
Josua Vogel 2022-01-17 13:46:19 +01:00
parent 06d4435c82
commit ac8d27facf
5 changed files with 28 additions and 4 deletions

View file

@ -399,7 +399,7 @@ function () {
selected: !!option.selected, selected: !!option.selected,
disabled: option.disabled || option.parentNode.disabled, disabled: option.disabled || option.parentNode.disabled,
placeholder: option.value === '' || option.hasAttribute('placeholder'), placeholder: option.value === '' || option.hasAttribute('placeholder'),
customProperties: option.dataset['custom-properties'] customProperties: _this._parseCustomProperties(option.dataset['customProperties'])
}); });
}); });
} }
@ -2503,6 +2503,18 @@ function () {
return null; return null;
}; };
Choices.prototype._parseCustomProperties = function (customProperties) {
if (typeof customProperties !== 'undefined') {
try {
return JSON.parse(customProperties);
} catch (e) {
return customProperties;
}
}
return {};
};
return Choices; return Choices;
}(); }();

File diff suppressed because one or more lines are too long

View file

@ -213,6 +213,7 @@ declare class Choices implements Choices {
_setChoiceOrItem(item: any): void; _setChoiceOrItem(item: any): void;
_findAndSelectChoiceByValue(value: string): void; _findAndSelectChoiceByValue(value: string): void;
_generatePlaceholderValue(): string | null; _generatePlaceholderValue(): string | null;
_parseCustomProperties(customProperties: any): any;
} }
export default Choices; export default Choices;
//# sourceMappingURL=choices.d.ts.map //# sourceMappingURL=choices.d.ts.map

File diff suppressed because one or more lines are too long

View file

@ -290,7 +290,7 @@ class Choices implements Choices {
disabled: option.disabled || option.parentNode.disabled, disabled: option.disabled || option.parentNode.disabled,
placeholder: placeholder:
option.value === '' || option.hasAttribute('placeholder'), option.value === '' || option.hasAttribute('placeholder'),
customProperties: option.dataset['custom-properties'], customProperties: this._parseCustomProperties(option.dataset['customProperties']),
}); });
}); });
} }
@ -2428,6 +2428,17 @@ class Choices implements Choices {
return null; return null;
} }
_parseCustomProperties(customProperties): any {
if(typeof customProperties !== 'undefined') {
try {
return JSON.parse(customProperties)
} catch(e) {
return customProperties
}
}
return {}
}
} }
export default Choices; export default Choices;