mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-19 14:06:33 +02:00
[BUGFIX] Correct evaluation of custom properties
This commit is contained in:
parent
06d4435c82
commit
ac8d27facf
|
@ -399,7 +399,7 @@ function () {
|
|||
selected: !!option.selected,
|
||||
disabled: option.disabled || option.parentNode.disabled,
|
||||
placeholder: option.value === '' || option.hasAttribute('placeholder'),
|
||||
customProperties: option.dataset['custom-properties']
|
||||
customProperties: _this._parseCustomProperties(option.dataset['customProperties'])
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -2503,6 +2503,18 @@ function () {
|
|||
return null;
|
||||
};
|
||||
|
||||
Choices.prototype._parseCustomProperties = function (customProperties) {
|
||||
if (typeof customProperties !== 'undefined') {
|
||||
try {
|
||||
return JSON.parse(customProperties);
|
||||
} catch (e) {
|
||||
return customProperties;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
return Choices;
|
||||
}();
|
||||
|
||||
|
|
2
public/assets/scripts/choices.min.js
vendored
2
public/assets/scripts/choices.min.js
vendored
File diff suppressed because one or more lines are too long
1
public/types/src/scripts/choices.d.ts
vendored
1
public/types/src/scripts/choices.d.ts
vendored
|
@ -213,6 +213,7 @@ declare class Choices implements Choices {
|
|||
_setChoiceOrItem(item: any): void;
|
||||
_findAndSelectChoiceByValue(value: string): void;
|
||||
_generatePlaceholderValue(): string | null;
|
||||
_parseCustomProperties(customProperties: any): any;
|
||||
}
|
||||
export default Choices;
|
||||
//# sourceMappingURL=choices.d.ts.map
|
File diff suppressed because one or more lines are too long
|
@ -290,7 +290,7 @@ class Choices implements Choices {
|
|||
disabled: option.disabled || option.parentNode.disabled,
|
||||
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;
|
||||
}
|
||||
|
||||
_parseCustomProperties(customProperties): any {
|
||||
if(typeof customProperties !== 'undefined') {
|
||||
try {
|
||||
return JSON.parse(customProperties)
|
||||
} catch(e) {
|
||||
return customProperties
|
||||
}
|
||||
}
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export default Choices;
|
||||
|
|
Loading…
Reference in a new issue