Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit1e3534f

Browse files
arturovtmhevery
authored andcommitted
perf(core): usengDevMode to tree-shake warnings (#39959)
This commit adds `ngDevMode` guard to show sanitization warnings onlyin 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.PRClose#39959
1 parent16b706b commit1e3534f

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

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

Lines 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‎

Lines 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
constsanitizer=newSanitizingHtmlSerializer();
270269
constsafeHtml=sanitizer.sanitizeChildren(
271270
getTemplateContent(inertBodyElement!)asElement||inertBodyElement);
272-
if(isDevMode()&&sanitizer.sanitizedSomething){
271+
if((typeofngDevMode==='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‎

Lines 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))returnurl;
4948

50-
if(isDevMode()){
49+
if(typeofngDevMode==='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)

[8]ページ先頭

©2009-2025 Movatter.jp