mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-07-03 20:41:07 +02:00
Merge c7374e72db into 75842fa06b
This commit is contained in:
commit
597bc72cec
1 changed files with 21 additions and 4 deletions
|
|
@ -100,6 +100,19 @@ const getElementType = (element) => {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isTextEntryElement = (element) => (
|
||||||
|
element instanceof HTMLInputElement
|
||||||
|
|| element instanceof HTMLTextAreaElement
|
||||||
|
|| (element instanceof HTMLElement && element.isContentEditable)
|
||||||
|
);
|
||||||
|
|
||||||
|
const shouldRedactVerificationValue = (element) => (
|
||||||
|
element instanceof HTMLInputElement
|
||||||
|
? !['checkbox', 'radio', 'range', 'button', 'submit', 'reset'].includes((element.type || '').toLowerCase())
|
||||||
|
: element instanceof HTMLTextAreaElement
|
||||||
|
|| (element instanceof HTMLElement && element.isContentEditable)
|
||||||
|
);
|
||||||
|
|
||||||
const getElementLabel = (element) => {
|
const getElementLabel = (element) => {
|
||||||
const ariaLabel = truncateText(element.getAttribute('aria-label') ?? '', 120);
|
const ariaLabel = truncateText(element.getAttribute('aria-label') ?? '', 120);
|
||||||
if (ariaLabel) return ariaLabel;
|
if (ariaLabel) return ariaLabel;
|
||||||
|
|
@ -121,10 +134,12 @@ const getElementLabel = (element) => {
|
||||||
const placeholder = truncateText(element.getAttribute('placeholder') ?? '', 120);
|
const placeholder = truncateText(element.getAttribute('placeholder') ?? '', 120);
|
||||||
if (placeholder) return placeholder;
|
if (placeholder) return placeholder;
|
||||||
|
|
||||||
|
if (isTextEntryElement(element)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const text = truncateText(
|
const text = truncateText(
|
||||||
element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement
|
element.textContent ?? '',
|
||||||
? element.value
|
|
||||||
: element.textContent ?? '',
|
|
||||||
120,
|
120,
|
||||||
);
|
);
|
||||||
return text || null;
|
return text || null;
|
||||||
|
|
@ -187,7 +202,9 @@ const getVerificationTargetState = (element) => {
|
||||||
? element.checked
|
? element.checked
|
||||||
: null,
|
: null,
|
||||||
value:
|
value:
|
||||||
element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement
|
shouldRedactVerificationValue(element)
|
||||||
|
? null
|
||||||
|
: element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement
|
||||||
? truncateText(element.value ?? '', 200)
|
? truncateText(element.value ?? '', 200)
|
||||||
: element instanceof HTMLSelectElement
|
: element instanceof HTMLSelectElement
|
||||||
? truncateText(element.value ?? '', 200)
|
? truncateText(element.value ?? '', 200)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue