Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e3534f

Browse filesBrowse files
arturovtmhevery
authored andcommitted
perf(core): use ngDevMode to tree-shake warnings (#39959)
This commit adds `ngDevMode` guard to show sanitization warnings only in dev mode (similar to how things work in other parts of Ivy runtime code). The `ngDevMode` flag helps to tree-shake these warnings from production builds (in dev mode everything will work as it works right now) to decrease production bundle size. PR Close #39959
1 parent 16b706b commit 1e3534f
Copy full SHA for 1e3534f

File tree

3 files changed

+3
-5
lines changed
Filter options

3 files changed

+3
-5
lines changed

‎goldens/size-tracking/integration-payloads.json

Copy file name to clipboardExpand all lines: goldens/size-tracking/integration-payloads.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"master": {
4040
"uncompressed": {
4141
"runtime-es2015": 2285,
42-
"main-es2015": 242075,
42+
"main-es2015": 241457,
4343
"polyfills-es2015": 36709,
4444
"5-es2015": 745
4545
}

‎packages/core/src/sanitization/html_sanitizer.ts

Copy file name to clipboardExpand all lines: packages/core/src/sanitization/html_sanitizer.ts
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {isDevMode} from '../util/is_dev_mode';
109
import {getInertBodyHelper, InertBodyHelper} from './inert_body';
1110
import {_sanitizeUrl, sanitizeSrcset} from './url_sanitizer';
1211

@@ -269,7 +268,7 @@ export function _sanitizeHtml(defaultDoc: any, unsafeHtmlInput: string): string
269268
const sanitizer = new SanitizingHtmlSerializer();
270269
const safeHtml = sanitizer.sanitizeChildren(
271270
getTemplateContent(inertBodyElement!) as Element || inertBodyElement);
272-
if (isDevMode() && sanitizer.sanitizedSomething) {
271+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && sanitizer.sanitizedSomething) {
273272
console.warn(
274273
'WARNING: sanitizing HTML stripped some content, see https://g.co/ng/security#xss');
275274
}

‎packages/core/src/sanitization/url_sanitizer.ts

Copy file name to clipboardExpand all lines: packages/core/src/sanitization/url_sanitizer.ts
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {isDevMode} from '../util/is_dev_mode';
109

1110
/**
1211
* A pattern that recognizes a commonly useful subset of URLs that are safe.
@@ -47,7 +46,7 @@ export function _sanitizeUrl(url: string): string {
4746
url = String(url);
4847
if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN)) return url;
4948

50-
if (isDevMode()) {
49+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
5150
console.warn(`WARNING: sanitizing unsafe URL value ${url} (see https://g.co/ng/security#xss)`);
5251
}
5352

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.