remove html from getTextLabel()

pull/1840/head
Cory LaViska 2024-01-26 14:07:33 -05:00
rodzic 83fe1ff28e
commit 97467d580b
3 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -12,6 +12,10 @@ Components with the <sl-badge variant="warning" pill>Experimental</sl-badge> bad
New versions of Shoelace are released as-needed and generally occur when a critical mass of changes have accumulated. At any time, you can see what's coming in the next release by visiting [next.shoelace.style](https://next.shoelace.style).
## Next
- Fixed a bug in `<sl-option>` that caused HTML tags to be included in `getTextLabel()`
## 2.13.1
- Fixed a bug where the safe triangle was always visible when selecting nested `<sl-menu>` elements [#1835]

Wyświetl plik

@ -112,7 +112,7 @@ export default class SlOption extends ShoelaceElement {
[...nodes].forEach(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
if (!(node as HTMLElement).hasAttribute('slot')) {
label += (node as HTMLElement).outerHTML;
label += (node as HTMLElement).textContent;
}
}

Wyświetl plik

@ -52,4 +52,9 @@ describe('<sl-option>', () => {
expect(el.value).to.equal('10');
});
it('should escape HTML when calling getTextLabel()', async () => {
const el = await fixture<SlOption>(html` <sl-option><strong>Option</strong></sl-option> `);
expect(el.getTextLabel()).to.equal('Option');
});
});