perf(core): use `ngDevMode` to tree-shake warnings (#39959) · angular/angular@1e3534f

File tree

3 files changed

lines changed

  • packages/core/src/sanitization

3 files changed

lines changed

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

}

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

}

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