Merge pull request #1365 from Choices-js/trusted-label-description

Fix data-label-description from source html was not treated as trusted
This commit is contained in:
Xon 2026-01-01 01:48:46 +08:00 committed by GitHub
commit d926bd0219
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 9 additions and 5 deletions

View file

@ -94,7 +94,9 @@ export default class WrappedSelect extends WrappedElement<HTMLSelectElement> {
labelClass:
typeof option.dataset.labelClass !== 'undefined' ? stringToHtmlClass(option.dataset.labelClass) : undefined,
labelDescription:
typeof option.dataset.labelDescription !== 'undefined' ? option.dataset.labelDescription : undefined,
typeof option.dataset.labelDescription !== 'undefined'
? { trusted: option.dataset.labelDescription }
: undefined,
customProperties: parseCustomProperties(option.dataset.customProperties),
};
}

View file

@ -1,4 +1,5 @@
import { StringUntrusted } from './string-untrusted';
import { StringPreEscaped } from './string-pre-escaped';
import { Types } from './types';
// eslint-disable-next-line import/no-cycle
import { GroupFull } from './group-full';
@ -15,7 +16,7 @@ export interface ChoiceFull {
itemEl?: HTMLElement;
choiceEl?: HTMLElement;
labelClass?: Array<string>;
labelDescription?: string;
labelDescription?: StringPreEscaped | StringUntrusted | string;
customProperties?: Types.CustomProperties;
disabled: boolean;
active: boolean;

View file

@ -1,4 +1,5 @@
import { StringUntrusted } from './string-untrusted';
import { StringPreEscaped } from './string-pre-escaped';
// eslint-disable-next-line
import { Types } from './types';
@ -6,7 +7,7 @@ export interface InputChoice {
id?: number;
highlighted?: boolean;
labelClass?: string | Array<string>;
labelDescription?: string;
labelDescription?: StringPreEscaped | StringUntrusted | string;
customProperties?: Types.CustomProperties;
disabled?: boolean;
active?: boolean;

View file

@ -135,7 +135,7 @@ export const getChoiceForOutput = (choice: ChoiceFull, keyCode?: number): EventC
id: choice.id,
highlighted: choice.highlighted,
labelClass: choice.labelClass,
labelDescription: choice.labelDescription,
labelDescription: unwrapStringForRaw(choice.labelDescription),
customProperties: choice.customProperties,
disabled: choice.disabled,
active: choice.active,

View file

@ -41,7 +41,7 @@ const assignCustomProperties = (el: HTMLElement, choice: ChoiceFull, withCustomP
}
if (labelDescription) {
dataset.labelDescription = labelDescription;
dataset.labelDescription = unwrapStringForRaw(labelDescription);
}
if (withCustomProperties && customProperties) {