Skip to content

chore: Added Trusted Types to iconSVG #2574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@
"@types/jest": "^27.5.1",
"@types/lodash": "^4.14.176",
"@types/node": "^18.18.5",
"@types/react": "^16.14.20",
"@types/react": "16.14.40",
"@types/react-dom": "^16.9.14",
"@types/react-resizable": "^1.7.4",
"@types/react-router": "^5.1.18",
"@types/react-router-dom": "^5.3.2",
"@types/react-transition-group": "^4.4.4",
"@types/trusted-types": "^2.0.7",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency is problematic. It is supposed to be a bult-in dom.d.ts type, but temporarily it exists as a library.

When it becomes built-in, our consumers may have problems upgrading to the latest typescript because of that.

Is type-safety here really that much important, or can we get away with type casting

iconSvg: trustedPolicy.createHTML(svgHtml) as any as string,

"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
Expand Down
4 changes: 3 additions & 1 deletion src/internal/plugins/controllers/drawers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import type { TrustedHTML } from 'trusted-types/lib';

import debounce from '../../debounce';
import { NonCancelableEventHandler } from '../../events';

Expand All @@ -18,7 +20,7 @@ export interface DrawerConfig {
orderPriority?: number;
defaultActive?: boolean;
trigger: {
iconSvg: string;
iconSvg: string | TrustedHTML;
};
mountContent: (container: HTMLElement) => void;
unmountContent: (container: HTMLElement) => void;
Expand Down
Loading