Skip to content

Commit

Permalink
feat: add "__argos__" class on root tag
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Dec 13, 2023
1 parent f660148 commit 3949b94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/browser/src/stabilization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

/**
Expand All @@ -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");
Expand All @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions packages/playwright/fixtures/dummy.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
border: 1px solid black;
overflow: scroll;
}
.__argos__ h1 {
font-variant: small-caps;
}
</style>
</head>
<body>
Expand Down

0 comments on commit 3949b94

Please sign in to comment.