67f3c4d824
* add `get-text-value` helper * use `getTextValue` in `Listbox` component * use `getTextValue` in `Menu` component * update changelog * ensure we handle multiple values for `aria-labelledby` * hoist regex * drop child nodes instead of replacing its innerText This makes it a bit slower but also more correct. We can use a cache on another level to ensure that we are not creating useless work. * add `useTextValue` to improve performance of `getTextValue` This will add a cache and only if the `innerText` changes, only then will we calculate the new text value. * use better `useTextValue` hook
16 lines
627 B
TypeScript
16 lines
627 B
TypeScript
// JSDOM Doesn't implement innerText yet: https://github.com/jsdom/jsdom/issues/1245
|
|
// So this is a hacky way of implementing it using `textContent`.
|
|
// Real implementation doesn't use textContent because:
|
|
// > textContent gets the content of all elements, including <script> and <style> elements. In
|
|
// > contrast, innerText only shows "human-readable" elements.
|
|
// >
|
|
// > — https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#differences_from_innertext
|
|
Object.defineProperty(HTMLElement.prototype, 'innerText', {
|
|
get() {
|
|
return this.textContent
|
|
},
|
|
set(value) {
|
|
this.textContent = value
|
|
},
|
|
})
|