(
$compile: ICompileService,
$injector: IInjectorService,
$parse: IParseService,
)
| 100 | selectors?: string[]; |
| 101 | }): any /* angular.IInjectable */ { |
| 102 | const directiveFactory: IAnnotatedFunction = function ( |
| 103 | $compile: ICompileService, |
| 104 | $injector: IInjectorService, |
| 105 | $parse: IParseService, |
| 106 | ): IDirective { |
| 107 | const unsafelyOverwriteSignalInputs = |
| 108 | (info as {unsafelyOverwriteSignalInputs?: boolean}).unsafelyOverwriteSignalInputs ?? false; |
| 109 | // When using `downgradeModule()`, we need to handle certain things specially. For example: |
| 110 | // - We always need to attach the component view to the `ApplicationRef` for it to be |
| 111 | // dirty-checked. |
| 112 | // - We need to ensure callbacks to Angular APIs (e.g. change detection) are run inside the |
| 113 | // Angular zone. |
| 114 | // NOTE: This is not needed, when using `UpgradeModule`, because `$digest()` will be run |
| 115 | // inside the Angular zone (except if explicitly escaped, in which case we shouldn't |
| 116 | // force it back in). |
| 117 | const isNgUpgradeLite = getUpgradeAppType($injector) === UpgradeAppType.Lite; |
| 118 | const wrapCallback: <T>(cb: () => T) => typeof cb = !isNgUpgradeLite |
| 119 | ? (cb) => cb |
| 120 | : (cb) => () => (NgZone.isInAngularZone() ? cb() : ngZone.run(cb)); |
| 121 | let ngZone: NgZone; |
| 122 | |
| 123 | // When downgrading multiple modules, special handling is needed wrt injectors. |
| 124 | const hasMultipleDowngradedModules = isNgUpgradeLite && getDowngradedModuleCount($injector) > 1; |
| 125 | |
| 126 | return { |
| 127 | restrict: 'E', |
| 128 | terminal: true, |
| 129 | require: [REQUIRE_INJECTOR, REQUIRE_NG_MODEL], |
| 130 | // Controller needs to be set so that `angular-component-router.js` (from beta Angular 2) |
| 131 | // configuration properties can be made available. See: |
| 132 | // See G3: javascript/angular2/angular1_router_lib.js |
| 133 | // https://github.com/angular/angular.js/blob/47bf11ee94664367a26ed8c91b9b586d3dd420f5/src/ng/compile.js#L1670-L1691. |
| 134 | controller: function () {}, |
| 135 | compile: (tElement: IAugmentedJQuery, tAttrs: IAttributes) => { |
| 136 | // Capture a copy of the static template contents during compilation, before any |
| 137 | // controllers (e.g. higher-priority directives, `ng-controller`, or same-priority |
| 138 | // directives sorted before this one) or ancestor pre-link hooks can run and write |
| 139 | // dynamic content into the host element. A DocumentFragment keeps the copies as siblings, |
| 140 | // as multi-element directives (e.g. `ng-repeat-start`) need. |
| 141 | // Skip capturing when a co-located transclusion directive (such as `ng-transclude` or a |
| 142 | // priority-0 directive with `transclude: true` / multi-slot transclusion) is present on |
| 143 | // the same element: it owns the host's template children (emptying `tElement` in |
| 144 | // `applyDirectivesToNode` / `compile`, which may run after this directive if its name |
| 145 | // sorts after ours) and inserts already-compiled nodes during linking. |
| 146 | let templateFragment: DocumentFragment | null = null; |
| 147 | const hostElement = tElement[0]; |
| 148 | if ( |
| 149 | hostElement && |
| 150 | !hasCoLocatedTranscludeDirective(tAttrs, $injector) && |
| 151 | hasCompilableChildNodes(hostElement) |
| 152 | ) { |
| 153 | templateFragment = (hostElement.ownerDocument ?? document).createDocumentFragment(); |
| 154 | hostElement.childNodes.forEach((node) => |
| 155 | templateFragment!.appendChild(node.cloneNode(true)), |
| 156 | ); |
| 157 | } |
| 158 | |
| 159 | return { |
nothing calls this directly
no test coverage detected