mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
fix(lint): a descendant selector inside a scoped query hides the overlay too
This commit is contained in:
@@ -3753,6 +3753,24 @@ describe("SVG draw-on rules", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts a descendant selector inside the query", async () => {
|
||||
expect(
|
||||
await flagged(
|
||||
scene(
|
||||
'gsap.set(document.querySelector("[data-composition-id=scene] .ov"), { opacity: 0 });',
|
||||
),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts a querySelector variable written without semicolons", async () => {
|
||||
expect(
|
||||
await flagged(
|
||||
scene('const ov = root.querySelector(".ov")\n gsap.set(ov, { opacity: 0 })'),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("still flags an overlay nothing hides at zero", async () => {
|
||||
expect(await flagged(scene(""))).toBe(true);
|
||||
});
|
||||
|
||||
@@ -274,7 +274,7 @@ function extractStandaloneHiddenSelectors(script: string): Set<string> {
|
||||
aliases.set(match[1] ?? "", match[3] ?? "");
|
||||
}
|
||||
for (const match of source.matchAll(
|
||||
/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*[\w$.]+\.querySelector(?:All)?\(\s*(["'`])([^"'`]+)\2\s*\)\s*;/g,
|
||||
/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*[\w$.]+\.querySelector(?:All)?\(\s*(["'`])([^"'`]+)\2\s*\)/g,
|
||||
)) {
|
||||
aliases.set(match[1] ?? "", match[3] ?? "");
|
||||
}
|
||||
@@ -1202,7 +1202,14 @@ export const gsapRules: LintRule<LintContext>[] = [
|
||||
(win.fromPropertyValues !== undefined && isHiddenGsapState(win.fromPropertyValues))),
|
||||
);
|
||||
if (startsHiddenAtZero) continue;
|
||||
if (selectors.some((selector) => authoredHiddenSelectors.has(selector))) continue;
|
||||
if (
|
||||
selectors.some((selector) =>
|
||||
[...authoredHiddenSelectors].some(
|
||||
(hidden) => hidden === selector || targetedSelectorTokens(hidden).has(selector),
|
||||
),
|
||||
)
|
||||
)
|
||||
continue;
|
||||
const firstVisible = visibilityWindows.find((win) => makesOverlayVisible(win));
|
||||
if (!firstVisible) continue;
|
||||
const selector =
|
||||
|
||||
Reference in New Issue
Block a user