All files / src/lib view-transition-name.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10              5x    
/**
 * The shared view-transition-name for a project's photo, so a swatch on a
 * listing morphs into the opened project's gallery. Project ids carry
 * characters like ':' that are not valid in a CSS ident, so they are folded
 * to '-'. Two elements on one page must never share a name.
 */
export function projectTransitionName(id: string): string {
	return `project-${id.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
}