fix(check): name a color-graded video by its own selector in layout findings (#7699)

A color-graded <video> is painted into a canvas the runtime inserts after it,
with a runtime-generated id (__hf_color_grading_<video id>). Layout findings on
that canvas (e.g. container_overflow for a punch-in inside an overflow:hidden
box) named the canvas, so the fix hint "mark intentional overflow with
data-layout-allow-overflow" pointed at an element the author never wrote.
The audit already reads flags from the authored video (authoredElement);
uniqueSelectorFor now names that element too, so the finding's selector,
data attributes and source file are the video's.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
wonjang
2026-11-14 03:47:53 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent c66a430967
commit 08e11cb563
2 changed files with 4 additions and 3 deletions
@@ -91,7 +91,8 @@
return `${selectorFor(parent)} > ${element.tagName.toLowerCase()}:nth-of-type(${index})`;
}
function uniqueSelectorFor(element) {
function uniqueSelectorFor(subject) {
const element = authoredElement(subject);
const preferred = selectorFor(element);
try {
if (document.querySelectorAll(preferred).length === 1) return preferred;
@@ -1456,7 +1456,7 @@ describe("layout-audit.browser coordinate-frame findings", () => {
["flags", "", true],
["clears", "data-layout-allow-overflow", false],
])(
"%s a graded video's canvas overflowing a clipping wrapper, per the video's own flag",
"%s a graded video's canvas overflowing a clipping wrapper by the video's selector and flag",
(_, flag, flagged) => {
document.body.innerHTML = `
<div id="root" data-composition-id="main" data-width="1920" data-height="1080">
@@ -1476,7 +1476,7 @@ describe("layout-audit.browser coordinate-frame findings", () => {
installAuditScript();
const overflow = runAudit().filter((issue) => issue.code === "container_overflow");
expect(overflow.map((issue) => issue.selector)).toEqual(flagged ? ["#art"] : []);
expect(overflow.map((issue) => issue.selector)).toEqual(flagged ? ["#clip"] : []);
},
);