@angular/upgrade 15.1.2 → 15.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/src/common/src/angular1.mjs +1 -1
- package/esm2020/src/common/src/component_info.mjs +1 -4
- package/esm2020/src/common/src/downgrade_component.mjs +4 -7
- package/esm2020/src/common/src/downgrade_component_adapter.mjs +62 -60
- package/esm2020/src/common/src/upgrade_helper.mjs +5 -6
- package/esm2020/src/common/src/util.mjs +2 -8
- package/esm2020/src/common/src/version.mjs +1 -1
- package/esm2020/src/dynamic/src/upgrade_adapter.mjs +32 -66
- package/esm2020/src/dynamic/src/upgrade_ng1_adapter.mjs +13 -20
- package/esm2020/static/src/upgrade_component.mjs +36 -29
- package/esm2020/static/src/upgrade_module.mjs +4 -4
- package/esm2020/static/testing/src/create_angular_testing_module.mjs +4 -4
- package/fesm2015/static/testing.mjs +5 -5
- package/fesm2015/static/testing.mjs.map +1 -1
- package/fesm2015/static.mjs +114 -114
- package/fesm2015/static.mjs.map +1 -1
- package/fesm2015/upgrade.mjs +119 -168
- package/fesm2015/upgrade.mjs.map +1 -1
- package/fesm2020/static/testing.mjs +5 -5
- package/fesm2020/static/testing.mjs.map +1 -1
- package/fesm2020/static.mjs +110 -114
- package/fesm2020/static.mjs.map +1 -1
- package/fesm2020/upgrade.mjs +116 -168
- package/fesm2020/upgrade.mjs.map +1 -1
- package/index.d.ts +1 -4
- package/package.json +5 -5
- package/static/index.d.ts +4 -9
- package/static/testing/index.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.mjs","sources":["../../../../../../../packages/upgrade/src/common/src/angular1.ts","../../../../../../../packages/upgrade/src/common/src/constants.ts","../../../../../../../packages/upgrade/static/testing/src/create_angular_testing_module.ts","../../../../../../../packages/upgrade/static/testing/src/create_angularjs_testing_module.ts","../../../../../../../packages/upgrade/static/testing/testing.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport type Ng1Token = string;\n\nexport type Ng1Expression = string|Function;\n\nexport interface IAnnotatedFunction extends Function {\n // Older versions of `@types/angular` typings extend the global `Function` interface with\n // `$inject?: string[]`, which is not compatible with `$inject?: ReadonlyArray<string>` (used in\n // latest versions).\n $inject?: Function extends {$inject?: string[]}? Ng1Token[]: ReadonlyArray<Ng1Token>;\n}\n\nexport type IInjectable = (Ng1Token|Function)[]|IAnnotatedFunction;\n\nexport type SingleOrListOrMap<T> = T|T[]|{[key: string]: T};\n\nexport interface IModule {\n name: string;\n requires: (string|IInjectable)[];\n config(fn: IInjectable): IModule;\n directive(selector: string, factory: IInjectable): IModule;\n component(selector: string, component: IComponent): IModule;\n controller(name: string, type: IInjectable): IModule;\n factory(key: Ng1Token, factoryFn: IInjectable): IModule;\n value(key: Ng1Token, value: any): IModule;\n constant(token: Ng1Token, value: any): IModule;\n run(a: IInjectable): IModule;\n}\nexport interface ICompileService {\n (element: Element|NodeList|Node[]|string, transclude?: Function): ILinkFn;\n}\nexport interface ILinkFn {\n (scope: IScope, cloneAttachFn?: ICloneAttachFunction, options?: ILinkFnOptions): IAugmentedJQuery;\n $$slots?: {[slotName: string]: ILinkFn};\n}\nexport interface ILinkFnOptions {\n parentBoundTranscludeFn?: Function;\n transcludeControllers?: {[key: string]: any};\n futureParentElement?: Node;\n}\nexport interface IRootScopeService {\n $new(isolate?: boolean): IScope;\n $id: string;\n $parent: IScope;\n $root: IScope;\n $watch(exp: Ng1Expression, fn?: (a1?: any, a2?: any) => void): Function;\n $on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;\n $destroy(): any;\n $apply(exp?: Ng1Expression): any;\n $digest(): any;\n $evalAsync(exp: Ng1Expression, locals?: any): void;\n $on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;\n $$childTail: IScope;\n $$childHead: IScope;\n $$nextSibling: IScope;\n [key: string]: any;\n}\nexport interface IScope extends IRootScopeService {}\n\nexport interface IAngularBootstrapConfig {\n strictDi?: boolean;\n}\nexport interface IDirective {\n compile?: IDirectiveCompileFn;\n controller?: IController;\n controllerAs?: string;\n bindToController?: boolean|{[key: string]: string};\n link?: IDirectiveLinkFn|IDirectivePrePost;\n name?: string;\n priority?: number;\n replace?: boolean;\n require?: DirectiveRequireProperty;\n restrict?: string;\n scope?: boolean|{[key: string]: string};\n template?: string|Function;\n templateUrl?: string|Function;\n templateNamespace?: string;\n terminal?: boolean;\n transclude?: DirectiveTranscludeProperty;\n}\nexport type DirectiveRequireProperty = SingleOrListOrMap<string>;\nexport type DirectiveTranscludeProperty = boolean|'element'|{[key: string]: string};\nexport interface IDirectiveCompileFn {\n (templateElement: IAugmentedJQuery, templateAttributes: IAttributes,\n transclude: ITranscludeFunction): IDirectivePrePost;\n}\nexport interface IDirectivePrePost {\n pre?: IDirectiveLinkFn;\n post?: IDirectiveLinkFn;\n}\nexport interface IDirectiveLinkFn {\n (scope: IScope, instanceElement: IAugmentedJQuery, instanceAttributes: IAttributes,\n controller: any, transclude: ITranscludeFunction): void;\n}\nexport interface IComponent {\n bindings?: {[key: string]: string};\n controller?: string|IInjectable;\n controllerAs?: string;\n require?: DirectiveRequireProperty;\n template?: string|Function;\n templateUrl?: string|Function;\n transclude?: DirectiveTranscludeProperty;\n}\nexport interface IAttributes {\n $observe(attr: string, fn: (v: string) => void): void;\n [key: string]: any;\n}\nexport interface ITranscludeFunction {\n // If the scope is provided, then the cloneAttachFn must be as well.\n (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;\n // If one argument is provided, then it's assumed to be the cloneAttachFn.\n (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;\n}\nexport interface ICloneAttachFunction {\n (clonedElement: IAugmentedJQuery, scope: IScope): any;\n}\nexport type IAugmentedJQuery = Node[]&{\n on?: (name: string, fn: () => void) => void;\n data?: (name: string, value?: any) => any;\n text?: () => string;\n inheritedData?: (name: string, value?: any) => any;\n children?: () => IAugmentedJQuery;\n contents?: () => IAugmentedJQuery;\n parent?: () => IAugmentedJQuery;\n empty?: () => void;\n append?: (content: IAugmentedJQuery|string) => IAugmentedJQuery;\n controller?: (name: string) => any;\n isolateScope?: () => IScope;\n injector?: () => IInjectorService;\n triggerHandler?: (eventTypeOrObject: string|Event, extraParameters?: any[]) => IAugmentedJQuery;\n remove?: () => void;\n removeData?: () => void;\n};\nexport interface IProvider {\n $get: IInjectable;\n}\nexport interface IProvideService {\n provider(token: Ng1Token, provider: IProvider): IProvider;\n factory(token: Ng1Token, factory: IInjectable): IProvider;\n service(token: Ng1Token, type: IInjectable): IProvider;\n value(token: Ng1Token, value: any): IProvider;\n constant(token: Ng1Token, value: any): void;\n decorator(token: Ng1Token, factory: IInjectable): void;\n}\nexport interface IParseService {\n (expression: string): ICompiledExpression;\n}\nexport interface ICompiledExpression {\n (context: any, locals: any): any;\n assign?: (context: any, value: any) => any;\n}\nexport interface IHttpBackendService {\n (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number,\n withCredentials?: boolean): void;\n}\nexport interface ICacheObject {\n put<T>(key: string, value?: T): T;\n get(key: string): any;\n}\nexport interface ITemplateCacheService extends ICacheObject {}\nexport interface ITemplateRequestService {\n (template: string|any /* TrustedResourceUrl */, ignoreRequestError?: boolean): Promise<string>;\n totalPendingRequests: number;\n}\nexport type IController = string|IInjectable;\nexport interface IControllerService {\n (controllerConstructor: IController, locals?: any, later?: any, ident?: any): any;\n (controllerName: string, locals?: any): any;\n}\n\nexport interface IInjectorService {\n get(key: string): any;\n has(key: string): boolean;\n}\n\nexport interface IIntervalService {\n (func: Function, delay: number, count?: number, invokeApply?: boolean,\n ...args: any[]): Promise<any>;\n cancel(promise: Promise<any>): boolean;\n}\n\nexport interface ITestabilityService {\n findBindings(element: Element, expression: string, opt_exactMatch?: boolean): Element[];\n findModels(element: Element, expression: string, opt_exactMatch?: boolean): Element[];\n getLocation(): string;\n setLocation(url: string): void;\n whenStable(callback: Function): void;\n}\n\nexport interface INgModelController {\n $render(): void;\n $isEmpty(value: any): boolean;\n $setValidity(validationErrorKey: string, isValid: boolean): void;\n $setPristine(): void;\n $setDirty(): void;\n $setUntouched(): void;\n $setTouched(): void;\n $rollbackViewValue(): void;\n $validate(): void;\n $commitViewValue(): void;\n $setViewValue(value: any, trigger: string): void;\n\n $viewValue: any;\n $modelValue: any;\n $parsers: Function[];\n $formatters: Function[];\n $validators: {[key: string]: Function};\n $asyncValidators: {[key: string]: Function};\n $viewChangeListeners: Function[];\n $error: Object;\n $pending: Object;\n $untouched: boolean;\n $touched: boolean;\n $pristine: boolean;\n $dirty: boolean;\n $valid: boolean;\n $invalid: boolean;\n $name: string;\n}\n\nfunction noNg(): never {\n throw new Error('AngularJS v1.x is not loaded!');\n}\n\nconst noNgElement: typeof angular.element = (() => noNg()) as any;\nnoNgElement.cleanData = noNg;\n\nlet angular: {\n bootstrap: (e: Element, modules: (string|IInjectable)[], config?: IAngularBootstrapConfig) =>\n IInjectorService,\n module: (prefix: string, dependencies?: string[]) => IModule,\n element: {\n (e: string|Element|Document|IAugmentedJQuery): IAugmentedJQuery;\n cleanData: (nodes: Node[]|NodeList) => void;\n },\n injector: (modules: Array<string|IInjectable>, strictDi?: boolean) => IInjectorService,\n version: {major: number},\n resumeBootstrap: () => void,\n getTestability: (e: Element) => ITestabilityService\n} = {\n bootstrap: noNg,\n module: noNg,\n element: noNgElement,\n injector: noNg,\n version: undefined as any,\n resumeBootstrap: noNg,\n getTestability: noNg\n};\n\ntry {\n if (window.hasOwnProperty('angular')) {\n angular = (<any>window).angular;\n }\n} catch {\n // ignore in CJS mode.\n}\n\n/**\n * @deprecated Use `setAngularJSGlobal` instead.\n *\n * @publicApi\n */\nexport function setAngularLib(ng: any): void {\n setAngularJSGlobal(ng);\n}\n\n/**\n * @deprecated Use `getAngularJSGlobal` instead.\n *\n * @publicApi\n */\nexport function getAngularLib(): any {\n return getAngularJSGlobal();\n}\n\n/**\n * Resets the AngularJS global.\n *\n * Used when AngularJS is loaded lazily, and not available on `window`.\n *\n * @publicApi\n */\nexport function setAngularJSGlobal(ng: any): void {\n angular = ng;\n}\n\n/**\n * Returns the current AngularJS global.\n *\n * @publicApi\n */\nexport function getAngularJSGlobal(): any {\n return angular;\n}\n\nexport const bootstrap: typeof angular.bootstrap = (e, modules, config?) =>\n angular.bootstrap(e, modules, config);\n\n// Do not declare as `module` to avoid webpack bug\n// (see https://github.com/angular/angular/issues/30050).\nexport const module_: typeof angular.module = (prefix, dependencies?) =>\n angular.module(prefix, dependencies);\n\nexport const element: typeof angular.element = (e => angular.element(e)) as typeof angular.element;\nelement.cleanData = nodes => angular.element.cleanData(nodes);\n\nexport const injector: typeof angular.injector =\n (modules: Array<string|IInjectable>, strictDi?: boolean) => angular.injector(modules, strictDi);\n\nexport const resumeBootstrap: typeof angular.resumeBootstrap = () => angular.resumeBootstrap();\n\nexport const getTestability: typeof angular.getTestability = e => angular.getTestability(e);\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport const $COMPILE = '$compile';\nexport const $CONTROLLER = '$controller';\nexport const $DELEGATE = '$delegate';\nexport const $EXCEPTION_HANDLER = '$exceptionHandler';\nexport const $HTTP_BACKEND = '$httpBackend';\nexport const $INJECTOR = '$injector';\nexport const $INTERVAL = '$interval';\nexport const $PARSE = '$parse';\nexport const $PROVIDE = '$provide';\nexport const $ROOT_ELEMENT = '$rootElement';\nexport const $ROOT_SCOPE = '$rootScope';\nexport const $SCOPE = '$scope';\nexport const $TEMPLATE_CACHE = '$templateCache';\nexport const $TEMPLATE_REQUEST = '$templateRequest';\n\nexport const $$TESTABILITY = '$$testability';\n\nexport const COMPILER_KEY = '$$angularCompiler';\nexport const DOWNGRADED_MODULE_COUNT_KEY = '$$angularDowngradedModuleCount';\nexport const GROUP_PROJECTABLE_NODES_KEY = '$$angularGroupProjectableNodes';\nexport const INJECTOR_KEY = '$$angularInjector';\nexport const LAZY_MODULE_REF = '$$angularLazyModuleRef';\nexport const NG_ZONE_KEY = '$$angularNgZone';\nexport const UPGRADE_APP_TYPE_KEY = '$$angularUpgradeAppType';\n\nexport const REQUIRE_INJECTOR = '?^^' + INJECTOR_KEY;\nexport const REQUIRE_NG_MODEL = '?ngModel';\n\nexport const UPGRADE_MODULE_NAME = '$$UpgradeModule';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Injector, NgModule, Type} from '@angular/core';\n\nimport * as angular from '../../../src/common/src/angular1';\nimport {$INJECTOR, INJECTOR_KEY, UPGRADE_APP_TYPE_KEY} from '../../../src/common/src/constants';\nimport {UpgradeAppType} from '../../../src/common/src/util';\n\nlet $injector: angular.IInjectorService|null = null;\nlet injector: Injector;\n\nexport function $injectorFactory() {\n return $injector;\n}\n\n@NgModule({providers: [{provide: $INJECTOR, useFactory: $injectorFactory}]})\nexport class AngularTestingModule {\n constructor(i: Injector) {\n injector = i;\n }\n}\n\n/**\n * A helper function to use when unit testing Angular services that depend upon upgraded AngularJS\n * services.\n *\n * This function returns an `NgModule` decorated class that is configured to wire up the Angular\n * and AngularJS injectors without the need to actually bootstrap a hybrid application.\n * This makes it simpler and faster to unit test services.\n *\n * Use the returned class as an \"import\" when configuring the `TestBed`.\n *\n * In the following code snippet, we are configuring the TestBed with two imports.\n * The `Ng2AppModule` is the Angular part of our hybrid application and the `ng1AppModule` is the\n * AngularJS part.\n *\n * <code-example path=\"upgrade/static/ts/full/module.spec.ts\" region=\"angular-setup\"></code-example>\n *\n * Once this is done we can get hold of services via the Angular `Injector` as normal.\n * Services that are (or have dependencies on) an upgraded AngularJS service, will be instantiated\n * as needed by the AngularJS `$injector`.\n *\n * In the following code snippet, `HeroesService` is an Angular service that depends upon an\n * AngularJS service, `titleCase`.\n *\n * <code-example path=\"upgrade/static/ts/full/module.spec.ts\" region=\"angular-spec\"></code-example>\n *\n * <div class=\"alert is-important\">\n *\n * This helper is for testing services not Components.\n * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or\n * `downgradeModule` for more information.\n *\n * </div>\n *\n * <div class=\"alert is-important\">\n *\n * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the\n * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger\n * AngularJS handlers of async events from Angular.\n *\n * </div>\n *\n * <div class=\"alert is-important\">\n *\n * The helper sets up global variables to hold the shared Angular and AngularJS injectors.\n *\n * * Only call this helper once per spec.\n * * Do not use `createAngularTestingModule` in the same spec as `createAngularJSTestingModule`.\n *\n * </div>\n *\n * Here is the example application and its unit tests that use `createAngularTestingModule`\n * and `createAngularJSTestingModule`.\n *\n * <code-tabs>\n * <code-pane header=\"module.spec.ts\" path=\"upgrade/static/ts/full/module.spec.ts\"></code-pane>\n * <code-pane header=\"module.ts\" path=\"upgrade/static/ts/full/module.ts\"></code-pane>\n * </code-tabs>\n *\n *\n * @param angularJSModules a collection of the names of AngularJS modules to include in the\n * configuration.\n * @param [strictDi] whether the AngularJS injector should have `strictDI` enabled.\n *\n * @publicApi\n */\nexport function createAngularTestingModule(\n angularJSModules: string[], strictDi?: boolean): Type<any> {\n angular.module_('$$angularJSTestingModule', angularJSModules)\n .constant(UPGRADE_APP_TYPE_KEY, UpgradeAppType.Static)\n .factory(INJECTOR_KEY, () => injector);\n $injector = angular.injector(['ng', '$$angularJSTestingModule'], strictDi);\n return AngularTestingModule;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Injector} from '@angular/core';\nimport {TestBed} from '@angular/core/testing';\n\nimport * as ng from '../../../src/common/src/angular1';\nimport {$INJECTOR, INJECTOR_KEY, UPGRADE_APP_TYPE_KEY} from '../../../src/common/src/constants';\nimport {UpgradeAppType} from '../../../src/common/src/util';\n\n\n/**\n * A helper function to use when unit testing AngularJS services that depend upon downgraded Angular\n * services.\n *\n * This function returns an AngularJS module that is configured to wire up the AngularJS and Angular\n * injectors without the need to actually bootstrap a hybrid application.\n * This makes it simpler and faster to unit test services.\n *\n * Use the returned AngularJS module in a call to\n * [`angular.mocks.module`](https://docs.angularjs.org/api/ngMock/function/angular.mock.module) to\n * include this module in the unit test injector.\n *\n * In the following code snippet, we are configuring the `$injector` with two modules:\n * The AngularJS `ng1AppModule`, which is the AngularJS part of our hybrid application and the\n * `Ng2AppModule`, which is the Angular part.\n *\n * <code-example path=\"upgrade/static/ts/full/module.spec.ts\"\n * region=\"angularjs-setup\"></code-example>\n *\n * Once this is done we can get hold of services via the AngularJS `$injector` as normal.\n * Services that are (or have dependencies on) a downgraded Angular service, will be instantiated as\n * needed by the Angular root `Injector`.\n *\n * In the following code snippet, `heroesService` is a downgraded Angular service that we are\n * accessing from AngularJS.\n *\n * <code-example path=\"upgrade/static/ts/full/module.spec.ts\"\n * region=\"angularjs-spec\"></code-example>\n *\n * <div class=\"alert is-important\">\n *\n * This helper is for testing services not components.\n * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or\n * `downgradeModule` for more information.\n *\n * </div>\n *\n * <div class=\"alert is-important\">\n *\n * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the\n * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger\n * AngularJS handlers of async events from Angular.\n *\n * </div>\n *\n * <div class=\"alert is-important\">\n *\n * The helper sets up global variables to hold the shared Angular and AngularJS injectors.\n *\n * * Only call this helper once per spec.\n * * Do not use `createAngularJSTestingModule` in the same spec as `createAngularTestingModule`.\n *\n * </div>\n *\n * Here is the example application and its unit tests that use `createAngularTestingModule`\n * and `createAngularJSTestingModule`.\n *\n * <code-tabs>\n * <code-pane header=\"module.spec.ts\" path=\"upgrade/static/ts/full/module.spec.ts\"></code-pane>\n * <code-pane header=\"module.ts\" path=\"upgrade/static/ts/full/module.ts\"></code-pane>\n * </code-tabs>\n *\n *\n * @param angularModules a collection of Angular modules to include in the configuration.\n *\n * @publicApi\n */\nexport function createAngularJSTestingModule(angularModules: any[]): string {\n return ng.module_('$$angularJSTestingModule', [])\n .constant(UPGRADE_APP_TYPE_KEY, UpgradeAppType.Static)\n .factory(\n INJECTOR_KEY,\n [\n $INJECTOR,\n ($injector: ng.IInjectorService) => {\n TestBed.configureTestingModule({\n imports: angularModules,\n providers: [{provide: $INJECTOR, useValue: $injector}]\n });\n return TestBed.inject(Injector);\n }\n ])\n .name;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["injector","angular.module_","angular.injector","ng.module_"],"mappings":";;;;;;;;;;AAmOA,SAAS,IAAI,GAAA;AACX,IAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,WAAW,IAA4B,MAAM,IAAI,EAAE,CAAQ,CAAC;AAClE,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC;AAE7B,IAAI,OAAO,GAYP;AACF,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,OAAO,EAAE,WAAW;AACpB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,OAAO,EAAE,SAAgB;AACzB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF,IAAI;AACF,IAAA,IAAI,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;AACpC,QAAA,OAAO,GAAS,MAAO,CAAC,OAAO,CAAC;AACjC,KAAA;AACF,CAAA;AAAC,OAAM,EAAA,EAAA;;AAEP,CAAA;AAED;;;;AAIG;AACG,SAAU,aAAa,CAAC,EAAO,EAAA;IACnC,kBAAkB,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC;AAED;;;;AAIG;SACa,aAAa,GAAA;IAC3B,OAAO,kBAAkB,EAAE,CAAC;AAC9B,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../../packages/upgrade/src/common/src/constants.ts","../../../../../../../packages/upgrade/static/testing/src/create_angular_testing_module.ts","../../../../../../../packages/upgrade/static/testing/src/create_angularjs_testing_module.ts","../../../../../../../packages/upgrade/static/testing/testing.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport type Ng1Token = string;\n\nexport type Ng1Expression = string|Function;\n\nexport interface IAnnotatedFunction extends Function {\n // Older versions of `@types/angular` typings extend the global `Function` interface with\n // `$inject?: string[]`, which is not compatible with `$inject?: ReadonlyArray<string>` (used in\n // latest versions).\n $inject?: Function extends {$inject?: string[]}? Ng1Token[]: ReadonlyArray<Ng1Token>;\n}\n\nexport type IInjectable = (Ng1Token|Function)[]|IAnnotatedFunction;\n\nexport type SingleOrListOrMap<T> = T|T[]|{[key: string]: T};\n\nexport interface IModule {\n name: string;\n requires: (string|IInjectable)[];\n config(fn: IInjectable): IModule;\n directive(selector: string, factory: IInjectable): IModule;\n component(selector: string, component: IComponent): IModule;\n controller(name: string, type: IInjectable): IModule;\n factory(key: Ng1Token, factoryFn: IInjectable): IModule;\n value(key: Ng1Token, value: any): IModule;\n constant(token: Ng1Token, value: any): IModule;\n run(a: IInjectable): IModule;\n}\nexport interface ICompileService {\n (element: Element|NodeList|Node[]|string, transclude?: Function): ILinkFn;\n}\nexport interface ILinkFn {\n (scope: IScope, cloneAttachFn?: ICloneAttachFunction, options?: ILinkFnOptions): IAugmentedJQuery;\n $$slots?: {[slotName: string]: ILinkFn};\n}\nexport interface ILinkFnOptions {\n parentBoundTranscludeFn?: Function;\n transcludeControllers?: {[key: string]: any};\n futureParentElement?: Node;\n}\nexport interface IRootScopeService {\n $new(isolate?: boolean): IScope;\n $id: string;\n $parent: IScope;\n $root: IScope;\n $watch(exp: Ng1Expression, fn?: (a1?: any, a2?: any) => void): Function;\n $on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;\n $destroy(): any;\n $apply(exp?: Ng1Expression): any;\n $digest(): any;\n $evalAsync(exp: Ng1Expression, locals?: any): void;\n $on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;\n $$childTail: IScope;\n $$childHead: IScope;\n $$nextSibling: IScope;\n [key: string]: any;\n}\nexport interface IScope extends IRootScopeService {}\n\nexport interface IAngularBootstrapConfig {\n strictDi?: boolean;\n}\nexport interface IDirective {\n compile?: IDirectiveCompileFn;\n controller?: IController;\n controllerAs?: string;\n bindToController?: boolean|{[key: string]: string};\n link?: IDirectiveLinkFn|IDirectivePrePost;\n name?: string;\n priority?: number;\n replace?: boolean;\n require?: DirectiveRequireProperty;\n restrict?: string;\n scope?: boolean|{[key: string]: string};\n template?: string|Function;\n templateUrl?: string|Function;\n templateNamespace?: string;\n terminal?: boolean;\n transclude?: DirectiveTranscludeProperty;\n}\nexport type DirectiveRequireProperty = SingleOrListOrMap<string>;\nexport type DirectiveTranscludeProperty = boolean|'element'|{[key: string]: string};\nexport interface IDirectiveCompileFn {\n (templateElement: IAugmentedJQuery, templateAttributes: IAttributes,\n transclude: ITranscludeFunction): IDirectivePrePost;\n}\nexport interface IDirectivePrePost {\n pre?: IDirectiveLinkFn;\n post?: IDirectiveLinkFn;\n}\nexport interface IDirectiveLinkFn {\n (scope: IScope, instanceElement: IAugmentedJQuery, instanceAttributes: IAttributes,\n controller: any, transclude: ITranscludeFunction): void;\n}\nexport interface IComponent {\n bindings?: {[key: string]: string};\n controller?: string|IInjectable;\n controllerAs?: string;\n require?: DirectiveRequireProperty;\n template?: string|Function;\n templateUrl?: string|Function;\n transclude?: DirectiveTranscludeProperty;\n}\nexport interface IAttributes {\n $observe(attr: string, fn: (v: string) => void): void;\n [key: string]: any;\n}\nexport interface ITranscludeFunction {\n // If the scope is provided, then the cloneAttachFn must be as well.\n (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;\n // If one argument is provided, then it's assumed to be the cloneAttachFn.\n (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;\n}\nexport interface ICloneAttachFunction {\n (clonedElement: IAugmentedJQuery, scope: IScope): any;\n}\nexport type IAugmentedJQuery = Node[]&{\n on?: (name: string, fn: () => void) => void;\n data?: (name: string, value?: any) => any;\n text?: () => string;\n inheritedData?: (name: string, value?: any) => any;\n children?: () => IAugmentedJQuery;\n contents?: () => IAugmentedJQuery;\n parent?: () => IAugmentedJQuery;\n empty?: () => void;\n append?: (content: IAugmentedJQuery|string) => IAugmentedJQuery;\n controller?: (name: string) => any;\n isolateScope?: () => IScope;\n injector?: () => IInjectorService;\n triggerHandler?: (eventTypeOrObject: string|Event, extraParameters?: any[]) => IAugmentedJQuery;\n remove?: () => void;\n removeData?: () => void;\n};\nexport interface IProvider {\n $get: IInjectable;\n}\nexport interface IProvideService {\n provider(token: Ng1Token, provider: IProvider): IProvider;\n factory(token: Ng1Token, factory: IInjectable): IProvider;\n service(token: Ng1Token, type: IInjectable): IProvider;\n value(token: Ng1Token, value: any): IProvider;\n constant(token: Ng1Token, value: any): void;\n decorator(token: Ng1Token, factory: IInjectable): void;\n}\nexport interface IParseService {\n (expression: string): ICompiledExpression;\n}\nexport interface ICompiledExpression {\n (context: any, locals: any): any;\n assign?: (context: any, value: any) => any;\n}\nexport interface IHttpBackendService {\n (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number,\n withCredentials?: boolean): void;\n}\nexport interface ICacheObject {\n put<T>(key: string, value?: T): T;\n get(key: string): any;\n}\nexport interface ITemplateCacheService extends ICacheObject {}\nexport type IController = string|IInjectable;\nexport interface IControllerService {\n (controllerConstructor: IController, locals?: any, later?: any, ident?: any): any;\n (controllerName: string, locals?: any): any;\n}\n\nexport interface IInjectorService {\n get(key: string): any;\n has(key: string): boolean;\n}\n\nexport interface IIntervalService {\n (func: Function, delay: number, count?: number, invokeApply?: boolean,\n ...args: any[]): Promise<any>;\n cancel(promise: Promise<any>): boolean;\n}\n\nexport interface ITestabilityService {\n findBindings(element: Element, expression: string, opt_exactMatch?: boolean): Element[];\n findModels(element: Element, expression: string, opt_exactMatch?: boolean): Element[];\n getLocation(): string;\n setLocation(url: string): void;\n whenStable(callback: Function): void;\n}\n\nexport interface INgModelController {\n $render(): void;\n $isEmpty(value: any): boolean;\n $setValidity(validationErrorKey: string, isValid: boolean): void;\n $setPristine(): void;\n $setDirty(): void;\n $setUntouched(): void;\n $setTouched(): void;\n $rollbackViewValue(): void;\n $validate(): void;\n $commitViewValue(): void;\n $setViewValue(value: any, trigger: string): void;\n\n $viewValue: any;\n $modelValue: any;\n $parsers: Function[];\n $formatters: Function[];\n $validators: {[key: string]: Function};\n $asyncValidators: {[key: string]: Function};\n $viewChangeListeners: Function[];\n $error: Object;\n $pending: Object;\n $untouched: boolean;\n $touched: boolean;\n $pristine: boolean;\n $dirty: boolean;\n $valid: boolean;\n $invalid: boolean;\n $name: string;\n}\n\nfunction noNg(): never {\n throw new Error('AngularJS v1.x is not loaded!');\n}\n\nconst noNgElement: typeof angular.element = (() => noNg()) as any;\nnoNgElement.cleanData = noNg;\n\nlet angular: {\n bootstrap: (e: Element, modules: (string|IInjectable)[], config?: IAngularBootstrapConfig) =>\n IInjectorService,\n module: (prefix: string, dependencies?: string[]) => IModule,\n element: {\n (e: string|Element|Document|IAugmentedJQuery): IAugmentedJQuery;\n cleanData: (nodes: Node[]|NodeList) => void;\n },\n injector: (modules: Array<string|IInjectable>, strictDi?: boolean) => IInjectorService,\n version: {major: number},\n resumeBootstrap: () => void,\n getTestability: (e: Element) => ITestabilityService\n} = {\n bootstrap: noNg,\n module: noNg,\n element: noNgElement,\n injector: noNg,\n version: undefined as any,\n resumeBootstrap: noNg,\n getTestability: noNg\n};\n\ntry {\n if (window.hasOwnProperty('angular')) {\n angular = (<any>window).angular;\n }\n} catch {\n // ignore in CJS mode.\n}\n\n/**\n * @deprecated Use `setAngularJSGlobal` instead.\n *\n * @publicApi\n */\nexport function setAngularLib(ng: any): void {\n setAngularJSGlobal(ng);\n}\n\n/**\n * @deprecated Use `getAngularJSGlobal` instead.\n *\n * @publicApi\n */\nexport function getAngularLib(): any {\n return getAngularJSGlobal();\n}\n\n/**\n * Resets the AngularJS global.\n *\n * Used when AngularJS is loaded lazily, and not available on `window`.\n *\n * @publicApi\n */\nexport function setAngularJSGlobal(ng: any): void {\n angular = ng;\n}\n\n/**\n * Returns the current AngularJS global.\n *\n * @publicApi\n */\nexport function getAngularJSGlobal(): any {\n return angular;\n}\n\nexport const bootstrap: typeof angular.bootstrap = (e, modules, config?) =>\n angular.bootstrap(e, modules, config);\n\n// Do not declare as `module` to avoid webpack bug\n// (see https://github.com/angular/angular/issues/30050).\nexport const module_: typeof angular.module = (prefix, dependencies?) =>\n angular.module(prefix, dependencies);\n\nexport const element: typeof angular.element = (e => angular.element(e)) as typeof angular.element;\nelement.cleanData = nodes => angular.element.cleanData(nodes);\n\nexport const injector: typeof angular.injector =\n (modules: Array<string|IInjectable>, strictDi?: boolean) => angular.injector(modules, strictDi);\n\nexport const resumeBootstrap: typeof angular.resumeBootstrap = () => angular.resumeBootstrap();\n\nexport const getTestability: typeof angular.getTestability = e => angular.getTestability(e);\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport const $COMPILE = '$compile';\nexport const $CONTROLLER = '$controller';\nexport const $DELEGATE = '$delegate';\nexport const $EXCEPTION_HANDLER = '$exceptionHandler';\nexport const $HTTP_BACKEND = '$httpBackend';\nexport const $INJECTOR = '$injector';\nexport const $INTERVAL = '$interval';\nexport const $PARSE = '$parse';\nexport const $PROVIDE = '$provide';\nexport const $ROOT_ELEMENT = '$rootElement';\nexport const $ROOT_SCOPE = '$rootScope';\nexport const $SCOPE = '$scope';\nexport const $TEMPLATE_CACHE = '$templateCache';\nexport const $TEMPLATE_REQUEST = '$templateRequest';\n\nexport const $$TESTABILITY = '$$testability';\n\nexport const COMPILER_KEY = '$$angularCompiler';\nexport const DOWNGRADED_MODULE_COUNT_KEY = '$$angularDowngradedModuleCount';\nexport const GROUP_PROJECTABLE_NODES_KEY = '$$angularGroupProjectableNodes';\nexport const INJECTOR_KEY = '$$angularInjector';\nexport const LAZY_MODULE_REF = '$$angularLazyModuleRef';\nexport const NG_ZONE_KEY = '$$angularNgZone';\nexport const UPGRADE_APP_TYPE_KEY = '$$angularUpgradeAppType';\n\nexport const REQUIRE_INJECTOR = '?^^' + INJECTOR_KEY;\nexport const REQUIRE_NG_MODEL = '?ngModel';\n\nexport const UPGRADE_MODULE_NAME = '$$UpgradeModule';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Injector, NgModule, Type} from '@angular/core';\n\nimport * as angular from '../../../src/common/src/angular1';\nimport {$INJECTOR, INJECTOR_KEY, UPGRADE_APP_TYPE_KEY} from '../../../src/common/src/constants';\nimport {UpgradeAppType} from '../../../src/common/src/util';\n\nlet $injector: angular.IInjectorService|null = null;\nlet injector: Injector;\n\nexport function $injectorFactory() {\n return $injector;\n}\n\n@NgModule({providers: [{provide: $INJECTOR, useFactory: $injectorFactory}]})\nexport class AngularTestingModule {\n constructor(i: Injector) {\n injector = i;\n }\n}\n\n/**\n * A helper function to use when unit testing Angular services that depend upon upgraded AngularJS\n * services.\n *\n * This function returns an `NgModule` decorated class that is configured to wire up the Angular\n * and AngularJS injectors without the need to actually bootstrap a hybrid application.\n * This makes it simpler and faster to unit test services.\n *\n * Use the returned class as an \"import\" when configuring the `TestBed`.\n *\n * In the following code snippet, we are configuring the TestBed with two imports.\n * The `Ng2AppModule` is the Angular part of our hybrid application and the `ng1AppModule` is the\n * AngularJS part.\n *\n * <code-example path=\"upgrade/static/ts/full/module.spec.ts\" region=\"angular-setup\"></code-example>\n *\n * Once this is done we can get hold of services via the Angular `Injector` as normal.\n * Services that are (or have dependencies on) an upgraded AngularJS service, will be instantiated\n * as needed by the AngularJS `$injector`.\n *\n * In the following code snippet, `HeroesService` is an Angular service that depends upon an\n * AngularJS service, `titleCase`.\n *\n * <code-example path=\"upgrade/static/ts/full/module.spec.ts\" region=\"angular-spec\"></code-example>\n *\n * <div class=\"alert is-important\">\n *\n * This helper is for testing services not Components.\n * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or\n * `downgradeModule` for more information.\n *\n * </div>\n *\n * <div class=\"alert is-important\">\n *\n * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the\n * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger\n * AngularJS handlers of async events from Angular.\n *\n * </div>\n *\n * <div class=\"alert is-important\">\n *\n * The helper sets up global variables to hold the shared Angular and AngularJS injectors.\n *\n * * Only call this helper once per spec.\n * * Do not use `createAngularTestingModule` in the same spec as `createAngularJSTestingModule`.\n *\n * </div>\n *\n * Here is the example application and its unit tests that use `createAngularTestingModule`\n * and `createAngularJSTestingModule`.\n *\n * <code-tabs>\n * <code-pane header=\"module.spec.ts\" path=\"upgrade/static/ts/full/module.spec.ts\"></code-pane>\n * <code-pane header=\"module.ts\" path=\"upgrade/static/ts/full/module.ts\"></code-pane>\n * </code-tabs>\n *\n *\n * @param angularJSModules a collection of the names of AngularJS modules to include in the\n * configuration.\n * @param [strictDi] whether the AngularJS injector should have `strictDI` enabled.\n *\n * @publicApi\n */\nexport function createAngularTestingModule(\n angularJSModules: string[], strictDi?: boolean): Type<any> {\n angular.module_('$$angularJSTestingModule', angularJSModules)\n .constant(UPGRADE_APP_TYPE_KEY, UpgradeAppType.Static)\n .factory(INJECTOR_KEY, () => injector);\n $injector = angular.injector(['ng', '$$angularJSTestingModule'], strictDi);\n return AngularTestingModule;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Injector} from '@angular/core';\nimport {TestBed} from '@angular/core/testing';\n\nimport * as ng from '../../../src/common/src/angular1';\nimport {$INJECTOR, INJECTOR_KEY, UPGRADE_APP_TYPE_KEY} from '../../../src/common/src/constants';\nimport {UpgradeAppType} from '../../../src/common/src/util';\n\n\n/**\n * A helper function to use when unit testing AngularJS services that depend upon downgraded Angular\n * services.\n *\n * This function returns an AngularJS module that is configured to wire up the AngularJS and Angular\n * injectors without the need to actually bootstrap a hybrid application.\n * This makes it simpler and faster to unit test services.\n *\n * Use the returned AngularJS module in a call to\n * [`angular.mocks.module`](https://docs.angularjs.org/api/ngMock/function/angular.mock.module) to\n * include this module in the unit test injector.\n *\n * In the following code snippet, we are configuring the `$injector` with two modules:\n * The AngularJS `ng1AppModule`, which is the AngularJS part of our hybrid application and the\n * `Ng2AppModule`, which is the Angular part.\n *\n * <code-example path=\"upgrade/static/ts/full/module.spec.ts\"\n * region=\"angularjs-setup\"></code-example>\n *\n * Once this is done we can get hold of services via the AngularJS `$injector` as normal.\n * Services that are (or have dependencies on) a downgraded Angular service, will be instantiated as\n * needed by the Angular root `Injector`.\n *\n * In the following code snippet, `heroesService` is a downgraded Angular service that we are\n * accessing from AngularJS.\n *\n * <code-example path=\"upgrade/static/ts/full/module.spec.ts\"\n * region=\"angularjs-spec\"></code-example>\n *\n * <div class=\"alert is-important\">\n *\n * This helper is for testing services not components.\n * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or\n * `downgradeModule` for more information.\n *\n * </div>\n *\n * <div class=\"alert is-important\">\n *\n * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the\n * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger\n * AngularJS handlers of async events from Angular.\n *\n * </div>\n *\n * <div class=\"alert is-important\">\n *\n * The helper sets up global variables to hold the shared Angular and AngularJS injectors.\n *\n * * Only call this helper once per spec.\n * * Do not use `createAngularJSTestingModule` in the same spec as `createAngularTestingModule`.\n *\n * </div>\n *\n * Here is the example application and its unit tests that use `createAngularTestingModule`\n * and `createAngularJSTestingModule`.\n *\n * <code-tabs>\n * <code-pane header=\"module.spec.ts\" path=\"upgrade/static/ts/full/module.spec.ts\"></code-pane>\n * <code-pane header=\"module.ts\" path=\"upgrade/static/ts/full/module.ts\"></code-pane>\n * </code-tabs>\n *\n *\n * @param angularModules a collection of Angular modules to include in the configuration.\n *\n * @publicApi\n */\nexport function createAngularJSTestingModule(angularModules: any[]): string {\n return ng.module_('$$angularJSTestingModule', [])\n .constant(UPGRADE_APP_TYPE_KEY, UpgradeAppType.Static)\n .factory(\n INJECTOR_KEY,\n [\n $INJECTOR,\n ($injector: ng.IInjectorService) => {\n TestBed.configureTestingModule({\n imports: angularModules,\n providers: [{provide: $INJECTOR, useValue: $injector}]\n });\n return TestBed.inject(Injector);\n }\n ])\n .name;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["injector","angular.module_","angular.injector","ng.module_"],"mappings":";;;;;;;;;;AA+NA,SAAS,IAAI,GAAA;AACX,IAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,WAAW,IAA4B,MAAM,IAAI,EAAE,CAAQ,CAAC;AAClE,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC;AAE7B,IAAI,OAAO,GAYP;AACF,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,OAAO,EAAE,WAAW;AACpB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,OAAO,EAAE,SAAgB;AACzB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF,IAAI;AACF,IAAA,IAAI,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;AACpC,QAAA,OAAO,GAAS,MAAO,CAAC,OAAO,CAAC;AACjC,KAAA;AACF,CAAA;AAAC,OAAM,EAAA,EAAA;;AAEP,CAAA;AAED;;;;AAIG;AACG,SAAU,aAAa,CAAC,EAAO,EAAA;IACnC,kBAAkB,CAAC,EAAE,CAAC,C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EG;;;;"}
|
package/fesm2015/static.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v15.1.
|
|
2
|
+
* @license Angular v15.1.3
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -110,9 +110,6 @@ class PropertyBinding {
|
|
|
110
110
|
constructor(prop, attr) {
|
|
111
111
|
this.prop = prop;
|
|
112
112
|
this.attr = attr;
|
|
113
|
-
this.parseBinding();
|
|
114
|
-
}
|
|
115
|
-
parseBinding() {
|
|
116
113
|
this.bracketAttr = `[${this.attr}]`;
|
|
117
114
|
this.parenAttr = `(${this.attr})`;
|
|
118
115
|
this.bracketParenAttr = `[(${this.attr})]`;
|
|
@@ -127,13 +124,7 @@ const DIRECTIVE_PREFIX_REGEXP = /^(?:x|data)[:\-_]/i;
|
|
|
127
124
|
const DIRECTIVE_SPECIAL_CHARS_REGEXP = /[:\-_]+(.)/g;
|
|
128
125
|
function onError(e) {
|
|
129
126
|
// TODO: (misko): We seem to not have a stack trace here!
|
|
130
|
-
|
|
131
|
-
console.error(e, e.stack);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
// tslint:disable-next-line:no-console
|
|
135
|
-
console.log(e, e.stack);
|
|
136
|
-
}
|
|
127
|
+
console.error(e, e.stack);
|
|
137
128
|
throw e;
|
|
138
129
|
}
|
|
139
130
|
/**
|
|
@@ -300,32 +291,38 @@ class DowngradeComponentAdapter {
|
|
|
300
291
|
});
|
|
301
292
|
return compiledProjectableNodes;
|
|
302
293
|
}
|
|
294
|
+
createComponentAndSetup(projectableNodes, manuallyAttachView = false, propagateDigest = true) {
|
|
295
|
+
const component = this.createComponent(projectableNodes);
|
|
296
|
+
this.setupInputs(manuallyAttachView, propagateDigest, component);
|
|
297
|
+
this.setupOutputs(component.componentRef);
|
|
298
|
+
this.registerCleanup(component.componentRef);
|
|
299
|
+
return component.componentRef;
|
|
300
|
+
}
|
|
303
301
|
createComponent(projectableNodes) {
|
|
304
302
|
const providers = [{ provide: $SCOPE, useValue: this.componentScope }];
|
|
305
303
|
const childInjector = Injector.create({ providers: providers, parent: this.parentInjector, name: 'DowngradeComponentAdapter' });
|
|
306
|
-
this.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
this.changeDetector = this.componentRef.changeDetectorRef;
|
|
310
|
-
this.component = this.componentRef.instance;
|
|
304
|
+
const componentRef = this.componentFactory.create(childInjector, projectableNodes, this.element[0]);
|
|
305
|
+
const viewChangeDetector = componentRef.injector.get(ChangeDetectorRef);
|
|
306
|
+
const changeDetector = componentRef.changeDetectorRef;
|
|
311
307
|
// testability hook is commonly added during component bootstrap in
|
|
312
308
|
// packages/core/src/application_ref.bootstrap()
|
|
313
309
|
// in downgraded application, component creation will take place here as well as adding the
|
|
314
310
|
// testability hook.
|
|
315
|
-
const testability =
|
|
311
|
+
const testability = componentRef.injector.get(Testability, null);
|
|
316
312
|
if (testability) {
|
|
317
|
-
|
|
318
|
-
.registerApplication(
|
|
313
|
+
componentRef.injector.get(TestabilityRegistry)
|
|
314
|
+
.registerApplication(componentRef.location.nativeElement, testability);
|
|
319
315
|
}
|
|
320
|
-
hookupNgModel(this.ngModel,
|
|
316
|
+
hookupNgModel(this.ngModel, componentRef.instance);
|
|
317
|
+
return { viewChangeDetector, componentRef, changeDetector };
|
|
321
318
|
}
|
|
322
|
-
setupInputs(manuallyAttachView, propagateDigest = true) {
|
|
319
|
+
setupInputs(manuallyAttachView, propagateDigest = true, { componentRef, changeDetector, viewChangeDetector }) {
|
|
323
320
|
const attrs = this.attrs;
|
|
324
321
|
const inputs = this.componentFactory.inputs || [];
|
|
325
|
-
for (
|
|
326
|
-
const
|
|
322
|
+
for (const input of inputs) {
|
|
323
|
+
const inputBinding = new PropertyBinding(input.propName, input.templateName);
|
|
327
324
|
let expr = null;
|
|
328
|
-
if (attrs.hasOwnProperty(
|
|
325
|
+
if (attrs.hasOwnProperty(inputBinding.attr)) {
|
|
329
326
|
const observeFn = (prop => {
|
|
330
327
|
let prevValue = INITIAL_VALUE$1;
|
|
331
328
|
return (currValue) => {
|
|
@@ -334,40 +331,40 @@ class DowngradeComponentAdapter {
|
|
|
334
331
|
if (prevValue === INITIAL_VALUE$1) {
|
|
335
332
|
prevValue = currValue;
|
|
336
333
|
}
|
|
337
|
-
this.updateInput(prop, prevValue, currValue);
|
|
334
|
+
this.updateInput(componentRef, prop, prevValue, currValue);
|
|
338
335
|
prevValue = currValue;
|
|
339
336
|
}
|
|
340
337
|
};
|
|
341
|
-
})(
|
|
342
|
-
attrs.$observe(
|
|
338
|
+
})(inputBinding.prop);
|
|
339
|
+
attrs.$observe(inputBinding.attr, observeFn);
|
|
343
340
|
// Use `$watch()` (in addition to `$observe()`) in order to initialize the input in time
|
|
344
341
|
// for `ngOnChanges()`. This is necessary if we are already in a `$digest`, which means that
|
|
345
342
|
// `ngOnChanges()` (which is called by a watcher) will run before the `$observe()` callback.
|
|
346
343
|
let unwatch = this.componentScope.$watch(() => {
|
|
347
344
|
unwatch();
|
|
348
345
|
unwatch = null;
|
|
349
|
-
observeFn(attrs[
|
|
346
|
+
observeFn(attrs[inputBinding.attr]);
|
|
350
347
|
});
|
|
351
348
|
}
|
|
352
|
-
else if (attrs.hasOwnProperty(
|
|
353
|
-
expr = attrs[
|
|
349
|
+
else if (attrs.hasOwnProperty(inputBinding.bindAttr)) {
|
|
350
|
+
expr = attrs[inputBinding.bindAttr];
|
|
354
351
|
}
|
|
355
|
-
else if (attrs.hasOwnProperty(
|
|
356
|
-
expr = attrs[
|
|
352
|
+
else if (attrs.hasOwnProperty(inputBinding.bracketAttr)) {
|
|
353
|
+
expr = attrs[inputBinding.bracketAttr];
|
|
357
354
|
}
|
|
358
|
-
else if (attrs.hasOwnProperty(
|
|
359
|
-
expr = attrs[
|
|
355
|
+
else if (attrs.hasOwnProperty(inputBinding.bindonAttr)) {
|
|
356
|
+
expr = attrs[inputBinding.bindonAttr];
|
|
360
357
|
}
|
|
361
|
-
else if (attrs.hasOwnProperty(
|
|
362
|
-
expr = attrs[
|
|
358
|
+
else if (attrs.hasOwnProperty(inputBinding.bracketParenAttr)) {
|
|
359
|
+
expr = attrs[inputBinding.bracketParenAttr];
|
|
363
360
|
}
|
|
364
361
|
if (expr != null) {
|
|
365
|
-
const watchFn = (prop => (currValue, prevValue) => this.updateInput(prop, prevValue, currValue))(
|
|
362
|
+
const watchFn = ((prop) => (currValue, prevValue) => this.updateInput(componentRef, prop, prevValue, currValue))(inputBinding.prop);
|
|
366
363
|
this.componentScope.$watch(expr, watchFn);
|
|
367
364
|
}
|
|
368
365
|
}
|
|
369
366
|
// Invoke `ngOnChanges()` and Change Detection (when necessary)
|
|
370
|
-
const detectChanges = () =>
|
|
367
|
+
const detectChanges = () => changeDetector.detectChanges();
|
|
371
368
|
const prototype = this.componentFactory.componentType.prototype;
|
|
372
369
|
this.implementsOnChanges = !!(prototype && prototype.ngOnChanges);
|
|
373
370
|
this.componentScope.$watch(() => this.inputChangeCount, this.wrapCallback(() => {
|
|
@@ -375,9 +372,9 @@ class DowngradeComponentAdapter {
|
|
|
375
372
|
if (this.implementsOnChanges) {
|
|
376
373
|
const inputChanges = this.inputChanges;
|
|
377
374
|
this.inputChanges = {};
|
|
378
|
-
|
|
375
|
+
componentRef.instance.ngOnChanges(inputChanges);
|
|
379
376
|
}
|
|
380
|
-
|
|
377
|
+
viewChangeDetector.markForCheck();
|
|
381
378
|
// If opted out of propagating digests, invoke change detection when inputs change.
|
|
382
379
|
if (!propagateDigest) {
|
|
383
380
|
detectChanges();
|
|
@@ -394,39 +391,39 @@ class DowngradeComponentAdapter {
|
|
|
394
391
|
unwatch();
|
|
395
392
|
unwatch = null;
|
|
396
393
|
const appRef = this.parentInjector.get(ApplicationRef);
|
|
397
|
-
appRef.attachView(
|
|
394
|
+
appRef.attachView(componentRef.hostView);
|
|
398
395
|
});
|
|
399
396
|
}
|
|
400
397
|
}
|
|
401
|
-
setupOutputs() {
|
|
398
|
+
setupOutputs(componentRef) {
|
|
402
399
|
const attrs = this.attrs;
|
|
403
400
|
const outputs = this.componentFactory.outputs || [];
|
|
404
|
-
for (
|
|
405
|
-
const
|
|
406
|
-
const bindonAttr =
|
|
407
|
-
const bracketParenAttr = `[(${
|
|
401
|
+
for (const output of outputs) {
|
|
402
|
+
const outputBindings = new PropertyBinding(output.propName, output.templateName);
|
|
403
|
+
const bindonAttr = outputBindings.bindonAttr.substring(0, outputBindings.bindonAttr.length - 6);
|
|
404
|
+
const bracketParenAttr = `[(${outputBindings.bracketParenAttr.substring(2, outputBindings.bracketParenAttr.length - 8)})]`;
|
|
408
405
|
// order below is important - first update bindings then evaluate expressions
|
|
409
406
|
if (attrs.hasOwnProperty(bindonAttr)) {
|
|
410
|
-
this.subscribeToOutput(
|
|
407
|
+
this.subscribeToOutput(componentRef, outputBindings, attrs[bindonAttr], true);
|
|
411
408
|
}
|
|
412
409
|
if (attrs.hasOwnProperty(bracketParenAttr)) {
|
|
413
|
-
this.subscribeToOutput(
|
|
410
|
+
this.subscribeToOutput(componentRef, outputBindings, attrs[bracketParenAttr], true);
|
|
414
411
|
}
|
|
415
|
-
if (attrs.hasOwnProperty(
|
|
416
|
-
this.subscribeToOutput(
|
|
412
|
+
if (attrs.hasOwnProperty(outputBindings.onAttr)) {
|
|
413
|
+
this.subscribeToOutput(componentRef, outputBindings, attrs[outputBindings.onAttr]);
|
|
417
414
|
}
|
|
418
|
-
if (attrs.hasOwnProperty(
|
|
419
|
-
this.subscribeToOutput(
|
|
415
|
+
if (attrs.hasOwnProperty(outputBindings.parenAttr)) {
|
|
416
|
+
this.subscribeToOutput(componentRef, outputBindings, attrs[outputBindings.parenAttr]);
|
|
420
417
|
}
|
|
421
418
|
}
|
|
422
419
|
}
|
|
423
|
-
subscribeToOutput(output, expr, isAssignment = false) {
|
|
420
|
+
subscribeToOutput(componentRef, output, expr, isAssignment = false) {
|
|
424
421
|
const getter = this.$parse(expr);
|
|
425
422
|
const setter = getter.assign;
|
|
426
423
|
if (isAssignment && !setter) {
|
|
427
424
|
throw new Error(`Expression '${expr}' is not assignable!`);
|
|
428
425
|
}
|
|
429
|
-
const emitter =
|
|
426
|
+
const emitter = componentRef.instance[output.prop];
|
|
430
427
|
if (emitter) {
|
|
431
428
|
emitter.subscribe({
|
|
432
429
|
next: isAssignment ? (v) => setter(this.scope, v) :
|
|
@@ -437,9 +434,9 @@ class DowngradeComponentAdapter {
|
|
|
437
434
|
throw new Error(`Missing emitter '${output.prop}' on component '${getTypeName(this.componentFactory.componentType)}'!`);
|
|
438
435
|
}
|
|
439
436
|
}
|
|
440
|
-
registerCleanup() {
|
|
441
|
-
const testabilityRegistry =
|
|
442
|
-
const destroyComponentRef = this.wrapCallback(() =>
|
|
437
|
+
registerCleanup(componentRef) {
|
|
438
|
+
const testabilityRegistry = componentRef.injector.get(TestabilityRegistry);
|
|
439
|
+
const destroyComponentRef = this.wrapCallback(() => componentRef.destroy());
|
|
443
440
|
let destroyed = false;
|
|
444
441
|
this.element.on('$destroy', () => {
|
|
445
442
|
// The `$destroy` event may have been triggered by the `cleanData()` call in the
|
|
@@ -451,7 +448,7 @@ class DowngradeComponentAdapter {
|
|
|
451
448
|
this.componentScope.$on('$destroy', () => {
|
|
452
449
|
if (!destroyed) {
|
|
453
450
|
destroyed = true;
|
|
454
|
-
testabilityRegistry.unregisterApplication(
|
|
451
|
+
testabilityRegistry.unregisterApplication(componentRef.location.nativeElement);
|
|
455
452
|
// The `componentScope` might be getting destroyed, because an ancestor element is being
|
|
456
453
|
// removed/destroyed. If that is the case, jqLite/jQuery would normally invoke `cleanData()`
|
|
457
454
|
// on the removed element and all descendants.
|
|
@@ -471,15 +468,12 @@ class DowngradeComponentAdapter {
|
|
|
471
468
|
}
|
|
472
469
|
});
|
|
473
470
|
}
|
|
474
|
-
|
|
475
|
-
return this.componentRef.injector;
|
|
476
|
-
}
|
|
477
|
-
updateInput(prop, prevValue, currValue) {
|
|
471
|
+
updateInput(componentRef, prop, prevValue, currValue) {
|
|
478
472
|
if (this.implementsOnChanges) {
|
|
479
473
|
this.inputChanges[prop] = new SimpleChange(prevValue, currValue, prevValue === currValue);
|
|
480
474
|
}
|
|
481
475
|
this.inputChangeCount++;
|
|
482
|
-
|
|
476
|
+
componentRef.instance[prop] = currValue;
|
|
483
477
|
}
|
|
484
478
|
groupProjectableNodes() {
|
|
485
479
|
let ngContentSelectors = this.componentFactory.ngContentSelectors;
|
|
@@ -523,14 +517,14 @@ function findMatchingNgContentIndex(element, ngContentSelectors) {
|
|
|
523
517
|
}
|
|
524
518
|
return ngContentIndices.length ? ngContentIndices[0] : null;
|
|
525
519
|
}
|
|
526
|
-
let _matches;
|
|
527
520
|
function matchesSelector(el, selector) {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
521
|
+
var _a;
|
|
522
|
+
const elProto = Element.prototype;
|
|
523
|
+
return el.nodeType === Node.ELEMENT_NODE
|
|
524
|
+
// matches is supported by all browsers from 2014 onwards except non-chromium edge
|
|
525
|
+
?
|
|
526
|
+
((_a = elProto.matches) !== null && _a !== void 0 ? _a : elProto.msMatchesSelector).call(el, selector) :
|
|
527
|
+
false;
|
|
534
528
|
}
|
|
535
529
|
|
|
536
530
|
function isThenable(obj) {
|
|
@@ -652,6 +646,7 @@ function downgradeComponent(info) {
|
|
|
652
646
|
terminal: true,
|
|
653
647
|
require: [REQUIRE_INJECTOR, REQUIRE_NG_MODEL],
|
|
654
648
|
link: (scope, element, attrs, required) => {
|
|
649
|
+
var _a;
|
|
655
650
|
// We might have to compile the contents asynchronously, because this might have been
|
|
656
651
|
// triggered by `UpgradeNg1ComponentAdapterBuilder`, before the Angular templates have
|
|
657
652
|
// been compiled.
|
|
@@ -665,7 +660,7 @@ function downgradeComponent(info) {
|
|
|
665
660
|
const attemptedAction = `instantiating component '${getTypeName(info.component)}'`;
|
|
666
661
|
validateInjectionKey($injector, downgradedModule, lazyModuleRefKey, attemptedAction);
|
|
667
662
|
const lazyModuleRef = $injector.get(lazyModuleRefKey);
|
|
668
|
-
moduleInjector = lazyModuleRef.injector
|
|
663
|
+
moduleInjector = (_a = lazyModuleRef.injector) !== null && _a !== void 0 ? _a : lazyModuleRef.promise;
|
|
669
664
|
}
|
|
670
665
|
// Notes:
|
|
671
666
|
//
|
|
@@ -716,11 +711,8 @@ function downgradeComponent(info) {
|
|
|
716
711
|
const injectorPromise = new ParentInjectorPromise(element);
|
|
717
712
|
const facade = new DowngradeComponentAdapter(element, attrs, scope, ngModel, injector, $compile, $parse, componentFactory, wrapCallback);
|
|
718
713
|
const projectableNodes = facade.compileContents();
|
|
719
|
-
facade.
|
|
720
|
-
|
|
721
|
-
facade.setupOutputs();
|
|
722
|
-
facade.registerCleanup();
|
|
723
|
-
injectorPromise.resolve(facade.getInjector());
|
|
714
|
+
const componentRef = facade.createComponentAndSetup(projectableNodes, isNgUpgradeLite, info.propagateDigest);
|
|
715
|
+
injectorPromise.resolve(componentRef.injector);
|
|
724
716
|
if (ranAsync) {
|
|
725
717
|
// If this is run async, it is possible that it is not run inside a
|
|
726
718
|
// digest and initial input values will not be detected.
|
|
@@ -855,7 +847,7 @@ function downgradeInjectable(token, downgradedModule = '') {
|
|
|
855
847
|
/**
|
|
856
848
|
* @publicApi
|
|
857
849
|
*/
|
|
858
|
-
const VERSION = new Version('15.1.
|
|
850
|
+
const VERSION = new Version('15.1.3');
|
|
859
851
|
|
|
860
852
|
// We have to do a little dance to get the ng1 injector into the module injector.
|
|
861
853
|
// We store the ng1 injector so that the provider in the module injector can access it
|
|
@@ -1096,7 +1088,7 @@ class UpgradeHelper {
|
|
|
1096
1088
|
this.$controller = this.$injector.get($CONTROLLER);
|
|
1097
1089
|
this.element = elementRef.nativeElement;
|
|
1098
1090
|
this.$element = element(this.element);
|
|
1099
|
-
this.directive = directive
|
|
1091
|
+
this.directive = directive !== null && directive !== void 0 ? directive : UpgradeHelper.getDirective(this.$injector, name);
|
|
1100
1092
|
}
|
|
1101
1093
|
static getDirective($injector, name) {
|
|
1102
1094
|
const directives = $injector.get(name + 'Directive');
|
|
@@ -1145,11 +1137,12 @@ class UpgradeHelper {
|
|
|
1145
1137
|
}
|
|
1146
1138
|
}
|
|
1147
1139
|
buildController(controllerType, $scope) {
|
|
1140
|
+
var _a, _b;
|
|
1148
1141
|
// TODO: Document that we do not pre-assign bindings on the controller instance.
|
|
1149
1142
|
// Quoted properties below so that this code can be optimized with Closure Compiler.
|
|
1150
1143
|
const locals = { '$scope': $scope, '$element': this.$element };
|
|
1151
1144
|
const controller = this.$controller(controllerType, locals, null, this.directive.controllerAs);
|
|
1152
|
-
this.$element.data(controllerKey(this.directive.name), controller);
|
|
1145
|
+
(_b = (_a = this.$element).data) === null || _b === void 0 ? void 0 : _b.call(_a, controllerKey(this.directive.name), controller);
|
|
1153
1146
|
return controller;
|
|
1154
1147
|
}
|
|
1155
1148
|
compileTemplate(template) {
|
|
@@ -1265,8 +1258,7 @@ class UpgradeHelper {
|
|
|
1265
1258
|
getDirectiveRequire() {
|
|
1266
1259
|
const require = this.directive.require || (this.directive.controller && this.directive.name);
|
|
1267
1260
|
if (isMap(require)) {
|
|
1268
|
-
Object.
|
|
1269
|
-
const value = require[key];
|
|
1261
|
+
Object.entries(require).forEach(([key, value]) => {
|
|
1270
1262
|
const match = value.match(REQUIRE_PREFIX_RE);
|
|
1271
1263
|
const name = value.substring(match[0].length);
|
|
1272
1264
|
if (!name) {
|
|
@@ -1276,7 +1268,7 @@ class UpgradeHelper {
|
|
|
1276
1268
|
}
|
|
1277
1269
|
return require;
|
|
1278
1270
|
}
|
|
1279
|
-
resolveRequire(require
|
|
1271
|
+
resolveRequire(require) {
|
|
1280
1272
|
if (!require) {
|
|
1281
1273
|
return null;
|
|
1282
1274
|
}
|
|
@@ -1384,15 +1376,14 @@ class UpgradeComponent {
|
|
|
1384
1376
|
* injection into the base class constructor.
|
|
1385
1377
|
*/
|
|
1386
1378
|
constructor(name, elementRef, injector) {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1379
|
+
// We will be instantiating the controller in the `ngOnInit` hook, when the
|
|
1380
|
+
// first `ngOnChanges` will have been already triggered. We store the
|
|
1381
|
+
// `SimpleChanges` and "play them back" later.
|
|
1382
|
+
this.pendingChanges = null;
|
|
1390
1383
|
this.helper = new UpgradeHelper(injector, name, elementRef);
|
|
1391
|
-
this.$injector = this.helper.$injector;
|
|
1392
|
-
this.element = this.helper.element;
|
|
1393
1384
|
this.$element = this.helper.$element;
|
|
1394
1385
|
this.directive = this.helper.directive;
|
|
1395
|
-
this.bindings = this.initializeBindings(this.directive);
|
|
1386
|
+
this.bindings = this.initializeBindings(this.directive, name);
|
|
1396
1387
|
// We ask for the AngularJS scope from the Angular injector, since
|
|
1397
1388
|
// we will put the new component scope onto the new injector for each component
|
|
1398
1389
|
const $parentScope = injector.get($SCOPE);
|
|
@@ -1408,20 +1399,28 @@ class UpgradeComponent {
|
|
|
1408
1399
|
// Instantiate controller
|
|
1409
1400
|
const controllerType = this.directive.controller;
|
|
1410
1401
|
const bindToController = this.directive.bindToController;
|
|
1411
|
-
|
|
1412
|
-
this.
|
|
1402
|
+
let controllerInstance = controllerType ?
|
|
1403
|
+
this.helper.buildController(controllerType, this.$componentScope) :
|
|
1404
|
+
undefined;
|
|
1405
|
+
let bindingDestination;
|
|
1406
|
+
if (!bindToController) {
|
|
1407
|
+
bindingDestination = this.$componentScope;
|
|
1413
1408
|
}
|
|
1414
|
-
else if (
|
|
1409
|
+
else if (controllerType && controllerInstance) {
|
|
1410
|
+
bindingDestination = controllerInstance;
|
|
1411
|
+
}
|
|
1412
|
+
else {
|
|
1415
1413
|
throw new Error(`Upgraded directive '${this.directive.name}' specifies 'bindToController' but no controller.`);
|
|
1416
1414
|
}
|
|
1415
|
+
this.controllerInstance = controllerInstance;
|
|
1416
|
+
this.bindingDestination = bindingDestination;
|
|
1417
1417
|
// Set up outputs
|
|
1418
|
-
this.bindingDestination
|
|
1419
|
-
this.bindOutputs();
|
|
1418
|
+
this.bindOutputs(bindingDestination);
|
|
1420
1419
|
// Require other controllers
|
|
1421
|
-
const requiredControllers = this.helper.resolveAndBindRequiredControllers(
|
|
1420
|
+
const requiredControllers = this.helper.resolveAndBindRequiredControllers(controllerInstance);
|
|
1422
1421
|
// Hook: $onChanges
|
|
1423
1422
|
if (this.pendingChanges) {
|
|
1424
|
-
this.forwardChanges(this.pendingChanges);
|
|
1423
|
+
this.forwardChanges(this.pendingChanges, bindingDestination);
|
|
1425
1424
|
this.pendingChanges = null;
|
|
1426
1425
|
}
|
|
1427
1426
|
// Hook: $onInit
|
|
@@ -1429,8 +1428,8 @@ class UpgradeComponent {
|
|
|
1429
1428
|
this.controllerInstance.$onInit();
|
|
1430
1429
|
}
|
|
1431
1430
|
// Hook: $doCheck
|
|
1432
|
-
if (
|
|
1433
|
-
const callDoCheck = () =>
|
|
1431
|
+
if (controllerInstance && isFunction(controllerInstance.$doCheck)) {
|
|
1432
|
+
const callDoCheck = () => { var _a; return (_a = controllerInstance === null || controllerInstance === void 0 ? void 0 : controllerInstance.$doCheck) === null || _a === void 0 ? void 0 : _a.call(controllerInstance); };
|
|
1434
1433
|
this.unregisterDoCheckWatcher = this.$componentScope.$parent.$watch(callDoCheck);
|
|
1435
1434
|
callDoCheck();
|
|
1436
1435
|
}
|
|
@@ -1457,7 +1456,7 @@ class UpgradeComponent {
|
|
|
1457
1456
|
this.pendingChanges = changes;
|
|
1458
1457
|
}
|
|
1459
1458
|
else {
|
|
1460
|
-
this.forwardChanges(changes);
|
|
1459
|
+
this.forwardChanges(changes, this.bindingDestination);
|
|
1461
1460
|
}
|
|
1462
1461
|
}
|
|
1463
1462
|
ngDoCheck() {
|
|
@@ -1465,7 +1464,8 @@ class UpgradeComponent {
|
|
|
1465
1464
|
const twoWayBoundLastValues = this.bindings.twoWayBoundLastValues;
|
|
1466
1465
|
const propertyToOutputMap = this.bindings.propertyToOutputMap;
|
|
1467
1466
|
twoWayBoundProperties.forEach((propName, idx) => {
|
|
1468
|
-
|
|
1467
|
+
var _a;
|
|
1468
|
+
const newValue = (_a = this.bindingDestination) === null || _a === void 0 ? void 0 : _a[propName];
|
|
1469
1469
|
const oldValue = twoWayBoundLastValues[idx];
|
|
1470
1470
|
if (!Object.is(newValue, oldValue)) {
|
|
1471
1471
|
const outputName = propertyToOutputMap[propName];
|
|
@@ -1481,7 +1481,7 @@ class UpgradeComponent {
|
|
|
1481
1481
|
}
|
|
1482
1482
|
this.helper.onDestroy(this.$componentScope, this.controllerInstance);
|
|
1483
1483
|
}
|
|
1484
|
-
initializeBindings(directive) {
|
|
1484
|
+
initializeBindings(directive, name) {
|
|
1485
1485
|
const btcIsObject = typeof directive.bindToController === 'object';
|
|
1486
1486
|
if (btcIsObject && Object.keys(directive.scope).length) {
|
|
1487
1487
|
throw new Error(`Binding definitions on scope and controller at the same time is not supported.`);
|
|
@@ -1511,7 +1511,7 @@ class UpgradeComponent {
|
|
|
1511
1511
|
break;
|
|
1512
1512
|
default:
|
|
1513
1513
|
let json = JSON.stringify(context);
|
|
1514
|
-
throw new Error(`Unexpected mapping '${bindingType}' in '${json}' in '${
|
|
1514
|
+
throw new Error(`Unexpected mapping '${bindingType}' in '${json}' in '${name}' directive.`);
|
|
1515
1515
|
}
|
|
1516
1516
|
});
|
|
1517
1517
|
}
|
|
@@ -1525,25 +1525,25 @@ class UpgradeComponent {
|
|
|
1525
1525
|
this[outputName] = new EventEmitter();
|
|
1526
1526
|
});
|
|
1527
1527
|
}
|
|
1528
|
-
bindOutputs() {
|
|
1528
|
+
bindOutputs(bindingDestination) {
|
|
1529
1529
|
// Bind `&` bindings to the corresponding outputs
|
|
1530
1530
|
this.bindings.expressionBoundProperties.forEach(propName => {
|
|
1531
1531
|
const outputName = this.bindings.propertyToOutputMap[propName];
|
|
1532
1532
|
const emitter = this[outputName];
|
|
1533
|
-
|
|
1533
|
+
bindingDestination[propName] = (value) => emitter.emit(value);
|
|
1534
1534
|
});
|
|
1535
1535
|
}
|
|
1536
|
-
forwardChanges(changes) {
|
|
1536
|
+
forwardChanges(changes, bindingDestination) {
|
|
1537
1537
|
// Forward input changes to `bindingDestination`
|
|
1538
|
-
Object.keys(changes).forEach(propName =>
|
|
1539
|
-
if (isFunction(
|
|
1540
|
-
|
|
1538
|
+
Object.keys(changes).forEach(propName => bindingDestination[propName] = changes[propName].currentValue);
|
|
1539
|
+
if (isFunction(bindingDestination.$onChanges)) {
|
|
1540
|
+
bindingDestination.$onChanges(changes);
|
|
1541
1541
|
}
|
|
1542
1542
|
}
|
|
1543
1543
|
}
|
|
1544
|
-
UpgradeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.
|
|
1545
|
-
UpgradeComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.
|
|
1546
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.
|
|
1544
|
+
UpgradeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: UpgradeComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
1545
|
+
UpgradeComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.3", type: UpgradeComponent, usesOnChanges: true, ngImport: i0 });
|
|
1546
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: UpgradeComponent, decorators: [{
|
|
1547
1547
|
type: Directive
|
|
1548
1548
|
}], ctorParameters: function () { return [{ type: undefined }, { type: i0.ElementRef }, { type: i0.Injector }]; } });
|
|
1549
1549
|
|
|
@@ -1817,10 +1817,10 @@ class UpgradeModule {
|
|
|
1817
1817
|
return returnValue;
|
|
1818
1818
|
}
|
|
1819
1819
|
}
|
|
1820
|
-
UpgradeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.
|
|
1821
|
-
UpgradeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.
|
|
1822
|
-
UpgradeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.
|
|
1823
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.
|
|
1820
|
+
UpgradeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: UpgradeModule, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: i0.PlatformRef }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1821
|
+
UpgradeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.3", ngImport: i0, type: UpgradeModule });
|
|
1822
|
+
UpgradeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: UpgradeModule, providers: [angular1Providers] });
|
|
1823
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: UpgradeModule, decorators: [{
|
|
1824
1824
|
type: NgModule,
|
|
1825
1825
|
args: [{ providers: [angular1Providers] }]
|
|
1826
1826
|
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.NgZone }, { type: i0.PlatformRef }]; } });
|