Skip to content

Commit

Permalink
Fix CSP violations due to inline styles
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Jan 5, 2024
1 parent ea0db7a commit 490f088
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
<div class="app-wrapper">%sveltekit.body%</div>
</body>
</html>
8 changes: 4 additions & 4 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('pswd matcher', () => {
await userEvent.type(initialPasswordInput, initialPassword);
expect(initialPasswordInput).toHaveValue(initialPassword);
expect(screen.queryByText('Passwords match')).not.toBeInTheDocument();
expect(screen.queryByText('Passwords do not match')).not.toBeVisible();
expect(screen.queryByText('Passwords do not match')?.parentElement).not.toHaveClass('visible');
});

it('should populate confirm password only', async () => {
Expand All @@ -31,7 +31,7 @@ describe('pswd matcher', () => {
await userEvent.type(confirmPasswordInput, confirmPassword);
expect(confirmPasswordInput).toHaveValue(confirmPassword);
expect(screen.queryByText('Passwords match')).not.toBeInTheDocument();
expect(screen.queryByText('Passwords do not match')).not.toBeVisible();
expect(screen.queryByText('Passwords do not match')?.parentElement).not.toHaveClass('visible');
});

it('should populate mismatching passwords', async () => {
Expand All @@ -45,7 +45,7 @@ describe('pswd matcher', () => {
expect(initialPasswordInput).toHaveValue(initialPassword);
expect(confirmPasswordInput).toHaveValue(confirmPassword);
expect(screen.queryByText('Passwords match')).not.toBeInTheDocument();
expect(screen.queryByText('Passwords do not match')).toBeVisible();
expect(screen.queryByText('Passwords do not match')).toBeInTheDocument();
});

it('should populate matching passwords', async () => {
Expand All @@ -57,7 +57,7 @@ describe('pswd matcher', () => {
await userEvent.type(confirmPasswordInput, password);
expect(initialPasswordInput).toHaveValue(password);
expect(confirmPasswordInput).toHaveValue(password);
expect(screen.queryByText('Passwords match')).toBeVisible();
expect(screen.queryByText('Passwords match')).toBeInTheDocument();
expect(screen.queryByText('Passwords do not match')).not.toBeInTheDocument();
});

Expand Down
2 changes: 1 addition & 1 deletion src/routes/MatchStatus.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div
class="match-status-container"
style:visibility={initialPassword !== '' && confirmPassword !== '' ? 'visible' : 'hidden'}
class:visible={initialPassword !== '' && confirmPassword !== ''}
aria-live="polite"
>
{#if initialPassword === confirmPassword}
Expand Down
3 changes: 3 additions & 0 deletions src/styles/_app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ body {
line-height: var(--line-height-app-text);
color: var(--color-app-text);
}
.app-wrapper {
display: contents;
}
.app {
margin: 0 auto;
max-width: 550px;
Expand Down
6 changes: 6 additions & 0 deletions src/styles/_match-status.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.match-status-container {
visibility: hidden;
&.visible {
visibility: visible;
}
}
.match-status {
margin: 0;
font-size: var(--font-size-match-status);
Expand Down

0 comments on commit 490f088

Please sign in to comment.