-
Notifications
You must be signed in to change notification settings - Fork 27.1k
refactor(core): guards stringify calls with ngDevMode #66958
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,7 +47,10 @@ export function createInjectorWithoutInjectorInstances( | |||||||||||||||||||||
| scopes = new Set<InjectorScope>(), | ||||||||||||||||||||||
| ): R3Injector { | ||||||||||||||||||||||
| const providers = [additionalProviders || EMPTY_ARRAY, importProvidersFrom(defType)]; | ||||||||||||||||||||||
| name = name || (typeof defType === 'object' ? undefined : stringify(defType)); | ||||||||||||||||||||||
| let source: string | undefined = undefined; | ||||||||||||||||||||||
| if (ngDevMode) { | ||||||||||||||||||||||
| source = name || (typeof defType === 'object' ? undefined : stringify(defType)); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return new R3Injector(providers, parent || getNullInjector(), name || null, scopes); | ||||||||||||||||||||||
| return new R3Injector(providers, parent || getNullInjector(), source || null, scopes); | ||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This value, as I understand it, is only used in dev angular/packages/core/src/di/r3_injector.ts Lines 401 to 410 in 63d828a
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -455,12 +455,16 @@ export class R3Injector extends EnvironmentInjector implements PrimitivesInjecto | |||||||||
| } | ||||||||||
|
|
||||||||||
| override toString() { | ||||||||||
JeanMeche marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| const tokens: string[] = []; | ||||||||||
| const records = this.records; | ||||||||||
| for (const token of records.keys()) { | ||||||||||
| tokens.push(stringify(token)); | ||||||||||
| if (ngDevMode) { | ||||||||||
| const tokens: string[] = []; | ||||||||||
| const records = this.records; | ||||||||||
| for (const token of records.keys()) { | ||||||||||
| tokens.push(stringify(token)); | ||||||||||
| } | ||||||||||
| return `R3Injector[${tokens.join(', ')}]`; | ||||||||||
| } | ||||||||||
| return `R3Injector[${tokens.join(', ')}]`; | ||||||||||
|
|
||||||||||
| return 'R3Injector[...]'; | ||||||||||
| } | ||||||||||
JeanMeche marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
@@ -521,7 +525,7 @@ export class R3Injector extends EnvironmentInjector implements PrimitivesInjecto | |||||||||
| const prevConsumer = setActiveConsumer(null); | ||||||||||
| try { | ||||||||||
| if (record.value === CIRCULAR) { | ||||||||||
| throw cyclicDependencyError(stringify(token)); | ||||||||||
| throw cyclicDependencyError(ngDevMode ? stringify(token) : ''); | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a similar case here; the value is only used for dev mode. angular/packages/core/src/render3/errors_di.ts Lines 24 to 27 in 63d828a
|
||||||||||
| } else if (record.value === NOT_YET) { | ||||||||||
| record.value = CIRCULAR; | ||||||||||
|
|
||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.