revert: fix(upgrade): remove code setting id attribute

This reverts commit 1302e54947.
This commit is contained in:
Matias Niemelä
2017-09-13 13:18:08 -07:00
parent 86f7b4170c
commit d1efc5ae90
2 changed files with 12 additions and 6 deletions

View File

@ -13,6 +13,8 @@ import {$COMPILE, $INJECTOR, $PARSE, INJECTOR_KEY, REQUIRE_INJECTOR, REQUIRE_NG_
import {DowngradeComponentAdapter} from './downgrade_component_adapter'; import {DowngradeComponentAdapter} from './downgrade_component_adapter';
import {controllerKey, getComponentName} from './util'; import {controllerKey, getComponentName} from './util';
let downgradeCount = 0;
/** /**
* @whatItDoes * @whatItDoes
* *
@ -55,6 +57,9 @@ export function downgradeComponent(info: {
/** @deprecated since v4. This parameter is no longer used */ /** @deprecated since v4. This parameter is no longer used */
selectors?: string[]; selectors?: string[];
}): any /* angular.IInjectable */ { }): any /* angular.IInjectable */ {
const idPrefix = `NG2_UPGRADE_${downgradeCount++}_`;
let idCount = 0;
const directiveFactory: const directiveFactory:
angular.IAnnotatedFunction = function( angular.IAnnotatedFunction = function(
$compile: angular.ICompileService, $compile: angular.ICompileService,
@ -85,9 +90,10 @@ export function downgradeComponent(info: {
throw new Error('Expecting ComponentFactory for: ' + getComponentName(info.component)); throw new Error('Expecting ComponentFactory for: ' + getComponentName(info.component));
} }
const id = idPrefix + (idCount++);
const injectorPromise = new ParentInjectorPromise(element); const injectorPromise = new ParentInjectorPromise(element);
const facade = new DowngradeComponentAdapter( const facade = new DowngradeComponentAdapter(
element, attrs, scope, ngModel, injector, $injector, $compile, $parse, id, element, attrs, scope, ngModel, injector, $injector, $compile, $parse,
componentFactory); componentFactory);
const projectableNodes = facade.compileContents(); const projectableNodes = facade.compileContents();

View File

@ -26,11 +26,11 @@ export class DowngradeComponentAdapter {
private changeDetector: ChangeDetectorRef|null = null; private changeDetector: ChangeDetectorRef|null = null;
constructor( constructor(
private element: angular.IAugmentedJQuery, private attrs: angular.IAttributes, private id: string, private element: angular.IAugmentedJQuery,
private scope: angular.IScope, private ngModel: angular.INgModelController, private attrs: angular.IAttributes, private scope: angular.IScope,
private parentInjector: Injector, private $injector: angular.IInjectorService, private ngModel: angular.INgModelController, private parentInjector: Injector,
private $compile: angular.ICompileService, private $parse: angular.IParseService, private $injector: angular.IInjectorService, private $compile: angular.ICompileService,
private componentFactory: ComponentFactory<any>) { private $parse: angular.IParseService, private componentFactory: ComponentFactory<any>) {
(this.element[0] as any).id = id; (this.element[0] as any).id = id;
this.componentScope = scope.$new(); this.componentScope = scope.$new();
} }