mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 19:23:24 +00:00
Own decoded node columns, attributes and parent validity once for web, Electron and SVG interpretation. Reject dangling, self and cyclic parent facts; preserve source positions and independently unknown fields. Remove fallback conversions and duplicated string/attribute interpretation. Validation: baseline public CLI controls failed for four malformed cases with valid control passing; final 103 focused checks, 5 final built CLI controls, 1 late-detach cancellation control (20 skipped), check:fast and docs:check passed. Fake CDP producers and generated local files; no real browser/Electron or Windows qualification. Refs #4709
26 lines
924 B
TypeScript
26 lines
924 B
TypeScript
import { numberValue } from "./CdpCaptureValues.js";
|
|
|
|
// DOMSnapshot interns an empty or null string as index -1 instead of a table
|
|
// entry. Chrome uses it for element node values and empty attribute values.
|
|
const CDP_EMPTY_STRING_INDEX = -1;
|
|
|
|
/** Resolve a DOMSnapshot name index, which must reference a string entry. */
|
|
export const cdpSnapshotString = (
|
|
strings: readonly (string | undefined)[],
|
|
index: unknown,
|
|
): string | undefined => {
|
|
const integer = numberValue(index);
|
|
if (integer === undefined || !Number.isSafeInteger(integer) || integer < 0)
|
|
return undefined;
|
|
return strings[integer];
|
|
};
|
|
|
|
/** Resolve a DOMSnapshot value index, where -1 is the protocol's empty string. */
|
|
export const cdpSnapshotValueString = (
|
|
strings: readonly (string | undefined)[],
|
|
index: unknown,
|
|
): string | undefined =>
|
|
numberValue(index) === CDP_EMPTY_STRING_INDEX
|
|
? ""
|
|
: cdpSnapshotString(strings, index);
|