fix(ivy): register `ModuleWithProviders` when deduplicating imported modules (#27268)

PR Close #27268
This commit is contained in:
Olivier Combe 2018-11-21 13:40:27 +01:00 committed by Jason Aden
parent c2f30542e7
commit 32157115da
2 changed files with 19 additions and 23 deletions

View File

@ -227,9 +227,7 @@ export class R3Injector {
} }
// Check for multiple imports of the same module // Check for multiple imports of the same module
if (dedupStack.indexOf(defType) !== -1) { const isDuplicate = dedupStack.indexOf(defType) !== -1;
return;
}
// If defOrWrappedType was an InjectorDefTypeWithProviders, then .providers may hold some // If defOrWrappedType was an InjectorDefTypeWithProviders, then .providers may hold some
// extra providers. // extra providers.
@ -255,7 +253,7 @@ export class R3Injector {
// Add providers in the same way that @NgModule resolution did: // Add providers in the same way that @NgModule resolution did:
// First, include providers from any imports. // First, include providers from any imports.
if (def.imports != null) { if (def.imports != null && !isDuplicate) {
// Before processing defType's imports, add it to the set of parents. This way, if it ends // Before processing defType's imports, add it to the set of parents. This way, if it ends
// up deeply importing itself, this can be detected. // up deeply importing itself, this can be detected.
ngDevMode && parents.push(defType); ngDevMode && parents.push(defType);
@ -272,7 +270,7 @@ export class R3Injector {
} }
// Next, include providers listed on the definition itself. // Next, include providers listed on the definition itself.
if (def.providers != null) { if (def.providers != null && !isDuplicate) {
deepForEach(def.providers, provider => this.processProvider(provider)); deepForEach(def.providers, provider => this.processProvider(provider));
} }

View File

@ -624,15 +624,14 @@ class HiddenModule {
}); });
})); }));
fixmeIvy('to investigate') && it('should handle element property "name"', async(() => {
it('should handle element property "name"', async(() => { renderModule(NameModule, {document: doc}).then(output => {
renderModule(NameModule, {document: doc}).then(output => { expect(output).toBe(
expect(output).toBe( '<html><head></head><body><app ng-version="0.0.0-PLACEHOLDER">' +
'<html><head></head><body><app ng-version="0.0.0-PLACEHOLDER">' + '<input name=""></app></body></html>');
'<input name=""></app></body></html>'); called = true;
called = true; });
}); }));
}));
fixmeIvy('to investigate') && fixmeIvy('to investigate') &&
it('should work with sanitizer to handle "innerHTML"', async(() => { it('should work with sanitizer to handle "innerHTML"', async(() => {
@ -648,15 +647,14 @@ class HiddenModule {
}); });
})); }));
fixmeIvy('to investigate') && it('should handle element property "hidden"', async(() => {
it('should handle element property "hidden"', async(() => { renderModule(HiddenModule, {document: doc}).then(output => {
renderModule(HiddenModule, {document: doc}).then(output => { expect(output).toBe(
expect(output).toBe( '<html><head></head><body><app ng-version="0.0.0-PLACEHOLDER">' +
'<html><head></head><body><app ng-version="0.0.0-PLACEHOLDER">' + '<input hidden=""><input></app></body></html>');
'<input hidden=""><input></app></body></html>'); called = true;
called = true; });
}); }));
}));
it('should call render hook', async(() => { it('should call render hook', async(() => {
renderModule(RenderHookModule, {document: doc}).then(output => { renderModule(RenderHookModule, {document: doc}).then(output => {