Archived
refactor(test): remove unused template-inspection helpers
Remove the three shared template-inspection test helpers that had no consumer after the Slice B migrations: templateStaticMarkup, collectTemplateStrings, and collectStringValues. They were kept alive only by a temporary @public knip shim; with no in-window test needing them, the finish-line requirement forbids dead helpers, so remove them outright. knip is now satisfied without the shim.
This commit is contained in:
@@ -64,53 +64,6 @@ export function isTemplateEventHandler<E extends Event = Event>(value: unknown):
|
||||
return typeof value === "function";
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenate only the static markup chunks of a template tree.
|
||||
*
|
||||
* Use for asserting stable structural markers (tag/attribute names, ids
|
||||
* intentionally used by the component) while locating wiring — not as a general
|
||||
* content-assertion tool.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export function templateStaticMarkup(template: TemplateResult): string {
|
||||
const chunks: string[] = [];
|
||||
visit(template);
|
||||
return chunks.join("");
|
||||
|
||||
function visit(value: unknown): void {
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) visit(item);
|
||||
return;
|
||||
}
|
||||
if (!isTemplateResult(value)) return;
|
||||
chunks.push(...templateStrings(value));
|
||||
for (const child of templateValues(value)) visit(child);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The static markup chunks of a template tree as a flat array.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export function collectTemplateStrings(template: TemplateResult): string[] {
|
||||
const strings: string[] = [];
|
||||
visit(template);
|
||||
return strings;
|
||||
|
||||
function visit(current: TemplateResult): void {
|
||||
strings.push(...templateStrings(current));
|
||||
for (const value of templateValues(current)) {
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) if (isTemplateResult(item)) visit(item);
|
||||
} else if (isTemplateResult(value)) {
|
||||
visit(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten static markup interleaved with primitive (string/number) values into
|
||||
* a single string, in document order.
|
||||
@@ -125,30 +78,6 @@ export function templateText(value: unknown): string {
|
||||
return typeof value === "string" || typeof value === "number" ? String(value) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect every interpolated string value in a template tree, in order.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export function collectStringValues(template: TemplateResult): string[] {
|
||||
const found: string[] = [];
|
||||
visit(template);
|
||||
return found;
|
||||
|
||||
function visit(value: unknown): void {
|
||||
if (typeof value === "string") {
|
||||
found.push(value);
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) visit(item);
|
||||
return;
|
||||
}
|
||||
if (!isTemplateResult(value)) return;
|
||||
for (const child of templateValues(value)) visit(child);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Every interpolated value whose immediately preceding static chunk includes
|
||||
* `marker`, collected across the whole tree in document order.
|
||||
|
||||
Reference in New Issue
Block a user