fix(upgrade): remove code setting id attribute.

The id was leftover from previous iterations of ngUpgrade and is
no longer needed. Moreover, setting it can clash with CSS usage of id.

Fixes #18446
This commit is contained in:
Rado Kirov 2017-09-05 22:44:32 -07:00
parent edf423af3d
commit 1302e54947
2 changed files with 6 additions and 12 deletions

View File

@ -13,8 +13,6 @@ 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
* *
@ -57,9 +55,6 @@ 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,
@ -90,10 +85,9 @@ 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(
id, element, attrs, scope, ngModel, injector, $injector, $compile, $parse, 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 id: string, private element: angular.IAugmentedJQuery, private element: angular.IAugmentedJQuery, private attrs: angular.IAttributes,
private attrs: angular.IAttributes, private scope: angular.IScope, private scope: angular.IScope, private ngModel: angular.INgModelController,
private ngModel: angular.INgModelController, private parentInjector: Injector, private parentInjector: Injector, private $injector: angular.IInjectorService,
private $injector: angular.IInjectorService, private $compile: angular.ICompileService, private $compile: angular.ICompileService, private $parse: angular.IParseService,
private $parse: angular.IParseService, private componentFactory: ComponentFactory<any>) { 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();
} }