From 3949b94fc7744326db3f968893ac8b2d11d442ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Wed, 13 Dec 2023 22:31:28 +0400 Subject: [PATCH] feat: add "__argos__" class on root tag --- packages/browser/src/stabilization.ts | 10 ++++++++++ packages/playwright/fixtures/dummy.html | 3 +++ 2 files changed, 13 insertions(+) diff --git a/packages/browser/src/stabilization.ts b/packages/browser/src/stabilization.ts index e713824..625409f 100644 --- a/packages/browser/src/stabilization.ts +++ b/packages/browser/src/stabilization.ts @@ -150,6 +150,14 @@ export function restoreElementPositions(document: Document) { }); } +export function addGlobalClass(document: Document, className: string) { + document.documentElement.classList.add(className); +} + +export function removeGlobalClass(document: Document, className: string) { + document.documentElement.classList.remove(className); +} + export type SetupOptions = { fullPage?: boolean; argosCSS?: string }; /** @@ -159,6 +167,7 @@ export function setup( document: Document, { fullPage, argosCSS }: SetupOptions = {}, ) { + addGlobalClass(document, "__argos__"); injectGlobalStyles(document, GLOBAL_CSS, "argos-reset-style"); if (argosCSS) { injectGlobalStyles(document, argosCSS, "argos-user-style"); @@ -178,6 +187,7 @@ export function teardown( document: Document, { fullPage, argosCSS }: SetupOptions = {}, ) { + removeGlobalClass(document, "__argos__"); removeGlobalStyles(document, "argos-reset-style"); if (argosCSS) { removeGlobalStyles(document, "argos-user-style"); diff --git a/packages/playwright/fixtures/dummy.html b/packages/playwright/fixtures/dummy.html index dd98278..eaf84a8 100644 --- a/packages/playwright/fixtures/dummy.html +++ b/packages/playwright/fixtures/dummy.html @@ -44,6 +44,9 @@ border: 1px solid black; overflow: scroll; } + .__argos__ h1 { + font-variant: small-caps; + }