@angular/core 15.0.0-next.3 → 15.0.0-next.4

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.
Files changed (33) hide show
  1. package/esm2020/src/core_private_export.mjs +2 -2
  2. package/esm2020/src/di/index.mjs +1 -1
  3. package/esm2020/src/di/injector.mjs +1 -1
  4. package/esm2020/src/di/injector_compatibility.mjs +15 -11
  5. package/esm2020/src/di/interface/injector.mjs +1 -1
  6. package/esm2020/src/di/r3_injector.mjs +3 -2
  7. package/esm2020/src/render3/component_ref.mjs +102 -83
  8. package/esm2020/src/render3/context_discovery.mjs +7 -7
  9. package/esm2020/src/render3/di.mjs +3 -2
  10. package/esm2020/src/render3/features/host_directives_feature.mjs +2 -3
  11. package/esm2020/src/render3/instructions/element.mjs +3 -15
  12. package/esm2020/src/render3/instructions/shared.mjs +93 -106
  13. package/esm2020/src/render3/ng_module_ref.mjs +1 -1
  14. package/esm2020/src/render3/node_manipulation.mjs +15 -1
  15. package/esm2020/src/render3/util/discovery_utils.mjs +2 -2
  16. package/esm2020/src/util/is_dev_mode.mjs +11 -19
  17. package/esm2020/src/version.mjs +1 -1
  18. package/esm2020/src/zone/async-stack-tagging.mjs +28 -0
  19. package/esm2020/src/zone/ng_zone.mjs +8 -3
  20. package/esm2020/testing/src/logger.mjs +3 -3
  21. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  22. package/esm2020/testing/src/test_bed.mjs +4 -4
  23. package/fesm2015/core.mjs +1506 -1470
  24. package/fesm2015/core.mjs.map +1 -1
  25. package/fesm2015/testing.mjs +888 -877
  26. package/fesm2015/testing.mjs.map +1 -1
  27. package/fesm2020/core.mjs +1509 -1475
  28. package/fesm2020/core.mjs.map +1 -1
  29. package/fesm2020/testing.mjs +886 -876
  30. package/fesm2020/testing.mjs.map +1 -1
  31. package/index.d.ts +60 -5
  32. package/package.json +1 -1
  33. package/testing/index.d.ts +9 -1
package/fesm2015/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v15.0.0-next.3
2
+ * @license Angular v15.0.0-next.4
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -582,152 +582,6 @@ function assertInjectImplementationNotEqual(fn) {
582
582
  assertNotEqual(_injectImplementation, fn, 'Calling ɵɵinject would cause infinite recursion');
583
583
  }
584
584
 
585
- /**
586
- * @license
587
- * Copyright Google LLC All Rights Reserved.
588
- *
589
- * Use of this source code is governed by an MIT-style license that can be
590
- * found in the LICENSE file at https://angular.io/license
591
- */
592
- /**
593
- * Convince closure compiler that the wrapped function has no side-effects.
594
- *
595
- * Closure compiler always assumes that `toString` has no side-effects. We use this quirk to
596
- * allow us to execute a function but have closure compiler mark the call as no-side-effects.
597
- * It is important that the return value for the `noSideEffects` function be assigned
598
- * to something which is retained otherwise the call to `noSideEffects` will be removed by closure
599
- * compiler.
600
- */
601
- function noSideEffects(fn) {
602
- return { toString: fn }.toString();
603
- }
604
-
605
- /**
606
- * @license
607
- * Copyright Google LLC All Rights Reserved.
608
- *
609
- * Use of this source code is governed by an MIT-style license that can be
610
- * found in the LICENSE file at https://angular.io/license
611
- */
612
- /**
613
- * The strategy that the default change detector uses to detect changes.
614
- * When set, takes effect the next time change detection is triggered.
615
- *
616
- * @see {@link ChangeDetectorRef#usage-notes Change detection usage}
617
- *
618
- * @publicApi
619
- */
620
- var ChangeDetectionStrategy;
621
- (function (ChangeDetectionStrategy) {
622
- /**
623
- * Use the `CheckOnce` strategy, meaning that automatic change detection is deactivated
624
- * until reactivated by setting the strategy to `Default` (`CheckAlways`).
625
- * Change detection can still be explicitly invoked.
626
- * This strategy applies to all child directives and cannot be overridden.
627
- */
628
- ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 0] = "OnPush";
629
- /**
630
- * Use the default `CheckAlways` strategy, in which change detection is automatic until
631
- * explicitly deactivated.
632
- */
633
- ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 1] = "Default";
634
- })(ChangeDetectionStrategy || (ChangeDetectionStrategy = {}));
635
- /**
636
- * Defines the possible states of the default change detector.
637
- * @see `ChangeDetectorRef`
638
- */
639
- var ChangeDetectorStatus;
640
- (function (ChangeDetectorStatus) {
641
- /**
642
- * A state in which, after calling `detectChanges()`, the change detector
643
- * state becomes `Checked`, and must be explicitly invoked or reactivated.
644
- */
645
- ChangeDetectorStatus[ChangeDetectorStatus["CheckOnce"] = 0] = "CheckOnce";
646
- /**
647
- * A state in which change detection is skipped until the change detector mode
648
- * becomes `CheckOnce`.
649
- */
650
- ChangeDetectorStatus[ChangeDetectorStatus["Checked"] = 1] = "Checked";
651
- /**
652
- * A state in which change detection continues automatically until explicitly
653
- * deactivated.
654
- */
655
- ChangeDetectorStatus[ChangeDetectorStatus["CheckAlways"] = 2] = "CheckAlways";
656
- /**
657
- * A state in which a change detector sub tree is not a part of the main tree and
658
- * should be skipped.
659
- */
660
- ChangeDetectorStatus[ChangeDetectorStatus["Detached"] = 3] = "Detached";
661
- /**
662
- * Indicates that the change detector encountered an error checking a binding
663
- * or calling a directive lifecycle method and is now in an inconsistent state. Change
664
- * detectors in this state do not detect changes.
665
- */
666
- ChangeDetectorStatus[ChangeDetectorStatus["Errored"] = 4] = "Errored";
667
- /**
668
- * Indicates that the change detector has been destroyed.
669
- */
670
- ChangeDetectorStatus[ChangeDetectorStatus["Destroyed"] = 5] = "Destroyed";
671
- })(ChangeDetectorStatus || (ChangeDetectorStatus = {}));
672
- /**
673
- * Reports whether a given strategy is currently the default for change detection.
674
- * @param changeDetectionStrategy The strategy to check.
675
- * @returns True if the given strategy is the current default, false otherwise.
676
- * @see `ChangeDetectorStatus`
677
- * @see `ChangeDetectorRef`
678
- */
679
- function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
680
- return changeDetectionStrategy == null ||
681
- changeDetectionStrategy === ChangeDetectionStrategy.Default;
682
- }
683
-
684
- /**
685
- * @license
686
- * Copyright Google LLC All Rights Reserved.
687
- *
688
- * Use of this source code is governed by an MIT-style license that can be
689
- * found in the LICENSE file at https://angular.io/license
690
- */
691
- /**
692
- * Defines the CSS styles encapsulation policies for the {@link Component} decorator's
693
- * `encapsulation` option.
694
- *
695
- * See {@link Component#encapsulation encapsulation}.
696
- *
697
- * @usageNotes
698
- * ### Example
699
- *
700
- * {@example core/ts/metadata/encapsulation.ts region='longform'}
701
- *
702
- * @publicApi
703
- */
704
- var ViewEncapsulation$1;
705
- (function (ViewEncapsulation) {
706
- // TODO: consider making `ViewEncapsulation` a `const enum` instead. See
707
- // https://github.com/angular/angular/issues/44119 for additional information.
708
- /**
709
- * Emulates a native Shadow DOM encapsulation behavior by adding a specific attribute to the
710
- * component's host element and applying the same attribute to all the CSS selectors provided
711
- * via {@link Component#styles styles} or {@link Component#styleUrls styleUrls}.
712
- *
713
- * This is the default option.
714
- */
715
- ViewEncapsulation[ViewEncapsulation["Emulated"] = 0] = "Emulated";
716
- // Historically the 1 value was for `Native` encapsulation which has been removed as of v11.
717
- /**
718
- * Doesn't provide any sort of CSS style encapsulation, meaning that all the styles provided
719
- * via {@link Component#styles styles} or {@link Component#styleUrls styleUrls} are applicable
720
- * to any HTML element of the application regardless of their host Component.
721
- */
722
- ViewEncapsulation[ViewEncapsulation["None"] = 2] = "None";
723
- /**
724
- * Uses the browser's native Shadow DOM API to encapsulate CSS styles, meaning that it creates
725
- * a ShadowRoot for the component's host element which is then used to encapsulate
726
- * all the Component's styling.
727
- */
728
- ViewEncapsulation[ViewEncapsulation["ShadowDom"] = 3] = "ShadowDom";
729
- })(ViewEncapsulation$1 || (ViewEncapsulation$1 = {}));
730
-
731
585
  /**
732
586
  * @license
733
587
  * Copyright Google LLC All Rights Reserved.
@@ -826,61 +680,437 @@ function initNgDevMode() {
826
680
  * Use of this source code is governed by an MIT-style license that can be
827
681
  * found in the LICENSE file at https://angular.io/license
828
682
  */
683
+ const _THROW_IF_NOT_FOUND = {};
684
+ const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
685
+ /*
686
+ * Name of a property (that we patch onto DI decorator), which is used as an annotation of which
687
+ * InjectFlag this decorator represents. This allows to avoid direct references to the DI decorators
688
+ * in the code, thus making them tree-shakable.
689
+ */
690
+ const DI_DECORATOR_FLAG = '__NG_DI_FLAG__';
691
+ const NG_TEMP_TOKEN_PATH = 'ngTempTokenPath';
692
+ const NG_TOKEN_PATH = 'ngTokenPath';
693
+ const NEW_LINE = /\n/gm;
694
+ const NO_NEW_LINE = 'ɵ';
695
+ const SOURCE = '__source';
829
696
  /**
830
- * This file contains reuseable "empty" symbols that can be used as default return values
831
- * in different parts of the rendering code. Because the same symbols are returned, this
832
- * allows for identity checks against these values to be consistently used by the framework
833
- * code.
697
+ * Current injector value used by `inject`.
698
+ * - `undefined`: it is an error to call `inject`
699
+ * - `null`: `inject` can be called but there is no injector (limp-mode).
700
+ * - Injector instance: Use the injector for resolution.
834
701
  */
835
- const EMPTY_OBJ = {};
836
- const EMPTY_ARRAY = [];
837
- // freezing the values prevents any code from accidentally inserting new values in
838
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode()) {
839
- // These property accesses can be ignored because ngDevMode will be set to false
840
- // when optimizing code and the whole if statement will be dropped.
841
- // tslint:disable-next-line:no-toplevel-property-access
842
- Object.freeze(EMPTY_OBJ);
843
- // tslint:disable-next-line:no-toplevel-property-access
844
- Object.freeze(EMPTY_ARRAY);
702
+ let _currentInjector = undefined;
703
+ function setCurrentInjector(injector) {
704
+ const former = _currentInjector;
705
+ _currentInjector = injector;
706
+ return former;
707
+ }
708
+ function injectInjectorOnly(token, flags = InjectFlags.Default) {
709
+ if (_currentInjector === undefined) {
710
+ throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, ngDevMode &&
711
+ `inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with \`EnvironmentInjector#runInContext\`.`);
712
+ }
713
+ else if (_currentInjector === null) {
714
+ return injectRootLimpMode(token, undefined, flags);
715
+ }
716
+ else {
717
+ return _currentInjector.get(token, flags & InjectFlags.Optional ? null : undefined, flags);
718
+ }
719
+ }
720
+ function ɵɵinject(token, flags = InjectFlags.Default) {
721
+ return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
845
722
  }
846
-
847
723
  /**
848
- * @license
849
- * Copyright Google LLC All Rights Reserved.
724
+ * Throws an error indicating that a factory function could not be generated by the compiler for a
725
+ * particular class.
850
726
  *
851
- * Use of this source code is governed by an MIT-style license that can be
852
- * found in the LICENSE file at https://angular.io/license
853
- */
854
- const NG_COMP_DEF = getClosureSafeProperty({ ɵcmp: getClosureSafeProperty });
855
- const NG_DIR_DEF = getClosureSafeProperty({ ɵdir: getClosureSafeProperty });
856
- const NG_PIPE_DEF = getClosureSafeProperty({ ɵpipe: getClosureSafeProperty });
857
- const NG_MOD_DEF = getClosureSafeProperty({ ɵmod: getClosureSafeProperty });
858
- const NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
859
- /**
860
- * If a directive is diPublic, bloomAdd sets a property on the type with this constant as
861
- * the key and the directive's unique ID as the value. This allows us to map directives to their
862
- * bloom filter bit for DI.
727
+ * The name of the class is not mentioned here, but will be in the generated factory function name
728
+ * and thus in the stack trace.
729
+ *
730
+ * @codeGenApi
863
731
  */
864
- // TODO(misko): This is wrong. The NG_ELEMENT_ID should never be minified.
865
- const NG_ELEMENT_ID = getClosureSafeProperty({ __NG_ELEMENT_ID__: getClosureSafeProperty });
732
+ function ɵɵinvalidFactoryDep(index) {
733
+ throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, ngDevMode &&
734
+ `This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
735
+ This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.
866
736
 
737
+ Please check that 1) the type for the parameter at index ${index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.`);
738
+ }
867
739
  /**
868
- * @license
869
- * Copyright Google LLC All Rights Reserved.
740
+ * Injects a token from the currently active injector.
741
+ * `inject` is only supported during instantiation of a dependency by the DI system. It can be used
742
+ * during:
743
+ * - Construction (via the `constructor`) of a class being instantiated by the DI system, such
744
+ * as an `@Injectable` or `@Component`.
745
+ * - In the initializer for fields of such classes.
746
+ * - In the factory function specified for `useFactory` of a `Provider` or an `@Injectable`.
747
+ * - In the `factory` function specified for an `InjectionToken`.
870
748
  *
871
- * Use of this source code is governed by an MIT-style license that can be
872
- * found in the LICENSE file at https://angular.io/license
873
- */
874
- /** Counter used to generate unique IDs for component definitions. */
875
- let componentDefCount = 0;
876
- /**
877
- * Create a component definition object.
749
+ * @param token A token that represents a dependency that should be injected.
750
+ * @param flags Optional flags that control how injection is executed.
751
+ * The flags correspond to injection strategies that can be specified with
752
+ * parameter decorators `@Host`, `@Self`, `@SkipSef`, and `@Optional`.
753
+ * @returns the injected value if operation is successful, `null` otherwise.
754
+ * @throws if called outside of a supported context.
878
755
  *
756
+ * @usageNotes
757
+ * In practice the `inject()` calls are allowed in a constructor, a constructor parameter and a
758
+ * field initializer:
879
759
  *
880
- * # Example
881
- * ```
882
- * class MyDirective {
883
- * // Generated by Angular Template Compiler
760
+ * ```typescript
761
+ * @Injectable({providedIn: 'root'})
762
+ * export class Car {
763
+ * radio: Radio|undefined;
764
+ * // OK: field initializer
765
+ * spareTyre = inject(Tyre);
766
+ *
767
+ * constructor() {
768
+ * // OK: constructor body
769
+ * this.radio = inject(Radio);
770
+ * }
771
+ * }
772
+ * ```
773
+ *
774
+ * It is also legal to call `inject` from a provider's factory:
775
+ *
776
+ * ```typescript
777
+ * providers: [
778
+ * {provide: Car, useFactory: () => {
779
+ * // OK: a class factory
780
+ * const engine = inject(Engine);
781
+ * return new Car(engine);
782
+ * }}
783
+ * ]
784
+ * ```
785
+ *
786
+ * Calls to the `inject()` function outside of the class creation context will result in error. Most
787
+ * notably, calls to `inject()` are disallowed after a class instance was created, in methods
788
+ * (including lifecycle hooks):
789
+ *
790
+ * ```typescript
791
+ * @Component({ ... })
792
+ * export class CarComponent {
793
+ * ngOnInit() {
794
+ * // ERROR: too late, the component instance was already created
795
+ * const engine = inject(Engine);
796
+ * engine.start();
797
+ * }
798
+ * }
799
+ * ```
800
+ *
801
+ * @publicApi
802
+ */
803
+ function inject(token, flags = InjectFlags.Default) {
804
+ return ɵɵinject(token, convertToBitFlags(flags));
805
+ }
806
+ // Converts object-based DI flags (`InjectOptions`) to bit flags (`InjectFlags`).
807
+ function convertToBitFlags(flags) {
808
+ if (typeof flags === 'undefined' || typeof flags === 'number') {
809
+ return flags;
810
+ }
811
+ // While TypeScript doesn't accept it without a cast, bitwise OR with false-y values in
812
+ // JavaScript is a no-op. We can use that for a very codesize-efficient conversion from
813
+ // `InjectOptions` to `InjectFlags`.
814
+ return (0 /* InternalInjectFlags.Default */ | // comment to force a line break in the formatter
815
+ (flags.optional && 8 /* InternalInjectFlags.Optional */) |
816
+ (flags.host && 1 /* InternalInjectFlags.Host */) |
817
+ (flags.self && 2 /* InternalInjectFlags.Self */) |
818
+ (flags.skipSelf && 4 /* InternalInjectFlags.SkipSelf */));
819
+ }
820
+ function injectArgs(types) {
821
+ const args = [];
822
+ for (let i = 0; i < types.length; i++) {
823
+ const arg = resolveForwardRef(types[i]);
824
+ if (Array.isArray(arg)) {
825
+ if (arg.length === 0) {
826
+ throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, ngDevMode && 'Arguments array must have arguments.');
827
+ }
828
+ let type = undefined;
829
+ let flags = InjectFlags.Default;
830
+ for (let j = 0; j < arg.length; j++) {
831
+ const meta = arg[j];
832
+ const flag = getInjectFlag(meta);
833
+ if (typeof flag === 'number') {
834
+ // Special case when we handle @Inject decorator.
835
+ if (flag === -1 /* DecoratorFlags.Inject */) {
836
+ type = meta.token;
837
+ }
838
+ else {
839
+ flags |= flag;
840
+ }
841
+ }
842
+ else {
843
+ type = meta;
844
+ }
845
+ }
846
+ args.push(ɵɵinject(type, flags));
847
+ }
848
+ else {
849
+ args.push(ɵɵinject(arg));
850
+ }
851
+ }
852
+ return args;
853
+ }
854
+ /**
855
+ * Attaches a given InjectFlag to a given decorator using monkey-patching.
856
+ * Since DI decorators can be used in providers `deps` array (when provider is configured using
857
+ * `useFactory`) without initialization (e.g. `Host`) and as an instance (e.g. `new Host()`), we
858
+ * attach the flag to make it available both as a static property and as a field on decorator
859
+ * instance.
860
+ *
861
+ * @param decorator Provided DI decorator.
862
+ * @param flag InjectFlag that should be applied.
863
+ */
864
+ function attachInjectFlag(decorator, flag) {
865
+ decorator[DI_DECORATOR_FLAG] = flag;
866
+ decorator.prototype[DI_DECORATOR_FLAG] = flag;
867
+ return decorator;
868
+ }
869
+ /**
870
+ * Reads monkey-patched property that contains InjectFlag attached to a decorator.
871
+ *
872
+ * @param token Token that may contain monkey-patched DI flags property.
873
+ */
874
+ function getInjectFlag(token) {
875
+ return token[DI_DECORATOR_FLAG];
876
+ }
877
+ function catchInjectorError(e, token, injectorErrorName, source) {
878
+ const tokenPath = e[NG_TEMP_TOKEN_PATH];
879
+ if (token[SOURCE]) {
880
+ tokenPath.unshift(token[SOURCE]);
881
+ }
882
+ e.message = formatError('\n' + e.message, tokenPath, injectorErrorName, source);
883
+ e[NG_TOKEN_PATH] = tokenPath;
884
+ e[NG_TEMP_TOKEN_PATH] = null;
885
+ throw e;
886
+ }
887
+ function formatError(text, obj, injectorErrorName, source = null) {
888
+ text = text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE ? text.slice(2) : text;
889
+ let context = stringify(obj);
890
+ if (Array.isArray(obj)) {
891
+ context = obj.map(stringify).join(' -> ');
892
+ }
893
+ else if (typeof obj === 'object') {
894
+ let parts = [];
895
+ for (let key in obj) {
896
+ if (obj.hasOwnProperty(key)) {
897
+ let value = obj[key];
898
+ parts.push(key + ':' + (typeof value === 'string' ? JSON.stringify(value) : stringify(value)));
899
+ }
900
+ }
901
+ context = `{${parts.join(', ')}}`;
902
+ }
903
+ return `${injectorErrorName}${source ? '(' + source + ')' : ''}[${context}]: ${text.replace(NEW_LINE, '\n ')}`;
904
+ }
905
+
906
+ /**
907
+ * @license
908
+ * Copyright Google LLC All Rights Reserved.
909
+ *
910
+ * Use of this source code is governed by an MIT-style license that can be
911
+ * found in the LICENSE file at https://angular.io/license
912
+ */
913
+ /**
914
+ * Convince closure compiler that the wrapped function has no side-effects.
915
+ *
916
+ * Closure compiler always assumes that `toString` has no side-effects. We use this quirk to
917
+ * allow us to execute a function but have closure compiler mark the call as no-side-effects.
918
+ * It is important that the return value for the `noSideEffects` function be assigned
919
+ * to something which is retained otherwise the call to `noSideEffects` will be removed by closure
920
+ * compiler.
921
+ */
922
+ function noSideEffects(fn) {
923
+ return { toString: fn }.toString();
924
+ }
925
+
926
+ /**
927
+ * @license
928
+ * Copyright Google LLC All Rights Reserved.
929
+ *
930
+ * Use of this source code is governed by an MIT-style license that can be
931
+ * found in the LICENSE file at https://angular.io/license
932
+ */
933
+ /**
934
+ * The strategy that the default change detector uses to detect changes.
935
+ * When set, takes effect the next time change detection is triggered.
936
+ *
937
+ * @see {@link ChangeDetectorRef#usage-notes Change detection usage}
938
+ *
939
+ * @publicApi
940
+ */
941
+ var ChangeDetectionStrategy;
942
+ (function (ChangeDetectionStrategy) {
943
+ /**
944
+ * Use the `CheckOnce` strategy, meaning that automatic change detection is deactivated
945
+ * until reactivated by setting the strategy to `Default` (`CheckAlways`).
946
+ * Change detection can still be explicitly invoked.
947
+ * This strategy applies to all child directives and cannot be overridden.
948
+ */
949
+ ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 0] = "OnPush";
950
+ /**
951
+ * Use the default `CheckAlways` strategy, in which change detection is automatic until
952
+ * explicitly deactivated.
953
+ */
954
+ ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 1] = "Default";
955
+ })(ChangeDetectionStrategy || (ChangeDetectionStrategy = {}));
956
+ /**
957
+ * Defines the possible states of the default change detector.
958
+ * @see `ChangeDetectorRef`
959
+ */
960
+ var ChangeDetectorStatus;
961
+ (function (ChangeDetectorStatus) {
962
+ /**
963
+ * A state in which, after calling `detectChanges()`, the change detector
964
+ * state becomes `Checked`, and must be explicitly invoked or reactivated.
965
+ */
966
+ ChangeDetectorStatus[ChangeDetectorStatus["CheckOnce"] = 0] = "CheckOnce";
967
+ /**
968
+ * A state in which change detection is skipped until the change detector mode
969
+ * becomes `CheckOnce`.
970
+ */
971
+ ChangeDetectorStatus[ChangeDetectorStatus["Checked"] = 1] = "Checked";
972
+ /**
973
+ * A state in which change detection continues automatically until explicitly
974
+ * deactivated.
975
+ */
976
+ ChangeDetectorStatus[ChangeDetectorStatus["CheckAlways"] = 2] = "CheckAlways";
977
+ /**
978
+ * A state in which a change detector sub tree is not a part of the main tree and
979
+ * should be skipped.
980
+ */
981
+ ChangeDetectorStatus[ChangeDetectorStatus["Detached"] = 3] = "Detached";
982
+ /**
983
+ * Indicates that the change detector encountered an error checking a binding
984
+ * or calling a directive lifecycle method and is now in an inconsistent state. Change
985
+ * detectors in this state do not detect changes.
986
+ */
987
+ ChangeDetectorStatus[ChangeDetectorStatus["Errored"] = 4] = "Errored";
988
+ /**
989
+ * Indicates that the change detector has been destroyed.
990
+ */
991
+ ChangeDetectorStatus[ChangeDetectorStatus["Destroyed"] = 5] = "Destroyed";
992
+ })(ChangeDetectorStatus || (ChangeDetectorStatus = {}));
993
+ /**
994
+ * Reports whether a given strategy is currently the default for change detection.
995
+ * @param changeDetectionStrategy The strategy to check.
996
+ * @returns True if the given strategy is the current default, false otherwise.
997
+ * @see `ChangeDetectorStatus`
998
+ * @see `ChangeDetectorRef`
999
+ */
1000
+ function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
1001
+ return changeDetectionStrategy == null ||
1002
+ changeDetectionStrategy === ChangeDetectionStrategy.Default;
1003
+ }
1004
+
1005
+ /**
1006
+ * @license
1007
+ * Copyright Google LLC All Rights Reserved.
1008
+ *
1009
+ * Use of this source code is governed by an MIT-style license that can be
1010
+ * found in the LICENSE file at https://angular.io/license
1011
+ */
1012
+ /**
1013
+ * Defines the CSS styles encapsulation policies for the {@link Component} decorator's
1014
+ * `encapsulation` option.
1015
+ *
1016
+ * See {@link Component#encapsulation encapsulation}.
1017
+ *
1018
+ * @usageNotes
1019
+ * ### Example
1020
+ *
1021
+ * {@example core/ts/metadata/encapsulation.ts region='longform'}
1022
+ *
1023
+ * @publicApi
1024
+ */
1025
+ var ViewEncapsulation$1;
1026
+ (function (ViewEncapsulation) {
1027
+ // TODO: consider making `ViewEncapsulation` a `const enum` instead. See
1028
+ // https://github.com/angular/angular/issues/44119 for additional information.
1029
+ /**
1030
+ * Emulates a native Shadow DOM encapsulation behavior by adding a specific attribute to the
1031
+ * component's host element and applying the same attribute to all the CSS selectors provided
1032
+ * via {@link Component#styles styles} or {@link Component#styleUrls styleUrls}.
1033
+ *
1034
+ * This is the default option.
1035
+ */
1036
+ ViewEncapsulation[ViewEncapsulation["Emulated"] = 0] = "Emulated";
1037
+ // Historically the 1 value was for `Native` encapsulation which has been removed as of v11.
1038
+ /**
1039
+ * Doesn't provide any sort of CSS style encapsulation, meaning that all the styles provided
1040
+ * via {@link Component#styles styles} or {@link Component#styleUrls styleUrls} are applicable
1041
+ * to any HTML element of the application regardless of their host Component.
1042
+ */
1043
+ ViewEncapsulation[ViewEncapsulation["None"] = 2] = "None";
1044
+ /**
1045
+ * Uses the browser's native Shadow DOM API to encapsulate CSS styles, meaning that it creates
1046
+ * a ShadowRoot for the component's host element which is then used to encapsulate
1047
+ * all the Component's styling.
1048
+ */
1049
+ ViewEncapsulation[ViewEncapsulation["ShadowDom"] = 3] = "ShadowDom";
1050
+ })(ViewEncapsulation$1 || (ViewEncapsulation$1 = {}));
1051
+
1052
+ /**
1053
+ * @license
1054
+ * Copyright Google LLC All Rights Reserved.
1055
+ *
1056
+ * Use of this source code is governed by an MIT-style license that can be
1057
+ * found in the LICENSE file at https://angular.io/license
1058
+ */
1059
+ /**
1060
+ * This file contains reuseable "empty" symbols that can be used as default return values
1061
+ * in different parts of the rendering code. Because the same symbols are returned, this
1062
+ * allows for identity checks against these values to be consistently used by the framework
1063
+ * code.
1064
+ */
1065
+ const EMPTY_OBJ = {};
1066
+ const EMPTY_ARRAY = [];
1067
+ // freezing the values prevents any code from accidentally inserting new values in
1068
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode()) {
1069
+ // These property accesses can be ignored because ngDevMode will be set to false
1070
+ // when optimizing code and the whole if statement will be dropped.
1071
+ // tslint:disable-next-line:no-toplevel-property-access
1072
+ Object.freeze(EMPTY_OBJ);
1073
+ // tslint:disable-next-line:no-toplevel-property-access
1074
+ Object.freeze(EMPTY_ARRAY);
1075
+ }
1076
+
1077
+ /**
1078
+ * @license
1079
+ * Copyright Google LLC All Rights Reserved.
1080
+ *
1081
+ * Use of this source code is governed by an MIT-style license that can be
1082
+ * found in the LICENSE file at https://angular.io/license
1083
+ */
1084
+ const NG_COMP_DEF = getClosureSafeProperty({ ɵcmp: getClosureSafeProperty });
1085
+ const NG_DIR_DEF = getClosureSafeProperty({ ɵdir: getClosureSafeProperty });
1086
+ const NG_PIPE_DEF = getClosureSafeProperty({ ɵpipe: getClosureSafeProperty });
1087
+ const NG_MOD_DEF = getClosureSafeProperty({ ɵmod: getClosureSafeProperty });
1088
+ const NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
1089
+ /**
1090
+ * If a directive is diPublic, bloomAdd sets a property on the type with this constant as
1091
+ * the key and the directive's unique ID as the value. This allows us to map directives to their
1092
+ * bloom filter bit for DI.
1093
+ */
1094
+ // TODO(misko): This is wrong. The NG_ELEMENT_ID should never be minified.
1095
+ const NG_ELEMENT_ID = getClosureSafeProperty({ __NG_ELEMENT_ID__: getClosureSafeProperty });
1096
+
1097
+ /**
1098
+ * @license
1099
+ * Copyright Google LLC All Rights Reserved.
1100
+ *
1101
+ * Use of this source code is governed by an MIT-style license that can be
1102
+ * found in the LICENSE file at https://angular.io/license
1103
+ */
1104
+ /** Counter used to generate unique IDs for component definitions. */
1105
+ let componentDefCount = 0;
1106
+ /**
1107
+ * Create a component definition object.
1108
+ *
1109
+ *
1110
+ * # Example
1111
+ * ```
1112
+ * class MyDirective {
1113
+ * // Generated by Angular Template Compiler
884
1114
  * // [Symbol] syntax will not be supported by TypeScript until v2.7
885
1115
  * static ɵcmp = defineComponent({
886
1116
  * ...
@@ -3595,7 +3825,7 @@ class NodeInjector {
3595
3825
  this._lView = _lView;
3596
3826
  }
3597
3827
  get(token, notFoundValue, flags) {
3598
- return getOrCreateInjectable(this._tNode, this._lView, token, flags, notFoundValue);
3828
+ return getOrCreateInjectable(this._tNode, this._lView, token, convertToBitFlags(flags), notFoundValue);
3599
3829
  }
3600
3830
  }
3601
3831
  /** Creates a `NodeInjector` for the current node. */
@@ -4661,288 +4891,62 @@ class ReflectionCapabilities {
4661
4891
  }
4662
4892
  // API for metadata created by invoking the decorators.
4663
4893
  if (typeOrFunc.hasOwnProperty(PROP_METADATA)) {
4664
- return typeOrFunc[PROP_METADATA];
4665
- }
4666
- return null;
4667
- }
4668
- propMetadata(typeOrFunc) {
4669
- if (!isType(typeOrFunc)) {
4670
- return {};
4671
- }
4672
- const parentCtor = getParentCtor(typeOrFunc);
4673
- const propMetadata = {};
4674
- if (parentCtor !== Object) {
4675
- const parentPropMetadata = this.propMetadata(parentCtor);
4676
- Object.keys(parentPropMetadata).forEach((propName) => {
4677
- propMetadata[propName] = parentPropMetadata[propName];
4678
- });
4679
- }
4680
- const ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
4681
- if (ownPropMetadata) {
4682
- Object.keys(ownPropMetadata).forEach((propName) => {
4683
- const decorators = [];
4684
- if (propMetadata.hasOwnProperty(propName)) {
4685
- decorators.push(...propMetadata[propName]);
4686
- }
4687
- decorators.push(...ownPropMetadata[propName]);
4688
- propMetadata[propName] = decorators;
4689
- });
4690
- }
4691
- return propMetadata;
4692
- }
4693
- ownPropMetadata(typeOrFunc) {
4694
- if (!isType(typeOrFunc)) {
4695
- return {};
4696
- }
4697
- return this._ownPropMetadata(typeOrFunc, getParentCtor(typeOrFunc)) || {};
4698
- }
4699
- hasLifecycleHook(type, lcProperty) {
4700
- return type instanceof Type && lcProperty in type.prototype;
4701
- }
4702
- }
4703
- function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
4704
- if (!decoratorInvocations) {
4705
- return [];
4706
- }
4707
- return decoratorInvocations.map(decoratorInvocation => {
4708
- const decoratorType = decoratorInvocation.type;
4709
- const annotationCls = decoratorType.annotationCls;
4710
- const annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
4711
- return new annotationCls(...annotationArgs);
4712
- });
4713
- }
4714
- function getParentCtor(ctor) {
4715
- const parentProto = ctor.prototype ? Object.getPrototypeOf(ctor.prototype) : null;
4716
- const parentCtor = parentProto ? parentProto.constructor : null;
4717
- // Note: We always use `Object` as the null value
4718
- // to simplify checking later on.
4719
- return parentCtor || Object;
4720
- }
4721
-
4722
- /**
4723
- * @license
4724
- * Copyright Google LLC All Rights Reserved.
4725
- *
4726
- * Use of this source code is governed by an MIT-style license that can be
4727
- * found in the LICENSE file at https://angular.io/license
4728
- */
4729
- const _THROW_IF_NOT_FOUND = {};
4730
- const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
4731
- /*
4732
- * Name of a property (that we patch onto DI decorator), which is used as an annotation of which
4733
- * InjectFlag this decorator represents. This allows to avoid direct references to the DI decorators
4734
- * in the code, thus making them tree-shakable.
4735
- */
4736
- const DI_DECORATOR_FLAG = '__NG_DI_FLAG__';
4737
- const NG_TEMP_TOKEN_PATH = 'ngTempTokenPath';
4738
- const NG_TOKEN_PATH = 'ngTokenPath';
4739
- const NEW_LINE = /\n/gm;
4740
- const NO_NEW_LINE = 'ɵ';
4741
- const SOURCE = '__source';
4742
- /**
4743
- * Current injector value used by `inject`.
4744
- * - `undefined`: it is an error to call `inject`
4745
- * - `null`: `inject` can be called but there is no injector (limp-mode).
4746
- * - Injector instance: Use the injector for resolution.
4747
- */
4748
- let _currentInjector = undefined;
4749
- function setCurrentInjector(injector) {
4750
- const former = _currentInjector;
4751
- _currentInjector = injector;
4752
- return former;
4753
- }
4754
- function injectInjectorOnly(token, flags = InjectFlags.Default) {
4755
- if (_currentInjector === undefined) {
4756
- throw new RuntimeError(-203 /* RuntimeErrorCode.MISSING_INJECTION_CONTEXT */, ngDevMode &&
4757
- `inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with \`EnvironmentInjector#runInContext\`.`);
4758
- }
4759
- else if (_currentInjector === null) {
4760
- return injectRootLimpMode(token, undefined, flags);
4761
- }
4762
- else {
4763
- return _currentInjector.get(token, flags & InjectFlags.Optional ? null : undefined, flags);
4764
- }
4765
- }
4766
- function ɵɵinject(token, flags = InjectFlags.Default) {
4767
- return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
4768
- }
4769
- /**
4770
- * Throws an error indicating that a factory function could not be generated by the compiler for a
4771
- * particular class.
4772
- *
4773
- * The name of the class is not mentioned here, but will be in the generated factory function name
4774
- * and thus in the stack trace.
4775
- *
4776
- * @codeGenApi
4777
- */
4778
- function ɵɵinvalidFactoryDep(index) {
4779
- throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, ngDevMode &&
4780
- `This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
4781
- This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.
4782
-
4783
- Please check that 1) the type for the parameter at index ${index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.`);
4784
- }
4785
- /**
4786
- * Injects a token from the currently active injector.
4787
- * `inject` is only supported during instantiation of a dependency by the DI system. It can be used
4788
- * during:
4789
- * - Construction (via the `constructor`) of a class being instantiated by the DI system, such
4790
- * as an `@Injectable` or `@Component`.
4791
- * - In the initializer for fields of such classes.
4792
- * - In the factory function specified for `useFactory` of a `Provider` or an `@Injectable`.
4793
- * - In the `factory` function specified for an `InjectionToken`.
4794
- *
4795
- * @param token A token that represents a dependency that should be injected.
4796
- * @param flags Optional flags that control how injection is executed.
4797
- * The flags correspond to injection strategies that can be specified with
4798
- * parameter decorators `@Host`, `@Self`, `@SkipSef`, and `@Optional`.
4799
- * @returns the injected value if operation is successful, `null` otherwise.
4800
- * @throws if called outside of a supported context.
4801
- *
4802
- * @usageNotes
4803
- * In practice the `inject()` calls are allowed in a constructor, a constructor parameter and a
4804
- * field initializer:
4805
- *
4806
- * ```typescript
4807
- * @Injectable({providedIn: 'root'})
4808
- * export class Car {
4809
- * radio: Radio|undefined;
4810
- * // OK: field initializer
4811
- * spareTyre = inject(Tyre);
4812
- *
4813
- * constructor() {
4814
- * // OK: constructor body
4815
- * this.radio = inject(Radio);
4816
- * }
4817
- * }
4818
- * ```
4819
- *
4820
- * It is also legal to call `inject` from a provider's factory:
4821
- *
4822
- * ```typescript
4823
- * providers: [
4824
- * {provide: Car, useFactory: () => {
4825
- * // OK: a class factory
4826
- * const engine = inject(Engine);
4827
- * return new Car(engine);
4828
- * }}
4829
- * ]
4830
- * ```
4831
- *
4832
- * Calls to the `inject()` function outside of the class creation context will result in error. Most
4833
- * notably, calls to `inject()` are disallowed after a class instance was created, in methods
4834
- * (including lifecycle hooks):
4835
- *
4836
- * ```typescript
4837
- * @Component({ ... })
4838
- * export class CarComponent {
4839
- * ngOnInit() {
4840
- * // ERROR: too late, the component instance was already created
4841
- * const engine = inject(Engine);
4842
- * engine.start();
4843
- * }
4844
- * }
4845
- * ```
4846
- *
4847
- * @publicApi
4848
- */
4849
- function inject(token, flags = InjectFlags.Default) {
4850
- if (typeof flags !== 'number') {
4851
- // While TypeScript doesn't accept it without a cast, bitwise OR with false-y values in
4852
- // JavaScript is a no-op. We can use that for a very codesize-efficient conversion from
4853
- // `InjectOptions` to `InjectFlags`.
4854
- flags = (0 /* InternalInjectFlags.Default */ | // comment to force a line break in the formatter
4855
- (flags.optional && 8 /* InternalInjectFlags.Optional */) |
4856
- (flags.host && 1 /* InternalInjectFlags.Host */) |
4857
- (flags.self && 2 /* InternalInjectFlags.Self */) |
4858
- (flags.skipSelf && 4 /* InternalInjectFlags.SkipSelf */));
4859
- }
4860
- return ɵɵinject(token, flags);
4861
- }
4862
- function injectArgs(types) {
4863
- const args = [];
4864
- for (let i = 0; i < types.length; i++) {
4865
- const arg = resolveForwardRef(types[i]);
4866
- if (Array.isArray(arg)) {
4867
- if (arg.length === 0) {
4868
- throw new RuntimeError(900 /* RuntimeErrorCode.INVALID_DIFFER_INPUT */, ngDevMode && 'Arguments array must have arguments.');
4869
- }
4870
- let type = undefined;
4871
- let flags = InjectFlags.Default;
4872
- for (let j = 0; j < arg.length; j++) {
4873
- const meta = arg[j];
4874
- const flag = getInjectFlag(meta);
4875
- if (typeof flag === 'number') {
4876
- // Special case when we handle @Inject decorator.
4877
- if (flag === -1 /* DecoratorFlags.Inject */) {
4878
- type = meta.token;
4879
- }
4880
- else {
4881
- flags |= flag;
4882
- }
4883
- }
4884
- else {
4885
- type = meta;
4894
+ return typeOrFunc[PROP_METADATA];
4895
+ }
4896
+ return null;
4897
+ }
4898
+ propMetadata(typeOrFunc) {
4899
+ if (!isType(typeOrFunc)) {
4900
+ return {};
4901
+ }
4902
+ const parentCtor = getParentCtor(typeOrFunc);
4903
+ const propMetadata = {};
4904
+ if (parentCtor !== Object) {
4905
+ const parentPropMetadata = this.propMetadata(parentCtor);
4906
+ Object.keys(parentPropMetadata).forEach((propName) => {
4907
+ propMetadata[propName] = parentPropMetadata[propName];
4908
+ });
4909
+ }
4910
+ const ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
4911
+ if (ownPropMetadata) {
4912
+ Object.keys(ownPropMetadata).forEach((propName) => {
4913
+ const decorators = [];
4914
+ if (propMetadata.hasOwnProperty(propName)) {
4915
+ decorators.push(...propMetadata[propName]);
4886
4916
  }
4887
- }
4888
- args.push(ɵɵinject(type, flags));
4917
+ decorators.push(...ownPropMetadata[propName]);
4918
+ propMetadata[propName] = decorators;
4919
+ });
4889
4920
  }
4890
- else {
4891
- args.push(ɵɵinject(arg));
4921
+ return propMetadata;
4922
+ }
4923
+ ownPropMetadata(typeOrFunc) {
4924
+ if (!isType(typeOrFunc)) {
4925
+ return {};
4892
4926
  }
4927
+ return this._ownPropMetadata(typeOrFunc, getParentCtor(typeOrFunc)) || {};
4893
4928
  }
4894
- return args;
4895
- }
4896
- /**
4897
- * Attaches a given InjectFlag to a given decorator using monkey-patching.
4898
- * Since DI decorators can be used in providers `deps` array (when provider is configured using
4899
- * `useFactory`) without initialization (e.g. `Host`) and as an instance (e.g. `new Host()`), we
4900
- * attach the flag to make it available both as a static property and as a field on decorator
4901
- * instance.
4902
- *
4903
- * @param decorator Provided DI decorator.
4904
- * @param flag InjectFlag that should be applied.
4905
- */
4906
- function attachInjectFlag(decorator, flag) {
4907
- decorator[DI_DECORATOR_FLAG] = flag;
4908
- decorator.prototype[DI_DECORATOR_FLAG] = flag;
4909
- return decorator;
4910
- }
4911
- /**
4912
- * Reads monkey-patched property that contains InjectFlag attached to a decorator.
4913
- *
4914
- * @param token Token that may contain monkey-patched DI flags property.
4915
- */
4916
- function getInjectFlag(token) {
4917
- return token[DI_DECORATOR_FLAG];
4918
- }
4919
- function catchInjectorError(e, token, injectorErrorName, source) {
4920
- const tokenPath = e[NG_TEMP_TOKEN_PATH];
4921
- if (token[SOURCE]) {
4922
- tokenPath.unshift(token[SOURCE]);
4929
+ hasLifecycleHook(type, lcProperty) {
4930
+ return type instanceof Type && lcProperty in type.prototype;
4923
4931
  }
4924
- e.message = formatError('\n' + e.message, tokenPath, injectorErrorName, source);
4925
- e[NG_TOKEN_PATH] = tokenPath;
4926
- e[NG_TEMP_TOKEN_PATH] = null;
4927
- throw e;
4928
4932
  }
4929
- function formatError(text, obj, injectorErrorName, source = null) {
4930
- text = text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE ? text.slice(2) : text;
4931
- let context = stringify(obj);
4932
- if (Array.isArray(obj)) {
4933
- context = obj.map(stringify).join(' -> ');
4934
- }
4935
- else if (typeof obj === 'object') {
4936
- let parts = [];
4937
- for (let key in obj) {
4938
- if (obj.hasOwnProperty(key)) {
4939
- let value = obj[key];
4940
- parts.push(key + ':' + (typeof value === 'string' ? JSON.stringify(value) : stringify(value)));
4941
- }
4942
- }
4943
- context = `{${parts.join(', ')}}`;
4933
+ function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
4934
+ if (!decoratorInvocations) {
4935
+ return [];
4944
4936
  }
4945
- return `${injectorErrorName}${source ? '(' + source + ')' : ''}[${context}]: ${text.replace(NEW_LINE, '\n ')}`;
4937
+ return decoratorInvocations.map(decoratorInvocation => {
4938
+ const decoratorType = decoratorInvocation.type;
4939
+ const annotationCls = decoratorType.annotationCls;
4940
+ const annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
4941
+ return new annotationCls(...annotationArgs);
4942
+ });
4943
+ }
4944
+ function getParentCtor(ctor) {
4945
+ const parentProto = ctor.prototype ? Object.getPrototypeOf(ctor.prototype) : null;
4946
+ const parentCtor = parentProto ? parentProto.constructor : null;
4947
+ // Note: We always use `Object` as the null value
4948
+ // to simplify checking later on.
4949
+ return parentCtor || Object;
4946
4950
  }
4947
4951
 
4948
4952
  /**
@@ -6735,6 +6739,7 @@ class R3Injector extends EnvironmentInjector {
6735
6739
  }
6736
6740
  get(token, notFoundValue = THROW_IF_NOT_FOUND, flags = InjectFlags.Default) {
6737
6741
  this.assertNotDestroyed();
6742
+ flags = convertToBitFlags(flags);
6738
6743
  // Set the injection context.
6739
6744
  const previousInjector = setCurrentInjector(this);
6740
6745
  const previousInjectImplementation = setInjectImplementation(undefined);
@@ -7133,167 +7138,17 @@ class ElementRef {
7133
7138
  /**
7134
7139
  * @internal
7135
7140
  * @nocollapse
7136
- */
7137
- ElementRef.__NG_ELEMENT_ID__ = injectElementRef;
7138
- /**
7139
- * Unwraps `ElementRef` and return the `nativeElement`.
7140
- *
7141
- * @param value value to unwrap
7142
- * @returns `nativeElement` if `ElementRef` otherwise returns value as is.
7143
- */
7144
- function unwrapElementRef(value) {
7145
- return value instanceof ElementRef ? value.nativeElement : value;
7146
- }
7147
-
7148
- /**
7149
- * @license
7150
- * Copyright Google LLC All Rights Reserved.
7151
- *
7152
- * Use of this source code is governed by an MIT-style license that can be
7153
- * found in the LICENSE file at https://angular.io/license
7154
- */
7155
- const Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
7156
- /**
7157
- * Creates and initializes a custom renderer that implements the `Renderer2` base class.
7158
- *
7159
- * @publicApi
7160
- */
7161
- class RendererFactory2 {
7162
- }
7163
- /**
7164
- * Extend this base class to implement custom rendering. By default, Angular
7165
- * renders a template into DOM. You can use custom rendering to intercept
7166
- * rendering calls, or to render to something other than DOM.
7167
- *
7168
- * Create your custom renderer using `RendererFactory2`.
7169
- *
7170
- * Use a custom renderer to bypass Angular's templating and
7171
- * make custom UI changes that can't be expressed declaratively.
7172
- * For example if you need to set a property or an attribute whose name is
7173
- * not statically known, use the `setProperty()` or
7174
- * `setAttribute()` method.
7175
- *
7176
- * @publicApi
7177
- */
7178
- class Renderer2 {
7179
- }
7180
- /**
7181
- * @internal
7182
- * @nocollapse
7183
- */
7184
- Renderer2.__NG_ELEMENT_ID__ = () => injectRenderer2();
7185
- /** Injects a Renderer2 for the current component. */
7186
- function injectRenderer2() {
7187
- // We need the Renderer to be based on the component that it's being injected into, however since
7188
- // DI happens before we've entered its view, `getLView` will return the parent view instead.
7189
- const lView = getLView();
7190
- const tNode = getCurrentTNode();
7191
- const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
7192
- return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
7193
- }
7194
-
7195
- /**
7196
- * @license
7197
- * Copyright Google LLC All Rights Reserved.
7198
- *
7199
- * Use of this source code is governed by an MIT-style license that can be
7200
- * found in the LICENSE file at https://angular.io/license
7201
- */
7202
- /**
7203
- * Sanitizer is used by the views to sanitize potentially dangerous values.
7204
- *
7205
- * @publicApi
7206
- */
7207
- class Sanitizer {
7208
- }
7209
- /** @nocollapse */
7210
- Sanitizer.ɵprov = ɵɵdefineInjectable({
7211
- token: Sanitizer,
7212
- providedIn: 'root',
7213
- factory: () => null,
7214
- });
7215
-
7216
- /**
7217
- * @license
7218
- * Copyright Google LLC All Rights Reserved.
7219
- *
7220
- * Use of this source code is governed by an MIT-style license that can be
7221
- * found in the LICENSE file at https://angular.io/license
7222
- */
7223
- /**
7224
- * @description Represents the version of Angular
7225
- *
7226
- * @publicApi
7227
- */
7228
- class Version {
7229
- constructor(full) {
7230
- this.full = full;
7231
- this.major = full.split('.')[0];
7232
- this.minor = full.split('.')[1];
7233
- this.patch = full.split('.').slice(2).join('.');
7234
- }
7235
- }
7236
- /**
7237
- * @publicApi
7238
- */
7239
- const VERSION = new Version('15.0.0-next.3');
7240
-
7241
- /**
7242
- * @license
7243
- * Copyright Google LLC All Rights Reserved.
7244
- *
7245
- * Use of this source code is governed by an MIT-style license that can be
7246
- * found in the LICENSE file at https://angular.io/license
7247
- */
7248
- // This default value is when checking the hierarchy for a token.
7249
- //
7250
- // It means both:
7251
- // - the token is not provided by the current injector,
7252
- // - only the element injectors should be checked (ie do not check module injectors
7253
- //
7254
- // mod1
7255
- // /
7256
- // el1 mod2
7257
- // \ /
7258
- // el2
7259
- //
7260
- // When requesting el2.injector.get(token), we should check in the following order and return the
7261
- // first found value:
7262
- // - el2.injector.get(token, default)
7263
- // - el1.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) -> do not check the module
7264
- // - mod2.injector.get(token, default)
7265
- const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
7266
-
7267
- /**
7268
- * @license
7269
- * Copyright Google LLC All Rights Reserved.
7270
- *
7271
- * Use of this source code is governed by an MIT-style license that can be
7272
- * found in the LICENSE file at https://angular.io/license
7273
- */
7274
- /**
7275
- * Defines a schema that allows an NgModule to contain the following:
7276
- * - Non-Angular elements named with dash case (`-`).
7277
- * - Element properties named with dash case (`-`).
7278
- * Dash case is the naming convention for custom elements.
7279
- *
7280
- * @publicApi
7281
- */
7282
- const CUSTOM_ELEMENTS_SCHEMA = {
7283
- name: 'custom-elements'
7284
- };
7285
- /**
7286
- * Defines a schema that allows any property on any element.
7287
- *
7288
- * This schema allows you to ignore the errors related to any unknown elements or properties in a
7289
- * template. The usage of this schema is generally discouraged because it prevents useful validation
7290
- * and may hide real errors in your template. Consider using the `CUSTOM_ELEMENTS_SCHEMA` instead.
7141
+ */
7142
+ ElementRef.__NG_ELEMENT_ID__ = injectElementRef;
7143
+ /**
7144
+ * Unwraps `ElementRef` and return the `nativeElement`.
7291
7145
  *
7292
- * @publicApi
7146
+ * @param value value to unwrap
7147
+ * @returns `nativeElement` if `ElementRef` otherwise returns value as is.
7293
7148
  */
7294
- const NO_ERRORS_SCHEMA = {
7295
- name: 'no-errors-schema'
7296
- };
7149
+ function unwrapElementRef(value) {
7150
+ return value instanceof ElementRef ? value.nativeElement : value;
7151
+ }
7297
7152
 
7298
7153
  /**
7299
7154
  * @license
@@ -7302,264 +7157,117 @@ const NO_ERRORS_SCHEMA = {
7302
7157
  * Use of this source code is governed by an MIT-style license that can be
7303
7158
  * found in the LICENSE file at https://angular.io/license
7304
7159
  */
7305
- let shouldThrowErrorOnUnknownElement = false;
7306
- /**
7307
- * Sets a strict mode for JIT-compiled components to throw an error on unknown elements,
7308
- * instead of just logging the error.
7309
- * (for AOT-compiled ones this check happens at build time).
7310
- */
7311
- function ɵsetUnknownElementStrictMode(shouldThrow) {
7312
- shouldThrowErrorOnUnknownElement = shouldThrow;
7313
- }
7314
- /**
7315
- * Gets the current value of the strict mode.
7316
- */
7317
- function ɵgetUnknownElementStrictMode() {
7318
- return shouldThrowErrorOnUnknownElement;
7319
- }
7320
- let shouldThrowErrorOnUnknownProperty = false;
7321
- /**
7322
- * Sets a strict mode for JIT-compiled components to throw an error on unknown properties,
7323
- * instead of just logging the error.
7324
- * (for AOT-compiled ones this check happens at build time).
7325
- */
7326
- function ɵsetUnknownPropertyStrictMode(shouldThrow) {
7327
- shouldThrowErrorOnUnknownProperty = shouldThrow;
7328
- }
7329
- /**
7330
- * Gets the current value of the strict mode.
7331
- */
7332
- function ɵgetUnknownPropertyStrictMode() {
7333
- return shouldThrowErrorOnUnknownProperty;
7334
- }
7160
+ const Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
7335
7161
  /**
7336
- * Validates that the element is known at runtime and produces
7337
- * an error if it's not the case.
7338
- * This check is relevant for JIT-compiled components (for AOT-compiled
7339
- * ones this check happens at build time).
7340
- *
7341
- * The element is considered known if either:
7342
- * - it's a known HTML element
7343
- * - it's a known custom element
7344
- * - the element matches any directive
7345
- * - the element is allowed by one of the schemas
7162
+ * Creates and initializes a custom renderer that implements the `Renderer2` base class.
7346
7163
  *
7347
- * @param element Element to validate
7348
- * @param lView An `LView` that represents a current component that is being rendered
7349
- * @param tagName Name of the tag to check
7350
- * @param schemas Array of schemas
7351
- * @param hasDirectives Boolean indicating that the element matches any directive
7164
+ * @publicApi
7352
7165
  */
7353
- function validateElementIsKnown(element, lView, tagName, schemas, hasDirectives) {
7354
- // If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
7355
- // mode where this check happens at compile time. In JIT mode, `schemas` is always present and
7356
- // defined as an array (as an empty array in case `schemas` field is not defined) and we should
7357
- // execute the check below.
7358
- if (schemas === null)
7359
- return;
7360
- // If the element matches any directive, it's considered as valid.
7361
- if (!hasDirectives && tagName !== null) {
7362
- // The element is unknown if it's an instance of HTMLUnknownElement, or it isn't registered
7363
- // as a custom element. Note that unknown elements with a dash in their name won't be instances
7364
- // of HTMLUnknownElement in browsers that support web components.
7365
- const isUnknown =
7366
- // Note that we can't check for `typeof HTMLUnknownElement === 'function'`,
7367
- // because while most browsers return 'function', IE returns 'object'.
7368
- (typeof HTMLUnknownElement !== 'undefined' && HTMLUnknownElement &&
7369
- element instanceof HTMLUnknownElement) ||
7370
- (typeof customElements !== 'undefined' && tagName.indexOf('-') > -1 &&
7371
- !customElements.get(tagName));
7372
- if (isUnknown && !matchingSchemas(schemas, tagName)) {
7373
- const isHostStandalone = isHostComponentStandalone(lView);
7374
- const templateLocation = getTemplateLocationDetails(lView);
7375
- const schemas = `'${isHostStandalone ? '@Component' : '@NgModule'}.schemas'`;
7376
- let message = `'${tagName}' is not a known element${templateLocation}:\n`;
7377
- message += `1. If '${tagName}' is an Angular component, then verify that it is ${isHostStandalone ? 'included in the \'@Component.imports\' of this component' :
7378
- 'a part of an @NgModule where this component is declared'}.\n`;
7379
- if (tagName && tagName.indexOf('-') > -1) {
7380
- message +=
7381
- `2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas} of this component to suppress this message.`;
7382
- }
7383
- else {
7384
- message +=
7385
- `2. To allow any element add 'NO_ERRORS_SCHEMA' to the ${schemas} of this component.`;
7386
- }
7387
- if (shouldThrowErrorOnUnknownElement) {
7388
- throw new RuntimeError(304 /* RuntimeErrorCode.UNKNOWN_ELEMENT */, message);
7389
- }
7390
- else {
7391
- console.error(formatRuntimeError(304 /* RuntimeErrorCode.UNKNOWN_ELEMENT */, message));
7392
- }
7393
- }
7394
- }
7166
+ class RendererFactory2 {
7395
7167
  }
7396
7168
  /**
7397
- * Validates that the property of the element is known at runtime and returns
7398
- * false if it's not the case.
7399
- * This check is relevant for JIT-compiled components (for AOT-compiled
7400
- * ones this check happens at build time).
7169
+ * Extend this base class to implement custom rendering. By default, Angular
7170
+ * renders a template into DOM. You can use custom rendering to intercept
7171
+ * rendering calls, or to render to something other than DOM.
7401
7172
  *
7402
- * The property is considered known if either:
7403
- * - it's a known property of the element
7404
- * - the element is allowed by one of the schemas
7405
- * - the property is used for animations
7173
+ * Create your custom renderer using `RendererFactory2`.
7406
7174
  *
7407
- * @param element Element to validate
7408
- * @param propName Name of the property to check
7409
- * @param tagName Name of the tag hosting the property
7410
- * @param schemas Array of schemas
7175
+ * Use a custom renderer to bypass Angular's templating and
7176
+ * make custom UI changes that can't be expressed declaratively.
7177
+ * For example if you need to set a property or an attribute whose name is
7178
+ * not statically known, use the `setProperty()` or
7179
+ * `setAttribute()` method.
7180
+ *
7181
+ * @publicApi
7411
7182
  */
7412
- function isPropertyValid(element, propName, tagName, schemas) {
7413
- // If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
7414
- // mode where this check happens at compile time. In JIT mode, `schemas` is always present and
7415
- // defined as an array (as an empty array in case `schemas` field is not defined) and we should
7416
- // execute the check below.
7417
- if (schemas === null)
7418
- return true;
7419
- // The property is considered valid if the element matches the schema, it exists on the element,
7420
- // or it is synthetic, and we are in a browser context (web worker nodes should be skipped).
7421
- if (matchingSchemas(schemas, tagName) || propName in element || isAnimationProp(propName)) {
7422
- return true;
7423
- }
7424
- // Note: `typeof Node` returns 'function' in most browsers, but on IE it is 'object' so we
7425
- // need to account for both here, while being careful with `typeof null` also returning 'object'.
7426
- return typeof Node === 'undefined' || Node === null || !(element instanceof Node);
7183
+ class Renderer2 {
7427
7184
  }
7428
7185
  /**
7429
- * Logs or throws an error that a property is not supported on an element.
7430
- *
7431
- * @param propName Name of the invalid property
7432
- * @param tagName Name of the tag hosting the property
7433
- * @param nodeType Type of the node hosting the property
7434
- * @param lView An `LView` that represents a current component
7186
+ * @internal
7187
+ * @nocollapse
7435
7188
  */
7436
- function handleUnknownPropertyError(propName, tagName, nodeType, lView) {
7437
- // Special-case a situation when a structural directive is applied to
7438
- // an `<ng-template>` element, for example: `<ng-template *ngIf="true">`.
7439
- // In this case the compiler generates the `ɵɵtemplate` instruction with
7440
- // the `null` as the tagName. The directive matching logic at runtime relies
7441
- // on this effect (see `isInlineTemplate`), thus using the 'ng-template' as
7442
- // a default value of the `tNode.value` is not feasible at this moment.
7443
- if (!tagName && nodeType === 4 /* TNodeType.Container */) {
7444
- tagName = 'ng-template';
7445
- }
7446
- const isHostStandalone = isHostComponentStandalone(lView);
7447
- const templateLocation = getTemplateLocationDetails(lView);
7448
- let message = `Can't bind to '${propName}' since it isn't a known property of '${tagName}'${templateLocation}.`;
7449
- const schemas = `'${isHostStandalone ? '@Component' : '@NgModule'}.schemas'`;
7450
- const importLocation = isHostStandalone ?
7451
- 'included in the \'@Component.imports\' of this component' :
7452
- 'a part of an @NgModule where this component is declared';
7453
- if (KNOWN_CONTROL_FLOW_DIRECTIVES.has(propName)) {
7454
- // Most likely this is a control flow directive (such as `*ngIf`) used in
7455
- // a template, but the directive or the `CommonModule` is not imported.
7456
- const correspondingImport = KNOWN_CONTROL_FLOW_DIRECTIVES.get(propName);
7457
- message += `\nIf the '${propName}' is an Angular control flow directive, ` +
7458
- `please make sure that either the '${correspondingImport}' directive or the 'CommonModule' is ${importLocation}.`;
7459
- }
7460
- else {
7461
- // May be an Angular component, which is not imported/declared?
7462
- message += `\n1. If '${tagName}' is an Angular component and it has the ` +
7463
- `'${propName}' input, then verify that it is ${importLocation}.`;
7464
- // May be a Web Component?
7465
- if (tagName && tagName.indexOf('-') > -1) {
7466
- message += `\n2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' ` +
7467
- `to the ${schemas} of this component to suppress this message.`;
7468
- message += `\n3. To allow any property add 'NO_ERRORS_SCHEMA' to ` +
7469
- `the ${schemas} of this component.`;
7470
- }
7471
- else {
7472
- // If it's expected, the error can be suppressed by the `NO_ERRORS_SCHEMA` schema.
7473
- message += `\n2. To allow any property add 'NO_ERRORS_SCHEMA' to ` +
7474
- `the ${schemas} of this component.`;
7475
- }
7476
- }
7477
- reportUnknownPropertyError(message);
7478
- }
7479
- function reportUnknownPropertyError(message) {
7480
- if (shouldThrowErrorOnUnknownProperty) {
7481
- throw new RuntimeError(303 /* RuntimeErrorCode.UNKNOWN_BINDING */, message);
7482
- }
7483
- else {
7484
- console.error(formatRuntimeError(303 /* RuntimeErrorCode.UNKNOWN_BINDING */, message));
7485
- }
7189
+ Renderer2.__NG_ELEMENT_ID__ = () => injectRenderer2();
7190
+ /** Injects a Renderer2 for the current component. */
7191
+ function injectRenderer2() {
7192
+ // We need the Renderer to be based on the component that it's being injected into, however since
7193
+ // DI happens before we've entered its view, `getLView` will return the parent view instead.
7194
+ const lView = getLView();
7195
+ const tNode = getCurrentTNode();
7196
+ const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
7197
+ return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER];
7486
7198
  }
7199
+
7487
7200
  /**
7488
- * WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
7489
- * and must **not** be used in production bundles. The function makes megamorphic reads, which might
7490
- * be too slow for production mode and also it relies on the constructor function being available.
7491
- *
7492
- * Gets a reference to the host component def (where a current component is declared).
7201
+ * @license
7202
+ * Copyright Google LLC All Rights Reserved.
7493
7203
  *
7494
- * @param lView An `LView` that represents a current component that is being rendered.
7204
+ * Use of this source code is governed by an MIT-style license that can be
7205
+ * found in the LICENSE file at https://angular.io/license
7495
7206
  */
7496
- function getDeclarationComponentDef(lView) {
7497
- !ngDevMode && throwError('Must never be called in production mode');
7498
- const declarationLView = lView[DECLARATION_COMPONENT_VIEW];
7499
- const context = declarationLView[CONTEXT];
7500
- // Unable to obtain a context.
7501
- if (!context)
7502
- return null;
7503
- return context.constructor ? getComponentDef(context.constructor) : null;
7504
- }
7505
7207
  /**
7506
- * WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
7507
- * and must **not** be used in production bundles. The function makes megamorphic reads, which might
7508
- * be too slow for production mode.
7509
- *
7510
- * Checks if the current component is declared inside of a standalone component template.
7208
+ * Sanitizer is used by the views to sanitize potentially dangerous values.
7511
7209
  *
7512
- * @param lView An `LView` that represents a current component that is being rendered.
7210
+ * @publicApi
7513
7211
  */
7514
- function isHostComponentStandalone(lView) {
7515
- !ngDevMode && throwError('Must never be called in production mode');
7516
- const componentDef = getDeclarationComponentDef(lView);
7517
- // Treat host component as non-standalone if we can't obtain the def.
7518
- return !!(componentDef === null || componentDef === void 0 ? void 0 : componentDef.standalone);
7212
+ class Sanitizer {
7519
7213
  }
7214
+ /** @nocollapse */
7215
+ Sanitizer.ɵprov = ɵɵdefineInjectable({
7216
+ token: Sanitizer,
7217
+ providedIn: 'root',
7218
+ factory: () => null,
7219
+ });
7220
+
7520
7221
  /**
7521
- * WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
7522
- * and must **not** be used in production bundles. The function makes megamorphic reads, which might
7523
- * be too slow for production mode.
7222
+ * @license
7223
+ * Copyright Google LLC All Rights Reserved.
7524
7224
  *
7525
- * Constructs a string describing the location of the host component template. The function is used
7526
- * in dev mode to produce error messages.
7225
+ * Use of this source code is governed by an MIT-style license that can be
7226
+ * found in the LICENSE file at https://angular.io/license
7227
+ */
7228
+ /**
7229
+ * @description Represents the version of Angular
7527
7230
  *
7528
- * @param lView An `LView` that represents a current component that is being rendered.
7231
+ * @publicApi
7529
7232
  */
7530
- function getTemplateLocationDetails(lView) {
7531
- var _a;
7532
- !ngDevMode && throwError('Must never be called in production mode');
7533
- const hostComponentDef = getDeclarationComponentDef(lView);
7534
- const componentClassName = (_a = hostComponentDef === null || hostComponentDef === void 0 ? void 0 : hostComponentDef.type) === null || _a === void 0 ? void 0 : _a.name;
7535
- return componentClassName ? ` (used in the '${componentClassName}' component template)` : '';
7233
+ class Version {
7234
+ constructor(full) {
7235
+ this.full = full;
7236
+ this.major = full.split('.')[0];
7237
+ this.minor = full.split('.')[1];
7238
+ this.patch = full.split('.').slice(2).join('.');
7239
+ }
7536
7240
  }
7537
7241
  /**
7538
- * The set of known control flow directives and their corresponding imports.
7539
- * We use this set to produce a more precises error message with a note
7540
- * that the `CommonModule` should also be included.
7242
+ * @publicApi
7541
7243
  */
7542
- const KNOWN_CONTROL_FLOW_DIRECTIVES = new Map([
7543
- ['ngIf', 'NgIf'], ['ngFor', 'NgFor'], ['ngSwitchCase', 'NgSwitchCase'],
7544
- ['ngSwitchDefault', 'NgSwitchDefault']
7545
- ]);
7244
+ const VERSION = new Version('15.0.0-next.4');
7245
+
7546
7246
  /**
7547
- * Returns true if the tag name is allowed by specified schemas.
7548
- * @param schemas Array of schemas
7549
- * @param tagName Name of the tag
7247
+ * @license
7248
+ * Copyright Google LLC All Rights Reserved.
7249
+ *
7250
+ * Use of this source code is governed by an MIT-style license that can be
7251
+ * found in the LICENSE file at https://angular.io/license
7550
7252
  */
7551
- function matchingSchemas(schemas, tagName) {
7552
- if (schemas !== null) {
7553
- for (let i = 0; i < schemas.length; i++) {
7554
- const schema = schemas[i];
7555
- if (schema === NO_ERRORS_SCHEMA ||
7556
- schema === CUSTOM_ELEMENTS_SCHEMA && tagName && tagName.indexOf('-') > -1) {
7557
- return true;
7558
- }
7559
- }
7560
- }
7561
- return false;
7562
- }
7253
+ // This default value is when checking the hierarchy for a token.
7254
+ //
7255
+ // It means both:
7256
+ // - the token is not provided by the current injector,
7257
+ // - only the element injectors should be checked (ie do not check module injectors
7258
+ //
7259
+ // mod1
7260
+ // /
7261
+ // el1 mod2
7262
+ // \ /
7263
+ // el2
7264
+ //
7265
+ // When requesting el2.injector.get(token), we should check in the following order and return the
7266
+ // first found value:
7267
+ // - el2.injector.get(token, default)
7268
+ // - el1.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) -> do not check the module
7269
+ // - mod2.injector.get(token, default)
7270
+ const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
7563
7271
 
7564
7272
  /**
7565
7273
  * @license
@@ -7568,15 +7276,28 @@ function matchingSchemas(schemas, tagName) {
7568
7276
  * Use of this source code is governed by an MIT-style license that can be
7569
7277
  * found in the LICENSE file at https://angular.io/license
7570
7278
  */
7571
- const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
7572
- function wrappedError(message, originalError) {
7573
- const msg = `${message} caused by: ${originalError instanceof Error ? originalError.message : originalError}`;
7574
- const error = Error(msg);
7575
- error[ERROR_ORIGINAL_ERROR] = originalError;
7576
- return error;
7279
+ // Keeps track of the currently-active LViews.
7280
+ const TRACKED_LVIEWS = new Map();
7281
+ // Used for generating unique IDs for LViews.
7282
+ let uniqueIdCounter = 0;
7283
+ /** Gets a unique ID that can be assigned to an LView. */
7284
+ function getUniqueLViewId() {
7285
+ return uniqueIdCounter++;
7577
7286
  }
7578
- function getOriginalError(error) {
7579
- return error[ERROR_ORIGINAL_ERROR];
7287
+ /** Starts tracking an LView. */
7288
+ function registerLView(lView) {
7289
+ ngDevMode && assertNumber(lView[ID], 'LView must have an ID in order to be registered');
7290
+ TRACKED_LVIEWS.set(lView[ID], lView);
7291
+ }
7292
+ /** Gets an LView by its unique ID. */
7293
+ function getLViewById(id) {
7294
+ ngDevMode && assertNumber(id, 'ID used for LView lookup must be a number');
7295
+ return TRACKED_LVIEWS.get(id) || null;
7296
+ }
7297
+ /** Stops tracking an LView. */
7298
+ function unregisterLView(lView) {
7299
+ ngDevMode && assertNumber(lView[ID], 'Cannot stop tracking an LView that does not have an ID');
7300
+ TRACKED_LVIEWS.delete(lView[ID]);
7580
7301
  }
7581
7302
 
7582
7303
  /**
@@ -7587,158 +7308,345 @@ function getOriginalError(error) {
7587
7308
  * found in the LICENSE file at https://angular.io/license
7588
7309
  */
7589
7310
  /**
7590
- * Provides a hook for centralized exception handling.
7311
+ * The internal view context which is specific to a given DOM element, directive or
7312
+ * component instance. Each value in here (besides the LView and element node details)
7313
+ * can be present, null or undefined. If undefined then it implies the value has not been
7314
+ * looked up yet, otherwise, if null, then a lookup was executed and nothing was found.
7591
7315
  *
7592
- * The default implementation of `ErrorHandler` prints error messages to the `console`. To
7593
- * intercept error handling, write a custom exception handler that replaces this default as
7594
- * appropriate for your app.
7316
+ * Each value will get filled when the respective value is examined within the getContext
7317
+ * function. The component, element and each directive instance will share the same instance
7318
+ * of the context.
7319
+ */
7320
+ class LContext {
7321
+ constructor(
7322
+ /**
7323
+ * ID of the component's parent view data.
7324
+ */
7325
+ lViewId,
7326
+ /**
7327
+ * The index instance of the node.
7328
+ */
7329
+ nodeIndex,
7330
+ /**
7331
+ * The instance of the DOM node that is attached to the lNode.
7332
+ */
7333
+ native) {
7334
+ this.lViewId = lViewId;
7335
+ this.nodeIndex = nodeIndex;
7336
+ this.native = native;
7337
+ }
7338
+ /** Component's parent view data. */
7339
+ get lView() {
7340
+ return getLViewById(this.lViewId);
7341
+ }
7342
+ }
7343
+
7344
+ /**
7345
+ * @license
7346
+ * Copyright Google LLC All Rights Reserved.
7595
7347
  *
7596
- * @usageNotes
7597
- * ### Example
7348
+ * Use of this source code is governed by an MIT-style license that can be
7349
+ * found in the LICENSE file at https://angular.io/license
7350
+ */
7351
+ /**
7352
+ * Returns the matching `LContext` data for a given DOM node, directive or component instance.
7598
7353
  *
7599
- * ```
7600
- * class MyErrorHandler implements ErrorHandler {
7601
- * handleError(error) {
7602
- * // do something with the exception
7603
- * }
7604
- * }
7354
+ * This function will examine the provided DOM element, component, or directive instance\'s
7355
+ * monkey-patched property to derive the `LContext` data. Once called then the monkey-patched
7356
+ * value will be that of the newly created `LContext`.
7605
7357
  *
7606
- * @NgModule({
7607
- * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
7608
- * })
7609
- * class MyModule {}
7610
- * ```
7358
+ * If the monkey-patched value is the `LView` instance then the context value for that
7359
+ * target will be created and the monkey-patch reference will be updated. Therefore when this
7360
+ * function is called it may mutate the provided element\'s, component\'s or any of the associated
7361
+ * directive\'s monkey-patch values.
7611
7362
  *
7612
- * @publicApi
7363
+ * If the monkey-patch value is not detected then the code will walk up the DOM until an element
7364
+ * is found which contains a monkey-patch reference. When that occurs then the provided element
7365
+ * will be updated with a new context (which is then returned). If the monkey-patch value is not
7366
+ * detected for a component/directive instance then it will throw an error (all components and
7367
+ * directives should be automatically monkey-patched by ivy).
7368
+ *
7369
+ * @param target Component, Directive or DOM Node.
7613
7370
  */
7614
- class ErrorHandler {
7615
- constructor() {
7616
- /**
7617
- * @internal
7618
- */
7619
- this._console = console;
7620
- }
7621
- handleError(error) {
7622
- const originalError = this._findOriginalError(error);
7623
- this._console.error('ERROR', error);
7624
- if (originalError) {
7625
- this._console.error('ORIGINAL ERROR', originalError);
7371
+ function getLContext(target) {
7372
+ let mpValue = readPatchedData(target);
7373
+ if (mpValue) {
7374
+ // only when it's an array is it considered an LView instance
7375
+ // ... otherwise it's an already constructed LContext instance
7376
+ if (isLView(mpValue)) {
7377
+ const lView = mpValue;
7378
+ let nodeIndex;
7379
+ let component = undefined;
7380
+ let directives = undefined;
7381
+ if (isComponentInstance(target)) {
7382
+ nodeIndex = findViaComponent(lView, target);
7383
+ if (nodeIndex == -1) {
7384
+ throw new Error('The provided component was not found in the application');
7385
+ }
7386
+ component = target;
7387
+ }
7388
+ else if (isDirectiveInstance(target)) {
7389
+ nodeIndex = findViaDirective(lView, target);
7390
+ if (nodeIndex == -1) {
7391
+ throw new Error('The provided directive was not found in the application');
7392
+ }
7393
+ directives = getDirectivesAtNodeIndex(nodeIndex, lView);
7394
+ }
7395
+ else {
7396
+ nodeIndex = findViaNativeElement(lView, target);
7397
+ if (nodeIndex == -1) {
7398
+ return null;
7399
+ }
7400
+ }
7401
+ // the goal is not to fill the entire context full of data because the lookups
7402
+ // are expensive. Instead, only the target data (the element, component, container, ICU
7403
+ // expression or directive details) are filled into the context. If called multiple times
7404
+ // with different target values then the missing target data will be filled in.
7405
+ const native = unwrapRNode(lView[nodeIndex]);
7406
+ const existingCtx = readPatchedData(native);
7407
+ const context = (existingCtx && !Array.isArray(existingCtx)) ?
7408
+ existingCtx :
7409
+ createLContext(lView, nodeIndex, native);
7410
+ // only when the component has been discovered then update the monkey-patch
7411
+ if (component && context.component === undefined) {
7412
+ context.component = component;
7413
+ attachPatchData(context.component, context);
7414
+ }
7415
+ // only when the directives have been discovered then update the monkey-patch
7416
+ if (directives && context.directives === undefined) {
7417
+ context.directives = directives;
7418
+ for (let i = 0; i < directives.length; i++) {
7419
+ attachPatchData(directives[i], context);
7420
+ }
7421
+ }
7422
+ attachPatchData(context.native, context);
7423
+ mpValue = context;
7626
7424
  }
7627
7425
  }
7628
- /** @internal */
7629
- _findOriginalError(error) {
7630
- let e = error && getOriginalError(error);
7631
- while (e && getOriginalError(e)) {
7632
- e = getOriginalError(e);
7426
+ else {
7427
+ const rElement = target;
7428
+ ngDevMode && assertDomNode(rElement);
7429
+ // if the context is not found then we need to traverse upwards up the DOM
7430
+ // to find the nearest element that has already been monkey patched with data
7431
+ let parent = rElement;
7432
+ while (parent = parent.parentNode) {
7433
+ const parentContext = readPatchedData(parent);
7434
+ if (parentContext) {
7435
+ const lView = Array.isArray(parentContext) ? parentContext : parentContext.lView;
7436
+ // the edge of the app was also reached here through another means
7437
+ // (maybe because the DOM was changed manually).
7438
+ if (!lView) {
7439
+ return null;
7440
+ }
7441
+ const index = findViaNativeElement(lView, rElement);
7442
+ if (index >= 0) {
7443
+ const native = unwrapRNode(lView[index]);
7444
+ const context = createLContext(lView, index, native);
7445
+ attachPatchData(native, context);
7446
+ mpValue = context;
7447
+ break;
7448
+ }
7449
+ }
7633
7450
  }
7634
- return e || null;
7635
7451
  }
7452
+ return mpValue || null;
7636
7453
  }
7637
-
7638
7454
  /**
7639
- * @license
7640
- * Copyright Google LLC All Rights Reserved.
7641
- *
7642
- * Use of this source code is governed by an MIT-style license that can be
7643
- * found in the LICENSE file at https://angular.io/license
7455
+ * Creates an empty instance of a `LContext` context
7644
7456
  */
7457
+ function createLContext(lView, nodeIndex, native) {
7458
+ return new LContext(lView[ID], nodeIndex, native);
7459
+ }
7645
7460
  /**
7646
- * Disallowed strings in the comment.
7461
+ * Takes a component instance and returns the view for that component.
7647
7462
  *
7648
- * see: https://html.spec.whatwg.org/multipage/syntax.html#comments
7463
+ * @param componentInstance
7464
+ * @returns The component's view
7649
7465
  */
7650
- const COMMENT_DISALLOWED = /^>|^->|<!--|-->|--!>|<!-$/g;
7466
+ function getComponentViewByInstance(componentInstance) {
7467
+ let patchedData = readPatchedData(componentInstance);
7468
+ let lView;
7469
+ if (isLView(patchedData)) {
7470
+ const contextLView = patchedData;
7471
+ const nodeIndex = findViaComponent(contextLView, componentInstance);
7472
+ lView = getComponentLViewByIndex(nodeIndex, contextLView);
7473
+ const context = createLContext(contextLView, nodeIndex, lView[HOST]);
7474
+ context.component = componentInstance;
7475
+ attachPatchData(componentInstance, context);
7476
+ attachPatchData(context.native, context);
7477
+ }
7478
+ else {
7479
+ const context = patchedData;
7480
+ const contextLView = context.lView;
7481
+ ngDevMode && assertLView(contextLView);
7482
+ lView = getComponentLViewByIndex(context.nodeIndex, contextLView);
7483
+ }
7484
+ return lView;
7485
+ }
7651
7486
  /**
7652
- * Delimiter in the disallowed strings which needs to be wrapped with zero with character.
7487
+ * This property will be monkey-patched on elements, components and directives.
7653
7488
  */
7654
- const COMMENT_DELIMITER = /(<|>)/;
7655
- const COMMENT_DELIMITER_ESCAPED = '\u200B$1\u200B';
7489
+ const MONKEY_PATCH_KEY_NAME = '__ngContext__';
7656
7490
  /**
7657
- * Escape the content of comment strings so that it can be safely inserted into a comment node.
7658
- *
7659
- * The issue is that HTML does not specify any way to escape comment end text inside the comment.
7660
- * Consider: `<!-- The way you close a comment is with ">", and "->" at the beginning or by "-->" or
7661
- * "--!>" at the end. -->`. Above the `"-->"` is meant to be text not an end to the comment. This
7662
- * can be created programmatically through DOM APIs. (`<!--` are also disallowed.)
7663
- *
7664
- * see: https://html.spec.whatwg.org/multipage/syntax.html#comments
7665
- *
7666
- * ```
7667
- * div.innerHTML = div.innerHTML
7668
- * ```
7669
- *
7670
- * One would expect that the above code would be safe to do, but it turns out that because comment
7671
- * text is not escaped, the comment may contain text which will prematurely close the comment
7672
- * opening up the application for XSS attack. (In SSR we programmatically create comment nodes which
7673
- * may contain such text and expect them to be safe.)
7674
- *
7675
- * This function escapes the comment text by looking for comment delimiters (`<` and `>`) and
7676
- * surrounding them with `_>_` where the `_` is a zero width space `\u200B`. The result is that if a
7677
- * comment contains any of the comment start/end delimiters (such as `<!--`, `-->` or `--!>`) the
7678
- * text it will render normally but it will not cause the HTML parser to close/open the comment.
7679
- *
7680
- * @param value text to make safe for comment node by escaping the comment open/close character
7681
- * sequence.
7491
+ * Assigns the given data to the given target (which could be a component,
7492
+ * directive or DOM node instance) using monkey-patching.
7682
7493
  */
7683
- function escapeCommentText(value) {
7684
- return value.replace(COMMENT_DISALLOWED, (text) => text.replace(COMMENT_DELIMITER, COMMENT_DELIMITER_ESCAPED));
7494
+ function attachPatchData(target, data) {
7495
+ ngDevMode && assertDefined(target, 'Target expected');
7496
+ // Only attach the ID of the view in order to avoid memory leaks (see #41047). We only do this
7497
+ // for `LView`, because we have control over when an `LView` is created and destroyed, whereas
7498
+ // we can't know when to remove an `LContext`.
7499
+ if (isLView(data)) {
7500
+ target[MONKEY_PATCH_KEY_NAME] = data[ID];
7501
+ registerLView(data);
7502
+ }
7503
+ else {
7504
+ target[MONKEY_PATCH_KEY_NAME] = data;
7505
+ }
7685
7506
  }
7686
-
7687
7507
  /**
7688
- * @license
7689
- * Copyright Google LLC All Rights Reserved.
7690
- *
7691
- * Use of this source code is governed by an MIT-style license that can be
7692
- * found in the LICENSE file at https://angular.io/license
7508
+ * Returns the monkey-patch value data present on the target (which could be
7509
+ * a component, directive or a DOM node).
7693
7510
  */
7694
- function normalizeDebugBindingName(name) {
7695
- // Attribute names with `$` (eg `x-y$`) are valid per spec, but unsupported by some browsers
7696
- name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
7697
- return `ng-reflect-${name}`;
7511
+ function readPatchedData(target) {
7512
+ ngDevMode && assertDefined(target, 'Target expected');
7513
+ const data = target[MONKEY_PATCH_KEY_NAME];
7514
+ return (typeof data === 'number') ? getLViewById(data) : data || null;
7698
7515
  }
7699
- const CAMEL_CASE_REGEXP = /([A-Z])/g;
7700
- function camelCaseToDashCase(input) {
7701
- return input.replace(CAMEL_CASE_REGEXP, (...m) => '-' + m[1].toLowerCase());
7516
+ function readPatchedLView(target) {
7517
+ const value = readPatchedData(target);
7518
+ if (value) {
7519
+ return (isLView(value) ? value : value.lView);
7520
+ }
7521
+ return null;
7702
7522
  }
7703
- function normalizeDebugBindingValue(value) {
7704
- try {
7705
- // Limit the size of the value as otherwise the DOM just gets polluted.
7706
- return value != null ? value.toString().slice(0, 30) : value;
7523
+ function isComponentInstance(instance) {
7524
+ return instance && instance.constructor && instance.constructor.ɵcmp;
7525
+ }
7526
+ function isDirectiveInstance(instance) {
7527
+ return instance && instance.constructor && instance.constructor.ɵdir;
7528
+ }
7529
+ /**
7530
+ * Locates the element within the given LView and returns the matching index
7531
+ */
7532
+ function findViaNativeElement(lView, target) {
7533
+ const tView = lView[TVIEW];
7534
+ for (let i = HEADER_OFFSET; i < tView.bindingStartIndex; i++) {
7535
+ if (unwrapRNode(lView[i]) === target) {
7536
+ return i;
7537
+ }
7707
7538
  }
7708
- catch (e) {
7709
- return '[ERROR] Exception while trying to serialize the value';
7539
+ return -1;
7540
+ }
7541
+ /**
7542
+ * Locates the next tNode (child, sibling or parent).
7543
+ */
7544
+ function traverseNextElement(tNode) {
7545
+ if (tNode.child) {
7546
+ return tNode.child;
7547
+ }
7548
+ else if (tNode.next) {
7549
+ return tNode.next;
7550
+ }
7551
+ else {
7552
+ // Let's take the following template: <div><span>text</span></div><component/>
7553
+ // After checking the text node, we need to find the next parent that has a "next" TNode,
7554
+ // in this case the parent `div`, so that we can find the component.
7555
+ while (tNode.parent && !tNode.parent.next) {
7556
+ tNode = tNode.parent;
7557
+ }
7558
+ return tNode.parent && tNode.parent.next;
7710
7559
  }
7711
7560
  }
7712
-
7713
7561
  /**
7714
- * @license
7715
- * Copyright Google LLC All Rights Reserved.
7716
- *
7717
- * Use of this source code is governed by an MIT-style license that can be
7718
- * found in the LICENSE file at https://angular.io/license
7562
+ * Locates the component within the given LView and returns the matching index
7719
7563
  */
7720
- // Keeps track of the currently-active LViews.
7721
- const TRACKED_LVIEWS = new Map();
7722
- // Used for generating unique IDs for LViews.
7723
- let uniqueIdCounter = 0;
7724
- /** Gets a unique ID that can be assigned to an LView. */
7725
- function getUniqueLViewId() {
7726
- return uniqueIdCounter++;
7564
+ function findViaComponent(lView, componentInstance) {
7565
+ const componentIndices = lView[TVIEW].components;
7566
+ if (componentIndices) {
7567
+ for (let i = 0; i < componentIndices.length; i++) {
7568
+ const elementComponentIndex = componentIndices[i];
7569
+ const componentView = getComponentLViewByIndex(elementComponentIndex, lView);
7570
+ if (componentView[CONTEXT] === componentInstance) {
7571
+ return elementComponentIndex;
7572
+ }
7573
+ }
7574
+ }
7575
+ else {
7576
+ const rootComponentView = getComponentLViewByIndex(HEADER_OFFSET, lView);
7577
+ const rootComponent = rootComponentView[CONTEXT];
7578
+ if (rootComponent === componentInstance) {
7579
+ // we are dealing with the root element here therefore we know that the
7580
+ // element is the very first element after the HEADER data in the lView
7581
+ return HEADER_OFFSET;
7582
+ }
7583
+ }
7584
+ return -1;
7727
7585
  }
7728
- /** Starts tracking an LView. */
7729
- function registerLView(lView) {
7730
- ngDevMode && assertNumber(lView[ID], 'LView must have an ID in order to be registered');
7731
- TRACKED_LVIEWS.set(lView[ID], lView);
7586
+ /**
7587
+ * Locates the directive within the given LView and returns the matching index
7588
+ */
7589
+ function findViaDirective(lView, directiveInstance) {
7590
+ // if a directive is monkey patched then it will (by default)
7591
+ // have a reference to the LView of the current view. The
7592
+ // element bound to the directive being search lives somewhere
7593
+ // in the view data. We loop through the nodes and check their
7594
+ // list of directives for the instance.
7595
+ let tNode = lView[TVIEW].firstChild;
7596
+ while (tNode) {
7597
+ const directiveIndexStart = tNode.directiveStart;
7598
+ const directiveIndexEnd = tNode.directiveEnd;
7599
+ for (let i = directiveIndexStart; i < directiveIndexEnd; i++) {
7600
+ if (lView[i] === directiveInstance) {
7601
+ return tNode.index;
7602
+ }
7603
+ }
7604
+ tNode = traverseNextElement(tNode);
7605
+ }
7606
+ return -1;
7732
7607
  }
7733
- /** Gets an LView by its unique ID. */
7734
- function getLViewById(id) {
7735
- ngDevMode && assertNumber(id, 'ID used for LView lookup must be a number');
7736
- return TRACKED_LVIEWS.get(id) || null;
7608
+ /**
7609
+ * Returns a list of directives applied to a node at a specific index. The list includes
7610
+ * directives matched by selector and any host directives, but it excludes components.
7611
+ * Use `getComponentAtNodeIndex` to find the component applied to a node.
7612
+ *
7613
+ * @param nodeIndex The node index
7614
+ * @param lView The target view data
7615
+ */
7616
+ function getDirectivesAtNodeIndex(nodeIndex, lView) {
7617
+ const tNode = lView[TVIEW].data[nodeIndex];
7618
+ if (tNode.directiveStart === 0)
7619
+ return EMPTY_ARRAY;
7620
+ const results = [];
7621
+ for (let i = tNode.directiveStart; i < tNode.directiveEnd; i++) {
7622
+ const directiveInstance = lView[i];
7623
+ if (!isComponentInstance(directiveInstance)) {
7624
+ results.push(directiveInstance);
7625
+ }
7626
+ }
7627
+ return results;
7737
7628
  }
7738
- /** Stops tracking an LView. */
7739
- function unregisterLView(lView) {
7740
- ngDevMode && assertNumber(lView[ID], 'Cannot stop tracking an LView that does not have an ID');
7741
- TRACKED_LVIEWS.delete(lView[ID]);
7629
+ function getComponentAtNodeIndex(nodeIndex, lView) {
7630
+ const tNode = lView[TVIEW].data[nodeIndex];
7631
+ const { directiveStart, componentOffset } = tNode;
7632
+ return componentOffset > -1 ? lView[directiveStart + componentOffset] : null;
7633
+ }
7634
+ /**
7635
+ * Returns a map of local references (local reference name => element or directive instance) that
7636
+ * exist on a given element.
7637
+ */
7638
+ function discoverLocalRefs(lView, nodeIndex) {
7639
+ const tNode = lView[TVIEW].data[nodeIndex];
7640
+ if (tNode && tNode.localNames) {
7641
+ const result = {};
7642
+ let localIndex = tNode.index + 1;
7643
+ for (let i = 0; i < tNode.localNames.length; i += 2) {
7644
+ result[tNode.localNames[i]] = lView[localIndex];
7645
+ localIndex++;
7646
+ }
7647
+ return result;
7648
+ }
7649
+ return null;
7742
7650
  }
7743
7651
 
7744
7652
  /**
@@ -7749,38 +7657,28 @@ function unregisterLView(lView) {
7749
7657
  * found in the LICENSE file at https://angular.io/license
7750
7658
  */
7751
7659
  /**
7752
- * The internal view context which is specific to a given DOM element, directive or
7753
- * component instance. Each value in here (besides the LView and element node details)
7754
- * can be present, null or undefined. If undefined then it implies the value has not been
7755
- * looked up yet, otherwise, if null, then a lookup was executed and nothing was found.
7660
+ * Defines a schema that allows an NgModule to contain the following:
7661
+ * - Non-Angular elements named with dash case (`-`).
7662
+ * - Element properties named with dash case (`-`).
7663
+ * Dash case is the naming convention for custom elements.
7756
7664
  *
7757
- * Each value will get filled when the respective value is examined within the getContext
7758
- * function. The component, element and each directive instance will share the same instance
7759
- * of the context.
7665
+ * @publicApi
7760
7666
  */
7761
- class LContext {
7762
- constructor(
7763
- /**
7764
- * ID of the component's parent view data.
7765
- */
7766
- lViewId,
7767
- /**
7768
- * The index instance of the node.
7769
- */
7770
- nodeIndex,
7771
- /**
7772
- * The instance of the DOM node that is attached to the lNode.
7773
- */
7774
- native) {
7775
- this.lViewId = lViewId;
7776
- this.nodeIndex = nodeIndex;
7777
- this.native = native;
7778
- }
7779
- /** Component's parent view data. */
7780
- get lView() {
7781
- return getLViewById(this.lViewId);
7782
- }
7783
- }
7667
+ const CUSTOM_ELEMENTS_SCHEMA = {
7668
+ name: 'custom-elements'
7669
+ };
7670
+ /**
7671
+ * Defines a schema that allows any property on any element.
7672
+ *
7673
+ * This schema allows you to ignore the errors related to any unknown elements or properties in a
7674
+ * template. The usage of this schema is generally discouraged because it prevents useful validation
7675
+ * and may hide real errors in your template. Consider using the `CUSTOM_ELEMENTS_SCHEMA` instead.
7676
+ *
7677
+ * @publicApi
7678
+ */
7679
+ const NO_ERRORS_SCHEMA = {
7680
+ name: 'no-errors-schema'
7681
+ };
7784
7682
 
7785
7683
  /**
7786
7684
  * @license
@@ -7789,305 +7687,412 @@ class LContext {
7789
7687
  * Use of this source code is governed by an MIT-style license that can be
7790
7688
  * found in the LICENSE file at https://angular.io/license
7791
7689
  */
7690
+ let shouldThrowErrorOnUnknownElement = false;
7792
7691
  /**
7793
- * Returns the matching `LContext` data for a given DOM node, directive or component instance.
7794
- *
7795
- * This function will examine the provided DOM element, component, or directive instance\'s
7796
- * monkey-patched property to derive the `LContext` data. Once called then the monkey-patched
7797
- * value will be that of the newly created `LContext`.
7798
- *
7799
- * If the monkey-patched value is the `LView` instance then the context value for that
7800
- * target will be created and the monkey-patch reference will be updated. Therefore when this
7801
- * function is called it may mutate the provided element\'s, component\'s or any of the associated
7802
- * directive\'s monkey-patch values.
7692
+ * Sets a strict mode for JIT-compiled components to throw an error on unknown elements,
7693
+ * instead of just logging the error.
7694
+ * (for AOT-compiled ones this check happens at build time).
7695
+ */
7696
+ function ɵsetUnknownElementStrictMode(shouldThrow) {
7697
+ shouldThrowErrorOnUnknownElement = shouldThrow;
7698
+ }
7699
+ /**
7700
+ * Gets the current value of the strict mode.
7701
+ */
7702
+ function ɵgetUnknownElementStrictMode() {
7703
+ return shouldThrowErrorOnUnknownElement;
7704
+ }
7705
+ let shouldThrowErrorOnUnknownProperty = false;
7706
+ /**
7707
+ * Sets a strict mode for JIT-compiled components to throw an error on unknown properties,
7708
+ * instead of just logging the error.
7709
+ * (for AOT-compiled ones this check happens at build time).
7710
+ */
7711
+ function ɵsetUnknownPropertyStrictMode(shouldThrow) {
7712
+ shouldThrowErrorOnUnknownProperty = shouldThrow;
7713
+ }
7714
+ /**
7715
+ * Gets the current value of the strict mode.
7716
+ */
7717
+ function ɵgetUnknownPropertyStrictMode() {
7718
+ return shouldThrowErrorOnUnknownProperty;
7719
+ }
7720
+ /**
7721
+ * Validates that the element is known at runtime and produces
7722
+ * an error if it's not the case.
7723
+ * This check is relevant for JIT-compiled components (for AOT-compiled
7724
+ * ones this check happens at build time).
7803
7725
  *
7804
- * If the monkey-patch value is not detected then the code will walk up the DOM until an element
7805
- * is found which contains a monkey-patch reference. When that occurs then the provided element
7806
- * will be updated with a new context (which is then returned). If the monkey-patch value is not
7807
- * detected for a component/directive instance then it will throw an error (all components and
7808
- * directives should be automatically monkey-patched by ivy).
7726
+ * The element is considered known if either:
7727
+ * - it's a known HTML element
7728
+ * - it's a known custom element
7729
+ * - the element matches any directive
7730
+ * - the element is allowed by one of the schemas
7809
7731
  *
7810
- * @param target Component, Directive or DOM Node.
7732
+ * @param element Element to validate
7733
+ * @param lView An `LView` that represents a current component that is being rendered
7734
+ * @param tagName Name of the tag to check
7735
+ * @param schemas Array of schemas
7736
+ * @param hasDirectives Boolean indicating that the element matches any directive
7811
7737
  */
7812
- function getLContext(target) {
7813
- let mpValue = readPatchedData(target);
7814
- if (mpValue) {
7815
- // only when it's an array is it considered an LView instance
7816
- // ... otherwise it's an already constructed LContext instance
7817
- if (isLView(mpValue)) {
7818
- const lView = mpValue;
7819
- let nodeIndex;
7820
- let component = undefined;
7821
- let directives = undefined;
7822
- if (isComponentInstance(target)) {
7823
- nodeIndex = findViaComponent(lView, target);
7824
- if (nodeIndex == -1) {
7825
- throw new Error('The provided component was not found in the application');
7826
- }
7827
- component = target;
7828
- }
7829
- else if (isDirectiveInstance(target)) {
7830
- nodeIndex = findViaDirective(lView, target);
7831
- if (nodeIndex == -1) {
7832
- throw new Error('The provided directive was not found in the application');
7833
- }
7834
- directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
7738
+ function validateElementIsKnown(element, lView, tagName, schemas, hasDirectives) {
7739
+ // If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
7740
+ // mode where this check happens at compile time. In JIT mode, `schemas` is always present and
7741
+ // defined as an array (as an empty array in case `schemas` field is not defined) and we should
7742
+ // execute the check below.
7743
+ if (schemas === null)
7744
+ return;
7745
+ // If the element matches any directive, it's considered as valid.
7746
+ if (!hasDirectives && tagName !== null) {
7747
+ // The element is unknown if it's an instance of HTMLUnknownElement, or it isn't registered
7748
+ // as a custom element. Note that unknown elements with a dash in their name won't be instances
7749
+ // of HTMLUnknownElement in browsers that support web components.
7750
+ const isUnknown =
7751
+ // Note that we can't check for `typeof HTMLUnknownElement === 'function'`,
7752
+ // because while most browsers return 'function', IE returns 'object'.
7753
+ (typeof HTMLUnknownElement !== 'undefined' && HTMLUnknownElement &&
7754
+ element instanceof HTMLUnknownElement) ||
7755
+ (typeof customElements !== 'undefined' && tagName.indexOf('-') > -1 &&
7756
+ !customElements.get(tagName));
7757
+ if (isUnknown && !matchingSchemas(schemas, tagName)) {
7758
+ const isHostStandalone = isHostComponentStandalone(lView);
7759
+ const templateLocation = getTemplateLocationDetails(lView);
7760
+ const schemas = `'${isHostStandalone ? '@Component' : '@NgModule'}.schemas'`;
7761
+ let message = `'${tagName}' is not a known element${templateLocation}:\n`;
7762
+ message += `1. If '${tagName}' is an Angular component, then verify that it is ${isHostStandalone ? 'included in the \'@Component.imports\' of this component' :
7763
+ 'a part of an @NgModule where this component is declared'}.\n`;
7764
+ if (tagName && tagName.indexOf('-') > -1) {
7765
+ message +=
7766
+ `2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas} of this component to suppress this message.`;
7835
7767
  }
7836
7768
  else {
7837
- nodeIndex = findViaNativeElement(lView, target);
7838
- if (nodeIndex == -1) {
7839
- return null;
7840
- }
7841
- }
7842
- // the goal is not to fill the entire context full of data because the lookups
7843
- // are expensive. Instead, only the target data (the element, component, container, ICU
7844
- // expression or directive details) are filled into the context. If called multiple times
7845
- // with different target values then the missing target data will be filled in.
7846
- const native = unwrapRNode(lView[nodeIndex]);
7847
- const existingCtx = readPatchedData(native);
7848
- const context = (existingCtx && !Array.isArray(existingCtx)) ?
7849
- existingCtx :
7850
- createLContext(lView, nodeIndex, native);
7851
- // only when the component has been discovered then update the monkey-patch
7852
- if (component && context.component === undefined) {
7853
- context.component = component;
7854
- attachPatchData(context.component, context);
7769
+ message +=
7770
+ `2. To allow any element add 'NO_ERRORS_SCHEMA' to the ${schemas} of this component.`;
7855
7771
  }
7856
- // only when the directives have been discovered then update the monkey-patch
7857
- if (directives && context.directives === undefined) {
7858
- context.directives = directives;
7859
- for (let i = 0; i < directives.length; i++) {
7860
- attachPatchData(directives[i], context);
7861
- }
7772
+ if (shouldThrowErrorOnUnknownElement) {
7773
+ throw new RuntimeError(304 /* RuntimeErrorCode.UNKNOWN_ELEMENT */, message);
7862
7774
  }
7863
- attachPatchData(context.native, context);
7864
- mpValue = context;
7865
- }
7866
- }
7867
- else {
7868
- const rElement = target;
7869
- ngDevMode && assertDomNode(rElement);
7870
- // if the context is not found then we need to traverse upwards up the DOM
7871
- // to find the nearest element that has already been monkey patched with data
7872
- let parent = rElement;
7873
- while (parent = parent.parentNode) {
7874
- const parentContext = readPatchedData(parent);
7875
- if (parentContext) {
7876
- const lView = Array.isArray(parentContext) ? parentContext : parentContext.lView;
7877
- // the edge of the app was also reached here through another means
7878
- // (maybe because the DOM was changed manually).
7879
- if (!lView) {
7880
- return null;
7881
- }
7882
- const index = findViaNativeElement(lView, rElement);
7883
- if (index >= 0) {
7884
- const native = unwrapRNode(lView[index]);
7885
- const context = createLContext(lView, index, native);
7886
- attachPatchData(native, context);
7887
- mpValue = context;
7888
- break;
7889
- }
7775
+ else {
7776
+ console.error(formatRuntimeError(304 /* RuntimeErrorCode.UNKNOWN_ELEMENT */, message));
7890
7777
  }
7891
7778
  }
7892
7779
  }
7893
- return mpValue || null;
7894
7780
  }
7895
7781
  /**
7896
- * Creates an empty instance of a `LContext` context
7782
+ * Validates that the property of the element is known at runtime and returns
7783
+ * false if it's not the case.
7784
+ * This check is relevant for JIT-compiled components (for AOT-compiled
7785
+ * ones this check happens at build time).
7786
+ *
7787
+ * The property is considered known if either:
7788
+ * - it's a known property of the element
7789
+ * - the element is allowed by one of the schemas
7790
+ * - the property is used for animations
7791
+ *
7792
+ * @param element Element to validate
7793
+ * @param propName Name of the property to check
7794
+ * @param tagName Name of the tag hosting the property
7795
+ * @param schemas Array of schemas
7897
7796
  */
7898
- function createLContext(lView, nodeIndex, native) {
7899
- return new LContext(lView[ID], nodeIndex, native);
7797
+ function isPropertyValid(element, propName, tagName, schemas) {
7798
+ // If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
7799
+ // mode where this check happens at compile time. In JIT mode, `schemas` is always present and
7800
+ // defined as an array (as an empty array in case `schemas` field is not defined) and we should
7801
+ // execute the check below.
7802
+ if (schemas === null)
7803
+ return true;
7804
+ // The property is considered valid if the element matches the schema, it exists on the element,
7805
+ // or it is synthetic, and we are in a browser context (web worker nodes should be skipped).
7806
+ if (matchingSchemas(schemas, tagName) || propName in element || isAnimationProp(propName)) {
7807
+ return true;
7808
+ }
7809
+ // Note: `typeof Node` returns 'function' in most browsers, but on IE it is 'object' so we
7810
+ // need to account for both here, while being careful with `typeof null` also returning 'object'.
7811
+ return typeof Node === 'undefined' || Node === null || !(element instanceof Node);
7900
7812
  }
7901
7813
  /**
7902
- * Takes a component instance and returns the view for that component.
7814
+ * Logs or throws an error that a property is not supported on an element.
7903
7815
  *
7904
- * @param componentInstance
7905
- * @returns The component's view
7816
+ * @param propName Name of the invalid property
7817
+ * @param tagName Name of the tag hosting the property
7818
+ * @param nodeType Type of the node hosting the property
7819
+ * @param lView An `LView` that represents a current component
7906
7820
  */
7907
- function getComponentViewByInstance(componentInstance) {
7908
- let patchedData = readPatchedData(componentInstance);
7909
- let lView;
7910
- if (isLView(patchedData)) {
7911
- const contextLView = patchedData;
7912
- const nodeIndex = findViaComponent(contextLView, componentInstance);
7913
- lView = getComponentLViewByIndex(nodeIndex, contextLView);
7914
- const context = createLContext(contextLView, nodeIndex, lView[HOST]);
7915
- context.component = componentInstance;
7916
- attachPatchData(componentInstance, context);
7917
- attachPatchData(context.native, context);
7821
+ function handleUnknownPropertyError(propName, tagName, nodeType, lView) {
7822
+ // Special-case a situation when a structural directive is applied to
7823
+ // an `<ng-template>` element, for example: `<ng-template *ngIf="true">`.
7824
+ // In this case the compiler generates the `ɵɵtemplate` instruction with
7825
+ // the `null` as the tagName. The directive matching logic at runtime relies
7826
+ // on this effect (see `isInlineTemplate`), thus using the 'ng-template' as
7827
+ // a default value of the `tNode.value` is not feasible at this moment.
7828
+ if (!tagName && nodeType === 4 /* TNodeType.Container */) {
7829
+ tagName = 'ng-template';
7830
+ }
7831
+ const isHostStandalone = isHostComponentStandalone(lView);
7832
+ const templateLocation = getTemplateLocationDetails(lView);
7833
+ let message = `Can't bind to '${propName}' since it isn't a known property of '${tagName}'${templateLocation}.`;
7834
+ const schemas = `'${isHostStandalone ? '@Component' : '@NgModule'}.schemas'`;
7835
+ const importLocation = isHostStandalone ?
7836
+ 'included in the \'@Component.imports\' of this component' :
7837
+ 'a part of an @NgModule where this component is declared';
7838
+ if (KNOWN_CONTROL_FLOW_DIRECTIVES.has(propName)) {
7839
+ // Most likely this is a control flow directive (such as `*ngIf`) used in
7840
+ // a template, but the directive or the `CommonModule` is not imported.
7841
+ const correspondingImport = KNOWN_CONTROL_FLOW_DIRECTIVES.get(propName);
7842
+ message += `\nIf the '${propName}' is an Angular control flow directive, ` +
7843
+ `please make sure that either the '${correspondingImport}' directive or the 'CommonModule' is ${importLocation}.`;
7918
7844
  }
7919
7845
  else {
7920
- const context = patchedData;
7921
- const contextLView = context.lView;
7922
- ngDevMode && assertLView(contextLView);
7923
- lView = getComponentLViewByIndex(context.nodeIndex, contextLView);
7846
+ // May be an Angular component, which is not imported/declared?
7847
+ message += `\n1. If '${tagName}' is an Angular component and it has the ` +
7848
+ `'${propName}' input, then verify that it is ${importLocation}.`;
7849
+ // May be a Web Component?
7850
+ if (tagName && tagName.indexOf('-') > -1) {
7851
+ message += `\n2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' ` +
7852
+ `to the ${schemas} of this component to suppress this message.`;
7853
+ message += `\n3. To allow any property add 'NO_ERRORS_SCHEMA' to ` +
7854
+ `the ${schemas} of this component.`;
7855
+ }
7856
+ else {
7857
+ // If it's expected, the error can be suppressed by the `NO_ERRORS_SCHEMA` schema.
7858
+ message += `\n2. To allow any property add 'NO_ERRORS_SCHEMA' to ` +
7859
+ `the ${schemas} of this component.`;
7860
+ }
7924
7861
  }
7925
- return lView;
7862
+ reportUnknownPropertyError(message);
7926
7863
  }
7927
- /**
7928
- * This property will be monkey-patched on elements, components and directives.
7929
- */
7930
- const MONKEY_PATCH_KEY_NAME = '__ngContext__';
7931
- /**
7932
- * Assigns the given data to the given target (which could be a component,
7933
- * directive or DOM node instance) using monkey-patching.
7934
- */
7935
- function attachPatchData(target, data) {
7936
- ngDevMode && assertDefined(target, 'Target expected');
7937
- // Only attach the ID of the view in order to avoid memory leaks (see #41047). We only do this
7938
- // for `LView`, because we have control over when an `LView` is created and destroyed, whereas
7939
- // we can't know when to remove an `LContext`.
7940
- if (isLView(data)) {
7941
- target[MONKEY_PATCH_KEY_NAME] = data[ID];
7942
- registerLView(data);
7864
+ function reportUnknownPropertyError(message) {
7865
+ if (shouldThrowErrorOnUnknownProperty) {
7866
+ throw new RuntimeError(303 /* RuntimeErrorCode.UNKNOWN_BINDING */, message);
7943
7867
  }
7944
7868
  else {
7945
- target[MONKEY_PATCH_KEY_NAME] = data;
7869
+ console.error(formatRuntimeError(303 /* RuntimeErrorCode.UNKNOWN_BINDING */, message));
7946
7870
  }
7947
7871
  }
7948
7872
  /**
7949
- * Returns the monkey-patch value data present on the target (which could be
7950
- * a component, directive or a DOM node).
7873
+ * WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
7874
+ * and must **not** be used in production bundles. The function makes megamorphic reads, which might
7875
+ * be too slow for production mode and also it relies on the constructor function being available.
7876
+ *
7877
+ * Gets a reference to the host component def (where a current component is declared).
7878
+ *
7879
+ * @param lView An `LView` that represents a current component that is being rendered.
7951
7880
  */
7952
- function readPatchedData(target) {
7953
- ngDevMode && assertDefined(target, 'Target expected');
7954
- const data = target[MONKEY_PATCH_KEY_NAME];
7955
- return (typeof data === 'number') ? getLViewById(data) : data || null;
7956
- }
7957
- function readPatchedLView(target) {
7958
- const value = readPatchedData(target);
7959
- if (value) {
7960
- return (isLView(value) ? value : value.lView);
7961
- }
7962
- return null;
7881
+ function getDeclarationComponentDef(lView) {
7882
+ !ngDevMode && throwError('Must never be called in production mode');
7883
+ const declarationLView = lView[DECLARATION_COMPONENT_VIEW];
7884
+ const context = declarationLView[CONTEXT];
7885
+ // Unable to obtain a context.
7886
+ if (!context)
7887
+ return null;
7888
+ return context.constructor ? getComponentDef(context.constructor) : null;
7963
7889
  }
7964
- function isComponentInstance(instance) {
7965
- return instance && instance.constructor && instance.constructor.ɵcmp;
7890
+ /**
7891
+ * WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
7892
+ * and must **not** be used in production bundles. The function makes megamorphic reads, which might
7893
+ * be too slow for production mode.
7894
+ *
7895
+ * Checks if the current component is declared inside of a standalone component template.
7896
+ *
7897
+ * @param lView An `LView` that represents a current component that is being rendered.
7898
+ */
7899
+ function isHostComponentStandalone(lView) {
7900
+ !ngDevMode && throwError('Must never be called in production mode');
7901
+ const componentDef = getDeclarationComponentDef(lView);
7902
+ // Treat host component as non-standalone if we can't obtain the def.
7903
+ return !!(componentDef === null || componentDef === void 0 ? void 0 : componentDef.standalone);
7966
7904
  }
7967
- function isDirectiveInstance(instance) {
7968
- return instance && instance.constructor && instance.constructor.ɵdir;
7905
+ /**
7906
+ * WARNING: this is a **dev-mode only** function (thus should always be guarded by the `ngDevMode`)
7907
+ * and must **not** be used in production bundles. The function makes megamorphic reads, which might
7908
+ * be too slow for production mode.
7909
+ *
7910
+ * Constructs a string describing the location of the host component template. The function is used
7911
+ * in dev mode to produce error messages.
7912
+ *
7913
+ * @param lView An `LView` that represents a current component that is being rendered.
7914
+ */
7915
+ function getTemplateLocationDetails(lView) {
7916
+ var _a;
7917
+ !ngDevMode && throwError('Must never be called in production mode');
7918
+ const hostComponentDef = getDeclarationComponentDef(lView);
7919
+ const componentClassName = (_a = hostComponentDef === null || hostComponentDef === void 0 ? void 0 : hostComponentDef.type) === null || _a === void 0 ? void 0 : _a.name;
7920
+ return componentClassName ? ` (used in the '${componentClassName}' component template)` : '';
7969
7921
  }
7970
7922
  /**
7971
- * Locates the element within the given LView and returns the matching index
7923
+ * The set of known control flow directives and their corresponding imports.
7924
+ * We use this set to produce a more precises error message with a note
7925
+ * that the `CommonModule` should also be included.
7972
7926
  */
7973
- function findViaNativeElement(lView, target) {
7974
- const tView = lView[TVIEW];
7975
- for (let i = HEADER_OFFSET; i < tView.bindingStartIndex; i++) {
7976
- if (unwrapRNode(lView[i]) === target) {
7977
- return i;
7927
+ const KNOWN_CONTROL_FLOW_DIRECTIVES = new Map([
7928
+ ['ngIf', 'NgIf'], ['ngFor', 'NgFor'], ['ngSwitchCase', 'NgSwitchCase'],
7929
+ ['ngSwitchDefault', 'NgSwitchDefault']
7930
+ ]);
7931
+ /**
7932
+ * Returns true if the tag name is allowed by specified schemas.
7933
+ * @param schemas Array of schemas
7934
+ * @param tagName Name of the tag
7935
+ */
7936
+ function matchingSchemas(schemas, tagName) {
7937
+ if (schemas !== null) {
7938
+ for (let i = 0; i < schemas.length; i++) {
7939
+ const schema = schemas[i];
7940
+ if (schema === NO_ERRORS_SCHEMA ||
7941
+ schema === CUSTOM_ELEMENTS_SCHEMA && tagName && tagName.indexOf('-') > -1) {
7942
+ return true;
7943
+ }
7978
7944
  }
7979
7945
  }
7980
- return -1;
7946
+ return false;
7981
7947
  }
7948
+
7982
7949
  /**
7983
- * Locates the next tNode (child, sibling or parent).
7950
+ * @license
7951
+ * Copyright Google LLC All Rights Reserved.
7952
+ *
7953
+ * Use of this source code is governed by an MIT-style license that can be
7954
+ * found in the LICENSE file at https://angular.io/license
7984
7955
  */
7985
- function traverseNextElement(tNode) {
7986
- if (tNode.child) {
7987
- return tNode.child;
7988
- }
7989
- else if (tNode.next) {
7990
- return tNode.next;
7991
- }
7992
- else {
7993
- // Let's take the following template: <div><span>text</span></div><component/>
7994
- // After checking the text node, we need to find the next parent that has a "next" TNode,
7995
- // in this case the parent `div`, so that we can find the component.
7996
- while (tNode.parent && !tNode.parent.next) {
7997
- tNode = tNode.parent;
7998
- }
7999
- return tNode.parent && tNode.parent.next;
8000
- }
7956
+ const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
7957
+ function wrappedError(message, originalError) {
7958
+ const msg = `${message} caused by: ${originalError instanceof Error ? originalError.message : originalError}`;
7959
+ const error = Error(msg);
7960
+ error[ERROR_ORIGINAL_ERROR] = originalError;
7961
+ return error;
7962
+ }
7963
+ function getOriginalError(error) {
7964
+ return error[ERROR_ORIGINAL_ERROR];
8001
7965
  }
7966
+
8002
7967
  /**
8003
- * Locates the component within the given LView and returns the matching index
7968
+ * @license
7969
+ * Copyright Google LLC All Rights Reserved.
7970
+ *
7971
+ * Use of this source code is governed by an MIT-style license that can be
7972
+ * found in the LICENSE file at https://angular.io/license
8004
7973
  */
8005
- function findViaComponent(lView, componentInstance) {
8006
- const componentIndices = lView[TVIEW].components;
8007
- if (componentIndices) {
8008
- for (let i = 0; i < componentIndices.length; i++) {
8009
- const elementComponentIndex = componentIndices[i];
8010
- const componentView = getComponentLViewByIndex(elementComponentIndex, lView);
8011
- if (componentView[CONTEXT] === componentInstance) {
8012
- return elementComponentIndex;
8013
- }
7974
+ /**
7975
+ * Provides a hook for centralized exception handling.
7976
+ *
7977
+ * The default implementation of `ErrorHandler` prints error messages to the `console`. To
7978
+ * intercept error handling, write a custom exception handler that replaces this default as
7979
+ * appropriate for your app.
7980
+ *
7981
+ * @usageNotes
7982
+ * ### Example
7983
+ *
7984
+ * ```
7985
+ * class MyErrorHandler implements ErrorHandler {
7986
+ * handleError(error) {
7987
+ * // do something with the exception
7988
+ * }
7989
+ * }
7990
+ *
7991
+ * @NgModule({
7992
+ * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
7993
+ * })
7994
+ * class MyModule {}
7995
+ * ```
7996
+ *
7997
+ * @publicApi
7998
+ */
7999
+ class ErrorHandler {
8000
+ constructor() {
8001
+ /**
8002
+ * @internal
8003
+ */
8004
+ this._console = console;
8005
+ }
8006
+ handleError(error) {
8007
+ const originalError = this._findOriginalError(error);
8008
+ this._console.error('ERROR', error);
8009
+ if (originalError) {
8010
+ this._console.error('ORIGINAL ERROR', originalError);
8014
8011
  }
8015
8012
  }
8016
- else {
8017
- const rootComponentView = getComponentLViewByIndex(HEADER_OFFSET, lView);
8018
- const rootComponent = rootComponentView[CONTEXT];
8019
- if (rootComponent === componentInstance) {
8020
- // we are dealing with the root element here therefore we know that the
8021
- // element is the very first element after the HEADER data in the lView
8022
- return HEADER_OFFSET;
8013
+ /** @internal */
8014
+ _findOriginalError(error) {
8015
+ let e = error && getOriginalError(error);
8016
+ while (e && getOriginalError(e)) {
8017
+ e = getOriginalError(e);
8023
8018
  }
8019
+ return e || null;
8024
8020
  }
8025
- return -1;
8026
8021
  }
8022
+
8027
8023
  /**
8028
- * Locates the directive within the given LView and returns the matching index
8024
+ * @license
8025
+ * Copyright Google LLC All Rights Reserved.
8026
+ *
8027
+ * Use of this source code is governed by an MIT-style license that can be
8028
+ * found in the LICENSE file at https://angular.io/license
8029
8029
  */
8030
- function findViaDirective(lView, directiveInstance) {
8031
- // if a directive is monkey patched then it will (by default)
8032
- // have a reference to the LView of the current view. The
8033
- // element bound to the directive being search lives somewhere
8034
- // in the view data. We loop through the nodes and check their
8035
- // list of directives for the instance.
8036
- let tNode = lView[TVIEW].firstChild;
8037
- while (tNode) {
8038
- const directiveIndexStart = tNode.directiveStart;
8039
- const directiveIndexEnd = tNode.directiveEnd;
8040
- for (let i = directiveIndexStart; i < directiveIndexEnd; i++) {
8041
- if (lView[i] === directiveInstance) {
8042
- return tNode.index;
8043
- }
8044
- }
8045
- tNode = traverseNextElement(tNode);
8046
- }
8047
- return -1;
8048
- }
8049
8030
  /**
8050
- * Returns a list of directives extracted from the given view based on the
8051
- * provided list of directive index values.
8031
+ * Disallowed strings in the comment.
8052
8032
  *
8053
- * @param nodeIndex The node index
8054
- * @param lView The target view data
8055
- * @param includeComponents Whether or not to include components in returned directives
8033
+ * see: https://html.spec.whatwg.org/multipage/syntax.html#comments
8056
8034
  */
8057
- function getDirectivesAtNodeIndex(nodeIndex, lView, includeComponents) {
8058
- const tNode = lView[TVIEW].data[nodeIndex];
8059
- if (tNode.directiveStart === 0)
8060
- return EMPTY_ARRAY;
8061
- const results = [];
8062
- for (let i = tNode.directiveStart; i < tNode.directiveEnd; i++) {
8063
- const directiveInstance = lView[i];
8064
- if (!isComponentInstance(directiveInstance) || includeComponents) {
8065
- results.push(directiveInstance);
8066
- }
8067
- }
8068
- return results;
8069
- }
8070
- function getComponentAtNodeIndex(nodeIndex, lView) {
8071
- const tNode = lView[TVIEW].data[nodeIndex];
8072
- const { directiveStart, componentOffset } = tNode;
8073
- return componentOffset > -1 ? lView[directiveStart + componentOffset] : null;
8035
+ const COMMENT_DISALLOWED = /^>|^->|<!--|-->|--!>|<!-$/g;
8036
+ /**
8037
+ * Delimiter in the disallowed strings which needs to be wrapped with zero with character.
8038
+ */
8039
+ const COMMENT_DELIMITER = /(<|>)/;
8040
+ const COMMENT_DELIMITER_ESCAPED = '\u200B$1\u200B';
8041
+ /**
8042
+ * Escape the content of comment strings so that it can be safely inserted into a comment node.
8043
+ *
8044
+ * The issue is that HTML does not specify any way to escape comment end text inside the comment.
8045
+ * Consider: `<!-- The way you close a comment is with ">", and "->" at the beginning or by "-->" or
8046
+ * "--!>" at the end. -->`. Above the `"-->"` is meant to be text not an end to the comment. This
8047
+ * can be created programmatically through DOM APIs. (`<!--` are also disallowed.)
8048
+ *
8049
+ * see: https://html.spec.whatwg.org/multipage/syntax.html#comments
8050
+ *
8051
+ * ```
8052
+ * div.innerHTML = div.innerHTML
8053
+ * ```
8054
+ *
8055
+ * One would expect that the above code would be safe to do, but it turns out that because comment
8056
+ * text is not escaped, the comment may contain text which will prematurely close the comment
8057
+ * opening up the application for XSS attack. (In SSR we programmatically create comment nodes which
8058
+ * may contain such text and expect them to be safe.)
8059
+ *
8060
+ * This function escapes the comment text by looking for comment delimiters (`<` and `>`) and
8061
+ * surrounding them with `_>_` where the `_` is a zero width space `\u200B`. The result is that if a
8062
+ * comment contains any of the comment start/end delimiters (such as `<!--`, `-->` or `--!>`) the
8063
+ * text it will render normally but it will not cause the HTML parser to close/open the comment.
8064
+ *
8065
+ * @param value text to make safe for comment node by escaping the comment open/close character
8066
+ * sequence.
8067
+ */
8068
+ function escapeCommentText(value) {
8069
+ return value.replace(COMMENT_DISALLOWED, (text) => text.replace(COMMENT_DELIMITER, COMMENT_DELIMITER_ESCAPED));
8074
8070
  }
8071
+
8075
8072
  /**
8076
- * Returns a map of local references (local reference name => element or directive instance) that
8077
- * exist on a given element.
8073
+ * @license
8074
+ * Copyright Google LLC All Rights Reserved.
8075
+ *
8076
+ * Use of this source code is governed by an MIT-style license that can be
8077
+ * found in the LICENSE file at https://angular.io/license
8078
8078
  */
8079
- function discoverLocalRefs(lView, nodeIndex) {
8080
- const tNode = lView[TVIEW].data[nodeIndex];
8081
- if (tNode && tNode.localNames) {
8082
- const result = {};
8083
- let localIndex = tNode.index + 1;
8084
- for (let i = 0; i < tNode.localNames.length; i += 2) {
8085
- result[tNode.localNames[i]] = lView[localIndex];
8086
- localIndex++;
8087
- }
8088
- return result;
8079
+ function normalizeDebugBindingName(name) {
8080
+ // Attribute names with `$` (eg `x-y$`) are valid per spec, but unsupported by some browsers
8081
+ name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
8082
+ return `ng-reflect-${name}`;
8083
+ }
8084
+ const CAMEL_CASE_REGEXP = /([A-Z])/g;
8085
+ function camelCaseToDashCase(input) {
8086
+ return input.replace(CAMEL_CASE_REGEXP, (...m) => '-' + m[1].toLowerCase());
8087
+ }
8088
+ function normalizeDebugBindingValue(value) {
8089
+ try {
8090
+ // Limit the size of the value as otherwise the DOM just gets polluted.
8091
+ return value != null ? value.toString().slice(0, 30) : value;
8092
+ }
8093
+ catch (e) {
8094
+ return '[ERROR] Exception while trying to serialize the value';
8089
8095
  }
8090
- return null;
8091
8096
  }
8092
8097
 
8093
8098
  /**
@@ -9306,6 +9311,19 @@ function writeDirectClass(renderer, element, newValue) {
9306
9311
  }
9307
9312
  ngDevMode && ngDevMode.rendererSetClassName++;
9308
9313
  }
9314
+ /** Sets up the static DOM attributes on an `RNode`. */
9315
+ function setupStaticAttributes(renderer, element, tNode) {
9316
+ const { mergedAttrs, classes, styles } = tNode;
9317
+ if (mergedAttrs !== null) {
9318
+ setUpAttributes(renderer, element, mergedAttrs);
9319
+ }
9320
+ if (classes !== null) {
9321
+ writeDirectClass(renderer, element, classes);
9322
+ }
9323
+ if (styles !== null) {
9324
+ writeDirectStyle(renderer, element, styles);
9325
+ }
9326
+ }
9309
9327
 
9310
9328
  /**
9311
9329
  * @license
@@ -12527,28 +12545,6 @@ function setNgReflectProperties(lView, element, type, dataValue, value) {
12527
12545
  }
12528
12546
  }
12529
12547
  }
12530
- /**
12531
- * Instantiate a root component.
12532
- */
12533
- function instantiateRootComponent(tView, lView, def) {
12534
- const rootTNode = getCurrentTNode();
12535
- if (tView.firstCreatePass) {
12536
- if (def.providersResolver)
12537
- def.providersResolver(def);
12538
- const directiveIndex = allocExpando(tView, lView, 1, null);
12539
- ngDevMode &&
12540
- assertEqual(directiveIndex, rootTNode.directiveStart, 'Because this is a root component the allocated expando should match the TNode component.');
12541
- configureViewWithDirective(tView, rootTNode, lView, directiveIndex, def);
12542
- initializeInputAndOutputAliases(tView, rootTNode);
12543
- }
12544
- const directive = getNodeInjectable(lView, tView, rootTNode.directiveStart + rootTNode.componentOffset, rootTNode);
12545
- attachPatchData(directive, lView);
12546
- const native = getNativeByTNode(rootTNode, lView);
12547
- if (native) {
12548
- attachPatchData(native, lView);
12549
- }
12550
- return directive;
12551
- }
12552
12548
  /**
12553
12549
  * Resolve the matched directives on a node.
12554
12550
  */
@@ -12558,59 +12554,16 @@ function resolveDirectives(tView, lView, tNode, localRefs) {
12558
12554
  ngDevMode && assertFirstCreatePass(tView);
12559
12555
  let hasDirectives = false;
12560
12556
  if (getBindingsEnabled()) {
12561
- const directiveDefsMatchedBySelectors = findDirectiveDefMatches(tView, lView, tNode);
12562
- const directiveDefs = directiveDefsMatchedBySelectors ?
12563
- findHostDirectiveDefs$1(directiveDefsMatchedBySelectors, tView, lView, tNode) :
12564
- null;
12557
+ const directiveDefs = findDirectiveDefMatches(tView, lView, tNode);
12565
12558
  const exportsMap = localRefs === null ? null : { '': -1 };
12566
12559
  if (directiveDefs !== null) {
12567
- hasDirectives = true;
12568
- initTNodeFlags(tNode, tView.data.length, directiveDefs.length);
12569
- // When the same token is provided by several directives on the same node, some rules apply in
12570
- // the viewEngine:
12571
- // - viewProviders have priority over providers
12572
- // - the last directive in NgModule.declarations has priority over the previous one
12573
- // So to match these rules, the order in which providers are added in the arrays is very
12574
- // important.
12575
- for (let i = 0; i < directiveDefs.length; i++) {
12576
- const def = directiveDefs[i];
12577
- if (def.providersResolver)
12578
- def.providersResolver(def);
12579
- }
12580
- let preOrderHooksFound = false;
12581
- let preOrderCheckHooksFound = false;
12582
- let directiveIdx = allocExpando(tView, lView, directiveDefs.length, null);
12583
- ngDevMode &&
12584
- assertSame(directiveIdx, tNode.directiveStart, 'TNode.directiveStart should point to just allocated space');
12560
+ // Publishes the directive types to DI so they can be injected. Needs to
12561
+ // happen in a separate pass before the TNode flags have been initialized.
12585
12562
  for (let i = 0; i < directiveDefs.length; i++) {
12586
- const def = directiveDefs[i];
12587
- // Merge the attrs in the order of matches. This assumes that the first directive is the
12588
- // component itself, so that the component has the least priority.
12589
- tNode.mergedAttrs = mergeHostAttrs(tNode.mergedAttrs, def.hostAttrs);
12590
- configureViewWithDirective(tView, tNode, lView, directiveIdx, def);
12591
- saveNameToExportMap(directiveIdx, def, exportsMap);
12592
- if (def.contentQueries !== null)
12593
- tNode.flags |= 4 /* TNodeFlags.hasContentQuery */;
12594
- if (def.hostBindings !== null || def.hostAttrs !== null || def.hostVars !== 0)
12595
- tNode.flags |= 64 /* TNodeFlags.hasHostBindings */;
12596
- const lifeCycleHooks = def.type.prototype;
12597
- // Only push a node index into the preOrderHooks array if this is the first
12598
- // pre-order hook found on this node.
12599
- if (!preOrderHooksFound &&
12600
- (lifeCycleHooks.ngOnChanges || lifeCycleHooks.ngOnInit || lifeCycleHooks.ngDoCheck)) {
12601
- // We will push the actual hook function into this array later during dir instantiation.
12602
- // We cannot do it now because we must ensure hooks are registered in the same
12603
- // order that directives are created (i.e. injection order).
12604
- (tView.preOrderHooks || (tView.preOrderHooks = [])).push(tNode.index);
12605
- preOrderHooksFound = true;
12606
- }
12607
- if (!preOrderCheckHooksFound && (lifeCycleHooks.ngOnChanges || lifeCycleHooks.ngDoCheck)) {
12608
- (tView.preOrderCheckHooks || (tView.preOrderCheckHooks = [])).push(tNode.index);
12609
- preOrderCheckHooksFound = true;
12610
- }
12611
- directiveIdx++;
12563
+ diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, lView), tView, directiveDefs[i].type);
12612
12564
  }
12613
- initializeInputAndOutputAliases(tView, tNode);
12565
+ hasDirectives = true;
12566
+ initializeDirectives(tView, lView, tNode, directiveDefs, exportsMap);
12614
12567
  }
12615
12568
  if (exportsMap)
12616
12569
  cacheMatchingLocalNames(tNode, localRefs, exportsMap);
@@ -12619,17 +12572,66 @@ function resolveDirectives(tView, lView, tNode, localRefs) {
12619
12572
  tNode.mergedAttrs = mergeHostAttrs(tNode.mergedAttrs, tNode.attrs);
12620
12573
  return hasDirectives;
12621
12574
  }
12575
+ /** Initializes the data structures necessary for a list of directives to be instantiated. */
12576
+ function initializeDirectives(tView, lView, tNode, directives, exportsMap) {
12577
+ ngDevMode && assertFirstCreatePass(tView);
12578
+ initTNodeFlags(tNode, tView.data.length, directives.length);
12579
+ // When the same token is provided by several directives on the same node, some rules apply in
12580
+ // the viewEngine:
12581
+ // - viewProviders have priority over providers
12582
+ // - the last directive in NgModule.declarations has priority over the previous one
12583
+ // So to match these rules, the order in which providers are added in the arrays is very
12584
+ // important.
12585
+ for (let i = 0; i < directives.length; i++) {
12586
+ const def = directives[i];
12587
+ if (def.providersResolver)
12588
+ def.providersResolver(def);
12589
+ }
12590
+ let preOrderHooksFound = false;
12591
+ let preOrderCheckHooksFound = false;
12592
+ let directiveIdx = allocExpando(tView, lView, directives.length, null);
12593
+ ngDevMode &&
12594
+ assertSame(directiveIdx, tNode.directiveStart, 'TNode.directiveStart should point to just allocated space');
12595
+ for (let i = 0; i < directives.length; i++) {
12596
+ const def = directives[i];
12597
+ // Merge the attrs in the order of matches. This assumes that the first directive is the
12598
+ // component itself, so that the component has the least priority.
12599
+ tNode.mergedAttrs = mergeHostAttrs(tNode.mergedAttrs, def.hostAttrs);
12600
+ configureViewWithDirective(tView, tNode, lView, directiveIdx, def);
12601
+ saveNameToExportMap(directiveIdx, def, exportsMap);
12602
+ if (def.contentQueries !== null)
12603
+ tNode.flags |= 4 /* TNodeFlags.hasContentQuery */;
12604
+ if (def.hostBindings !== null || def.hostAttrs !== null || def.hostVars !== 0)
12605
+ tNode.flags |= 64 /* TNodeFlags.hasHostBindings */;
12606
+ const lifeCycleHooks = def.type.prototype;
12607
+ // Only push a node index into the preOrderHooks array if this is the first
12608
+ // pre-order hook found on this node.
12609
+ if (!preOrderHooksFound &&
12610
+ (lifeCycleHooks.ngOnChanges || lifeCycleHooks.ngOnInit || lifeCycleHooks.ngDoCheck)) {
12611
+ // We will push the actual hook function into this array later during dir instantiation.
12612
+ // We cannot do it now because we must ensure hooks are registered in the same
12613
+ // order that directives are created (i.e. injection order).
12614
+ (tView.preOrderHooks || (tView.preOrderHooks = [])).push(tNode.index);
12615
+ preOrderHooksFound = true;
12616
+ }
12617
+ if (!preOrderCheckHooksFound && (lifeCycleHooks.ngOnChanges || lifeCycleHooks.ngDoCheck)) {
12618
+ (tView.preOrderCheckHooks || (tView.preOrderCheckHooks = [])).push(tNode.index);
12619
+ preOrderCheckHooksFound = true;
12620
+ }
12621
+ directiveIdx++;
12622
+ }
12623
+ initializeInputAndOutputAliases(tView, tNode);
12624
+ }
12622
12625
  /**
12623
12626
  * Add `hostBindings` to the `TView.hostBindingOpCodes`.
12624
12627
  *
12625
12628
  * @param tView `TView` to which the `hostBindings` should be added.
12626
12629
  * @param tNode `TNode` the element which contains the directive
12627
- * @param lView `LView` current `LView`
12628
12630
  * @param directiveIdx Directive index in view.
12629
12631
  * @param directiveVarsIdx Where will the directive's vars be stored
12630
12632
  * @param def `ComponentDef`/`DirectiveDef`, which contains the `hostVars`/`hostBindings` to add.
12631
12633
  */
12632
- function registerHostBindingOpCodes(tView, tNode, lView, directiveIdx, directiveVarsIdx, def) {
12634
+ function registerHostBindingOpCodes(tView, tNode, directiveIdx, directiveVarsIdx, def) {
12633
12635
  ngDevMode && assertFirstCreatePass(tView);
12634
12636
  const hostBindings = def.hostBindings;
12635
12637
  if (hostBindings) {
@@ -12730,7 +12732,8 @@ function invokeHostBindingsInCreationMode(def, directive) {
12730
12732
  * Matches the current node against all available selectors.
12731
12733
  * If a component is matched (at most one), it is returned in first position in the array.
12732
12734
  */
12733
- function findDirectiveDefMatches(tView, viewData, tNode) {
12735
+ function findDirectiveDefMatches(tView, lView, tNode) {
12736
+ var _a;
12734
12737
  ngDevMode && assertFirstCreatePass(tView);
12735
12738
  ngDevMode && assertTNodeType(tNode, 3 /* TNodeType.AnyRNode */ | 12 /* TNodeType.AnyContainer */);
12736
12739
  const registry = tView.directiveRegistry;
@@ -12740,22 +12743,45 @@ function findDirectiveDefMatches(tView, viewData, tNode) {
12740
12743
  const def = registry[i];
12741
12744
  if (isNodeMatchingSelectorList(tNode, def.selectors, /* isProjectionMode */ false)) {
12742
12745
  matches || (matches = ngDevMode ? new MatchesArray() : []);
12743
- diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, viewData), tView, def.type);
12744
12746
  if (isComponentDef(def)) {
12745
12747
  if (ngDevMode) {
12746
12748
  assertTNodeType(tNode, 2 /* TNodeType.Element */, `"${tNode.value}" tags cannot be used as component hosts. ` +
12747
12749
  `Please use a different tag to activate the ${stringify(def.type)} component.`);
12748
12750
  if (isComponentHost(tNode)) {
12749
- // If another component has been matched previously, it's the first element in the
12750
- // `matches` array, see how we store components/directives in `matches` below.
12751
- throwMultipleComponentError(tNode, matches[0].type, def.type);
12751
+ throwMultipleComponentError(tNode, matches.find(isComponentDef).type, def.type);
12752
12752
  }
12753
12753
  }
12754
- markAsComponentHost(tView, tNode, 0);
12755
- // The component is always stored first with directives after.
12756
- matches.unshift(def);
12754
+ // Components are inserted at the front of the matches array so that their lifecycle
12755
+ // hooks run before any directive lifecycle hooks. This appears to be for ViewEngine
12756
+ // compatibility. This logic doesn't make sense with host directives, because it
12757
+ // would allow the host directives to undo any overrides the host may have made.
12758
+ // To handle this case, the host directives of components are inserted at the beginning
12759
+ // of the array, followed by the component. As such, the insertion order is as follows:
12760
+ // 1. Host directives belonging to the selector-matched component.
12761
+ // 2. Selector-matched component.
12762
+ // 3. Host directives belonging to selector-matched directives.
12763
+ // 4. Selector-matched directives.
12764
+ if (def.findHostDirectiveDefs !== null) {
12765
+ const hostDirectiveMatches = [];
12766
+ def.findHostDirectiveDefs(hostDirectiveMatches, def, tView, lView, tNode);
12767
+ // Add all host directives declared on this component, followed by the component itself.
12768
+ // Host directives should execute first so the host has a chance to override changes
12769
+ // to the DOM made by them.
12770
+ matches.unshift(...hostDirectiveMatches, def);
12771
+ // Component is offset starting from the beginning of the host directives array.
12772
+ const componentOffset = hostDirectiveMatches.length;
12773
+ markAsComponentHost(tView, tNode, componentOffset);
12774
+ }
12775
+ else {
12776
+ // No host directives on this component, just add the
12777
+ // component def to the beginning of the matches.
12778
+ matches.unshift(def);
12779
+ markAsComponentHost(tView, tNode, 0);
12780
+ }
12757
12781
  }
12758
12782
  else {
12783
+ // Append any host directives to the matches first.
12784
+ (_a = def.findHostDirectiveDefs) === null || _a === void 0 ? void 0 : _a.call(def, matches, def, tView, lView, tNode);
12759
12785
  matches.push(def);
12760
12786
  }
12761
12787
  }
@@ -12775,26 +12801,6 @@ function markAsComponentHost(tView, hostTNode, componentOffset) {
12775
12801
  (tView.components || (tView.components = ngDevMode ? new TViewComponents() : []))
12776
12802
  .push(hostTNode.index);
12777
12803
  }
12778
- /**
12779
- * Given an array of directives that were matched by their selectors, this function
12780
- * produces a new array that also includes any host directives that have to be applied.
12781
- * @param selectorMatches Directives matched in a template based on their selectors.
12782
- * @param tView Current TView.
12783
- * @param lView Current LView.
12784
- * @param tNode Current TNode that is being matched.
12785
- */
12786
- function findHostDirectiveDefs$1(selectorMatches, tView, lView, tNode) {
12787
- const matches = [];
12788
- for (const def of selectorMatches) {
12789
- if (def.findHostDirectiveDefs === null) {
12790
- matches.push(def);
12791
- }
12792
- else {
12793
- def.findHostDirectiveDefs(matches, def, tView, lView, tNode);
12794
- }
12795
- }
12796
- return matches;
12797
- }
12798
12804
  /** Caches local names and their matching directive indices for query and template lookups. */
12799
12805
  function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
12800
12806
  if (localRefs) {
@@ -12862,7 +12868,7 @@ function configureViewWithDirective(tView, tNode, lView, directiveIndex, def) {
12862
12868
  const nodeInjectorFactory = new NodeInjectorFactory(directiveFactory, isComponentDef(def), ɵɵdirectiveInject);
12863
12869
  tView.blueprint[directiveIndex] = nodeInjectorFactory;
12864
12870
  lView[directiveIndex] = nodeInjectorFactory;
12865
- registerHostBindingOpCodes(tView, tNode, lView, directiveIndex, allocExpando(tView, lView, def.hostVars, NO_CHANGE), def);
12871
+ registerHostBindingOpCodes(tView, tNode, directiveIndex, allocExpando(tView, lView, def.hostVars, NO_CHANGE), def);
12866
12872
  }
12867
12873
  function addComponentLogic(lView, hostTNode, def) {
12868
12874
  const native = getNativeByTNode(hostTNode, lView);
@@ -13785,6 +13791,7 @@ class ChainedInjector {
13785
13791
  this.parentInjector = parentInjector;
13786
13792
  }
13787
13793
  get(token, notFoundValue, flags) {
13794
+ flags = convertToBitFlags(flags);
13788
13795
  const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
13789
13796
  if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
13790
13797
  notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
@@ -13861,42 +13868,23 @@ class ComponentFactory extends ComponentFactory$1 {
13861
13868
  let component;
13862
13869
  let tElementNode;
13863
13870
  try {
13864
- const componentView = createRootComponentView(hostRNode, this.componentDef, rootLView, rendererFactory, hostRenderer);
13871
+ const rootDirectives = [this.componentDef];
13872
+ const hostTNode = createRootComponentTNode(rootLView, hostRNode);
13873
+ const componentView = createRootComponentView(hostTNode, hostRNode, this.componentDef, rootDirectives, rootLView, rendererFactory, hostRenderer);
13874
+ tElementNode = getTNode(rootTView, HEADER_OFFSET);
13875
+ // TODO(crisbeto): in practice `hostRNode` should always be defined, but there are some tests
13876
+ // where the renderer is mocked out and `undefined` is returned. We should update the tests so
13877
+ // that this check can be removed.
13865
13878
  if (hostRNode) {
13866
- if (rootSelectorOrNode) {
13867
- setUpAttributes(hostRenderer, hostRNode, ['ng-version', VERSION.full]);
13868
- }
13869
- else {
13870
- // If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
13871
- // is not defined), also apply attributes and classes extracted from component selector.
13872
- // Extract attributes and classes from the first selector only to match VE behavior.
13873
- const { attrs, classes } = extractAttrsAndClassesFromSelector(this.componentDef.selectors[0]);
13874
- if (attrs) {
13875
- setUpAttributes(hostRenderer, hostRNode, attrs);
13876
- }
13877
- if (classes && classes.length > 0) {
13878
- writeDirectClass(hostRenderer, hostRNode, classes.join(' '));
13879
- }
13880
- }
13879
+ setRootNodeAttributes(hostRenderer, this.componentDef, hostRNode, rootSelectorOrNode);
13881
13880
  }
13882
- tElementNode = getTNode(rootTView, HEADER_OFFSET);
13883
13881
  if (projectableNodes !== undefined) {
13884
- const projection = tElementNode.projection = [];
13885
- for (let i = 0; i < this.ngContentSelectors.length; i++) {
13886
- const nodesforSlot = projectableNodes[i];
13887
- // Projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
13888
- // case). Here we do normalize passed data structure to be an array of arrays to avoid
13889
- // complex checks down the line.
13890
- // We also normalize the length of the passed in projectable nodes (to match the number of
13891
- // <ng-container> slots defined by a component).
13892
- projection.push(nodesforSlot != null ? Array.from(nodesforSlot) : null);
13893
- }
13882
+ projectNodes(tElementNode, this.ngContentSelectors, projectableNodes);
13894
13883
  }
13895
13884
  // TODO: should LifecycleHooksFeature and other host features be generated by the compiler and
13896
13885
  // executed here?
13897
13886
  // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
13898
- component =
13899
- createRootComponent(componentView, this.componentDef, rootLView, [LifecycleHooksFeature]);
13887
+ component = createRootComponent(componentView, this.componentDef, rootDirectives, rootLView, [LifecycleHooksFeature]);
13900
13888
  renderView(rootTView, rootLView, null);
13901
13889
  }
13902
13890
  finally {
@@ -13967,11 +13955,22 @@ const NULL_INJECTOR = {
13967
13955
  throwProviderNotFoundError(token, 'NullInjector');
13968
13956
  }
13969
13957
  };
13958
+ /** Creates a TNode that can be used to instantiate a root component. */
13959
+ function createRootComponentTNode(lView, rNode) {
13960
+ const tView = lView[TVIEW];
13961
+ const index = HEADER_OFFSET;
13962
+ ngDevMode && assertIndexInRange(lView, index);
13963
+ lView[index] = rNode;
13964
+ // '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
13965
+ // the same time we want to communicate the debug `TNode` that this is a special `TNode`
13966
+ // representing a host element.
13967
+ return getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
13968
+ }
13970
13969
  /**
13971
13970
  * Creates the root component view and the root component node.
13972
13971
  *
13973
13972
  * @param rNode Render host element.
13974
- * @param def ComponentDef
13973
+ * @param rootComponentDef ComponentDef
13975
13974
  * @param rootView The parent view where the host node is stored
13976
13975
  * @param rendererFactory Factory to be used for creating child renderers.
13977
13976
  * @param hostRenderer The current renderer
@@ -13979,72 +13978,96 @@ const NULL_INJECTOR = {
13979
13978
  *
13980
13979
  * @returns Component view created
13981
13980
  */
13982
- function createRootComponentView(rNode, def, rootView, rendererFactory, hostRenderer, sanitizer) {
13981
+ function createRootComponentView(tNode, rNode, rootComponentDef, rootDirectives, rootView, rendererFactory, hostRenderer, sanitizer) {
13983
13982
  const tView = rootView[TVIEW];
13984
- const index = HEADER_OFFSET;
13985
- ngDevMode && assertIndexInRange(rootView, index);
13986
- rootView[index] = rNode;
13987
- // '#host' is added here as we don't know the real host DOM name (we don't want to read it) and at
13988
- // the same time we want to communicate the debug `TNode` that this is a special `TNode`
13989
- // representing a host element.
13990
- const tNode = getOrCreateTNode(tView, index, 2 /* TNodeType.Element */, '#host', null);
13991
- const mergedAttrs = tNode.mergedAttrs = def.hostAttrs;
13992
- if (mergedAttrs !== null) {
13993
- computeStaticStyling(tNode, mergedAttrs, true);
13994
- if (rNode !== null) {
13995
- setUpAttributes(hostRenderer, rNode, mergedAttrs);
13996
- if (tNode.classes !== null) {
13997
- writeDirectClass(hostRenderer, rNode, tNode.classes);
13998
- }
13999
- if (tNode.styles !== null) {
14000
- writeDirectStyle(hostRenderer, rNode, tNode.styles);
14001
- }
14002
- }
14003
- }
14004
- const viewRenderer = rendererFactory.createRenderer(rNode, def);
14005
- const componentView = createLView(rootView, getOrCreateComponentTView(def), null, def.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
13983
+ applyRootComponentStyling(rootDirectives, tNode, rNode, hostRenderer);
13984
+ const viewRenderer = rendererFactory.createRenderer(rNode, rootComponentDef);
13985
+ const componentView = createLView(rootView, getOrCreateComponentTView(rootComponentDef), null, rootComponentDef.onPush ? 32 /* LViewFlags.Dirty */ : 16 /* LViewFlags.CheckAlways */, rootView[tNode.index], tNode, rendererFactory, viewRenderer, sanitizer || null, null, null);
14006
13986
  if (tView.firstCreatePass) {
14007
- diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, def.type);
13987
+ diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), tView, rootComponentDef.type);
14008
13988
  markAsComponentHost(tView, tNode, 0);
14009
- initTNodeFlags(tNode, rootView.length, 1);
14010
13989
  }
14011
13990
  addToViewTree(rootView, componentView);
14012
13991
  // Store component view at node index, with node as the HOST
14013
- return rootView[index] = componentView;
13992
+ return rootView[tNode.index] = componentView;
13993
+ }
13994
+ /** Sets up the styling information on a root component. */
13995
+ function applyRootComponentStyling(rootDirectives, tNode, rNode, hostRenderer) {
13996
+ for (const def of rootDirectives) {
13997
+ tNode.mergedAttrs = mergeHostAttrs(tNode.mergedAttrs, def.hostAttrs);
13998
+ }
13999
+ if (tNode.mergedAttrs !== null) {
14000
+ computeStaticStyling(tNode, tNode.mergedAttrs, true);
14001
+ if (rNode !== null) {
14002
+ setupStaticAttributes(hostRenderer, rNode, tNode);
14003
+ }
14004
+ }
14014
14005
  }
14015
14006
  /**
14016
14007
  * Creates a root component and sets it up with features and host bindings.Shared by
14017
14008
  * renderComponent() and ViewContainerRef.createComponent().
14018
14009
  */
14019
- function createRootComponent(componentView, componentDef, rootLView, hostFeatures) {
14010
+ function createRootComponent(componentView, rootComponentDef, rootDirectives, rootLView, hostFeatures) {
14011
+ const rootTNode = getCurrentTNode();
14012
+ ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
14020
14013
  const tView = rootLView[TVIEW];
14021
- // Create directive instance with factory() and store at next index in viewData
14022
- const component = instantiateRootComponent(tView, rootLView, componentDef);
14023
- // Root view only contains an instance of this component,
14024
- // so we use a reference to that component instance as a context.
14014
+ const native = getNativeByTNode(rootTNode, rootLView);
14015
+ initializeDirectives(tView, rootLView, rootTNode, rootDirectives, null);
14016
+ for (let i = 0; i < rootDirectives.length; i++) {
14017
+ const directiveIndex = rootTNode.directiveStart + i;
14018
+ const directiveInstance = getNodeInjectable(rootLView, tView, directiveIndex, rootTNode);
14019
+ attachPatchData(directiveInstance, rootLView);
14020
+ }
14021
+ invokeDirectivesHostBindings(tView, rootLView, rootTNode);
14022
+ if (native) {
14023
+ attachPatchData(native, rootLView);
14024
+ }
14025
+ // We're guaranteed for the `componentOffset` to be positive here
14026
+ // since a root component always matches a component def.
14027
+ ngDevMode &&
14028
+ assertGreaterThan(rootTNode.componentOffset, -1, 'componentOffset must be great than -1');
14029
+ const component = getNodeInjectable(rootLView, tView, rootTNode.directiveStart + rootTNode.componentOffset, rootTNode);
14025
14030
  componentView[CONTEXT] = rootLView[CONTEXT] = component;
14026
14031
  if (hostFeatures !== null) {
14027
14032
  for (const feature of hostFeatures) {
14028
- feature(component, componentDef);
14033
+ feature(component, rootComponentDef);
14029
14034
  }
14030
14035
  }
14031
14036
  // We want to generate an empty QueryList for root content queries for backwards
14032
14037
  // compatibility with ViewEngine.
14033
- if (componentDef.contentQueries) {
14034
- const tNode = getCurrentTNode();
14035
- ngDevMode && assertDefined(tNode, 'TNode expected');
14036
- componentDef.contentQueries(1 /* RenderFlags.Create */, component, tNode.directiveStart);
14038
+ executeContentQueries(tView, rootTNode, componentView);
14039
+ return component;
14040
+ }
14041
+ /** Sets the static attributes on a root component. */
14042
+ function setRootNodeAttributes(hostRenderer, componentDef, hostRNode, rootSelectorOrNode) {
14043
+ if (rootSelectorOrNode) {
14044
+ setUpAttributes(hostRenderer, hostRNode, ['ng-version', VERSION.full]);
14037
14045
  }
14038
- const rootTNode = getCurrentTNode();
14039
- ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');
14040
- if (tView.firstCreatePass &&
14041
- (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {
14042
- setSelectedIndex(rootTNode.index);
14043
- const rootTView = rootLView[TVIEW];
14044
- registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);
14045
- invokeHostBindingsInCreationMode(componentDef, component);
14046
+ else {
14047
+ // If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
14048
+ // is not defined), also apply attributes and classes extracted from component selector.
14049
+ // Extract attributes and classes from the first selector only to match VE behavior.
14050
+ const { attrs, classes } = extractAttrsAndClassesFromSelector(componentDef.selectors[0]);
14051
+ if (attrs) {
14052
+ setUpAttributes(hostRenderer, hostRNode, attrs);
14053
+ }
14054
+ if (classes && classes.length > 0) {
14055
+ writeDirectClass(hostRenderer, hostRNode, classes.join(' '));
14056
+ }
14057
+ }
14058
+ }
14059
+ /** Projects the `projectableNodes` that were specified when creating a root component. */
14060
+ function projectNodes(tNode, ngContentSelectors, projectableNodes) {
14061
+ const projection = tNode.projection = [];
14062
+ for (let i = 0; i < ngContentSelectors.length; i++) {
14063
+ const nodesforSlot = projectableNodes[i];
14064
+ // Projectable nodes can be passed as array of arrays or an array of iterables (ngUpgrade
14065
+ // case). Here we do normalize passed data structure to be an array of arrays to avoid
14066
+ // complex checks down the line.
14067
+ // We also normalize the length of the passed in projectable nodes (to match the number of
14068
+ // <ng-container> slots defined by a component).
14069
+ projection.push(nodesforSlot != null ? Array.from(nodesforSlot) : null);
14046
14070
  }
14047
- return component;
14048
14071
  }
14049
14072
  /**
14050
14073
  * Used to enable lifecycle hooks on the root component.
@@ -14351,10 +14374,9 @@ function findHostDirectiveDefs(matches, def, tView, lView, tNode) {
14351
14374
  // TODO(crisbeto): assert that the def exists.
14352
14375
  // Host directives execute before the host so that its host bindings can be overwritten.
14353
14376
  findHostDirectiveDefs(matches, hostDirectiveDef, tView, lView, tNode);
14377
+ matches.push(hostDirectiveDef);
14354
14378
  }
14355
14379
  }
14356
- // Push the def itself at the end since it needs to execute after the host directives.
14357
- matches.push(def);
14358
14380
  }
14359
14381
  /**
14360
14382
  * Converts an array in the form of `['publicName', 'alias', 'otherPublicName', 'otherAlias']` into
@@ -15313,18 +15335,7 @@ function ɵɵelementStart(index, name, attrsIndex, localRefsIndex) {
15313
15335
  elementStartFirstCreatePass(adjustedIndex, tView, lView, native, name, attrsIndex, localRefsIndex) :
15314
15336
  tView.data[adjustedIndex];
15315
15337
  setCurrentTNode(tNode, true);
15316
- const mergedAttrs = tNode.mergedAttrs;
15317
- if (mergedAttrs !== null) {
15318
- setUpAttributes(renderer, native, mergedAttrs);
15319
- }
15320
- const classes = tNode.classes;
15321
- if (classes !== null) {
15322
- writeDirectClass(renderer, native, classes);
15323
- }
15324
- const styles = tNode.styles;
15325
- if (styles !== null) {
15326
- writeDirectStyle(renderer, native, styles);
15327
- }
15338
+ setupStaticAttributes(renderer, native, tNode);
15328
15339
  if ((tNode.flags & 32 /* TNodeFlags.isDetached */) !== 32 /* TNodeFlags.isDetached */) {
15329
15340
  // In the i18n case, the translation may have removed this element, so only add it if it is not
15330
15341
  // detached. See `TNodeType.Placeholder` and `LFrame.inI18n` for more context.
@@ -22014,7 +22025,7 @@ function getDirectives(node) {
22014
22025
  return [];
22015
22026
  }
22016
22027
  if (context.directives === undefined) {
22017
- context.directives = getDirectivesAtNodeIndex(nodeIndex, lView, false);
22028
+ context.directives = getDirectivesAtNodeIndex(nodeIndex, lView);
22018
22029
  }
22019
22030
  // The `directives` in this case are a named array called `LComponentView`. Clone the
22020
22031
  // result so we don't expose an internal data structure in the user's console.
@@ -26013,6 +26024,35 @@ function getNativeRequestAnimationFrame() {
26013
26024
  return { nativeRequestAnimationFrame, nativeCancelAnimationFrame };
26014
26025
  }
26015
26026
 
26027
+ /**
26028
+ * @license
26029
+ * Copyright Google LLC All Rights Reserved.
26030
+ *
26031
+ * Use of this source code is governed by an MIT-style license that can be
26032
+ * found in the LICENSE file at https://angular.io/license
26033
+ */
26034
+ class AsyncStackTaggingZoneSpec {
26035
+ constructor(namePrefix, consoleAsyncStackTaggingImpl = console) {
26036
+ var _a;
26037
+ this.name = 'asyncStackTagging for ' + namePrefix;
26038
+ this.createTask = (_a = consoleAsyncStackTaggingImpl === null || consoleAsyncStackTaggingImpl === void 0 ? void 0 : consoleAsyncStackTaggingImpl.createTask) !== null && _a !== void 0 ? _a : (() => null);
26039
+ }
26040
+ onScheduleTask(delegate, _current, target, task) {
26041
+ task.consoleTask = this.createTask(`Zone - ${task.source || task.type}`);
26042
+ return delegate.scheduleTask(target, task);
26043
+ }
26044
+ onInvokeTask(delegate, _currentZone, targetZone, task, applyThis, applyArgs) {
26045
+ let ret;
26046
+ if (task.consoleTask) {
26047
+ ret = task.consoleTask.run(() => delegate.invokeTask(targetZone, task, applyThis, applyArgs));
26048
+ }
26049
+ else {
26050
+ ret = delegate.invokeTask(targetZone, task, applyThis, applyArgs);
26051
+ }
26052
+ return ret;
26053
+ }
26054
+ }
26055
+
26016
26056
  /**
26017
26057
  * @license
26018
26058
  * Copyright Google LLC All Rights Reserved.
@@ -26129,8 +26169,12 @@ class NgZone {
26129
26169
  const self = this;
26130
26170
  self._nesting = 0;
26131
26171
  self._outer = self._inner = Zone.current;
26132
- if (Zone['AsyncStackTaggingZoneSpec']) {
26133
- const AsyncStackTaggingZoneSpec = Zone['AsyncStackTaggingZoneSpec'];
26172
+ // AsyncStackTaggingZoneSpec provides `linked stack traces` to show
26173
+ // where the async operation is scheduled. For more details, refer
26174
+ // to this article, https://developer.chrome.com/blog/devtools-better-angular-debugging/
26175
+ // And we only import this AsyncStackTaggingZoneSpec in development mode,
26176
+ // in the production mode, the AsyncStackTaggingZoneSpec will be tree shaken away.
26177
+ if (ngDevMode) {
26134
26178
  self._inner = self._inner.fork(new AsyncStackTaggingZoneSpec('Angular'));
26135
26179
  }
26136
26180
  if (Zone['TaskTrackingZoneSpec']) {
@@ -27577,24 +27621,16 @@ function _mergeArrays(parts) {
27577
27621
  * found in the LICENSE file at https://angular.io/license
27578
27622
  */
27579
27623
  /**
27580
- * This file is used to control if the default rendering pipeline should be `ViewEngine` or `Ivy`.
27581
- *
27582
- * For more information on how to run and debug tests with either Ivy or View Engine (legacy),
27583
- * please see [BAZEL.md](./docs/BAZEL.md).
27584
- */
27585
- let _devMode = true;
27586
- let _runModeLocked = false;
27587
- /**
27588
- * Returns whether Angular is in development mode. After called once,
27589
- * the value is locked and won't change any more.
27624
+ * Returns whether Angular is in development mode.
27590
27625
  *
27591
- * By default, this is true, unless a user calls `enableProdMode` before calling this.
27626
+ * By default, this is true, unless `enableProdMode` is invoked prior to calling this method or the
27627
+ * application is built using the Angular CLI with the `optimization` option.
27628
+ * @see {@link cli/build ng build}
27592
27629
  *
27593
27630
  * @publicApi
27594
27631
  */
27595
27632
  function isDevMode() {
27596
- _runModeLocked = true;
27597
- return _devMode;
27633
+ return typeof ngDevMode === 'undefined' || !!ngDevMode;
27598
27634
  }
27599
27635
  /**
27600
27636
  * Disable Angular's development mode, which turns off assertions and other
@@ -27604,18 +27640,18 @@ function isDevMode() {
27604
27640
  * does not result in additional changes to any bindings (also known as
27605
27641
  * unidirectional data flow).
27606
27642
  *
27643
+ * Using this method is discouraged as the Angular CLI will set production mode when using the
27644
+ * `optimization` option.
27645
+ * @see {@link cli/build ng build}
27646
+ *
27607
27647
  * @publicApi
27608
27648
  */
27609
27649
  function enableProdMode() {
27610
- if (_runModeLocked) {
27611
- throw new Error('Cannot enable prod mode after platform setup.');
27612
- }
27613
27650
  // The below check is there so when ngDevMode is set via terser
27614
27651
  // `global['ngDevMode'] = false;` is also dropped.
27615
- if (typeof ngDevMode === undefined || !!ngDevMode) {
27652
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
27616
27653
  _global['ngDevMode'] = false;
27617
27654
  }
27618
- _devMode = false;
27619
27655
  }
27620
27656
 
27621
27657
  /**
@@ -29857,5 +29893,5 @@ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
29857
29893
  * Generated bundle index. Do not edit.
29858
29894
  */
29859
29895
 
29860
- export { ANALYZE_FOR_ENTRY_COMPONENTS, ANIMATION_MODULE_TYPE, APP_BOOTSTRAP_LISTENER, APP_ID, APP_INITIALIZER, ApplicationInitStatus, ApplicationModule, ApplicationRef, Attribute, COMPILER_OPTIONS, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, ChangeDetectorRef, Compiler, CompilerFactory, Component, ComponentFactory$1 as ComponentFactory, ComponentFactoryResolver$1 as ComponentFactoryResolver, ComponentRef$1 as ComponentRef, ContentChild, ContentChildren, DEFAULT_CURRENCY_CODE, DebugElement, DebugEventListener, DebugNode, DefaultIterableDiffer, Directive, ENVIRONMENT_INITIALIZER, ElementRef, EmbeddedViewRef, EnvironmentInjector, ErrorHandler, EventEmitter, Host, HostBinding, HostListener, INJECTOR, Inject, InjectFlags, Injectable, InjectionToken, Injector, Input, IterableDiffers, KeyValueDiffers, LOCALE_ID, MissingTranslationStrategy, ModuleWithComponentFactories, NO_ERRORS_SCHEMA, NgModule, NgModuleFactory$1 as NgModuleFactory, NgModuleRef$1 as NgModuleRef, NgProbeToken, NgZone, Optional, Output, PACKAGE_ROOT_URL, PLATFORM_ID, PLATFORM_INITIALIZER, Pipe, PlatformRef, Query, QueryList, ReflectiveInjector, ReflectiveKey, Renderer2, RendererFactory2, RendererStyleFlags2, ResolvedReflectiveFactory, Sanitizer, SecurityContext, Self, SimpleChange, SkipSelf, TRANSLATIONS, TRANSLATIONS_FORMAT, TemplateRef, Testability, TestabilityRegistry, Type, VERSION, Version, ViewChild, ViewChildren, ViewContainerRef, ViewEncapsulation$1 as ViewEncapsulation, ViewRef, asNativeElements, assertPlatform, createComponent, createEnvironmentInjector, createNgModule, createNgModuleRef, createPlatform, createPlatformFactory, defineInjectable, destroyPlatform, enableProdMode, forwardRef, getDebugNode, getModuleFactory, getNgModuleById, getPlatform, importProvidersFrom, inject, isDevMode, platformCore, reflectComponentType, resolveForwardRef, setTestabilityGetter, ALLOW_MULTIPLE_PLATFORMS as ɵALLOW_MULTIPLE_PLATFORMS, APP_ID_RANDOM_PROVIDER as ɵAPP_ID_RANDOM_PROVIDER, ChangeDetectorStatus as ɵChangeDetectorStatus, ComponentFactory$1 as ɵComponentFactory, Console as ɵConsole, DEFAULT_LOCALE_ID as ɵDEFAULT_LOCALE_ID, INJECTOR_SCOPE as ɵINJECTOR_SCOPE, LContext as ɵLContext, LifecycleHooksFeature as ɵLifecycleHooksFeature, LocaleDataIndex as ɵLocaleDataIndex, NG_COMP_DEF as ɵNG_COMP_DEF, NG_DIR_DEF as ɵNG_DIR_DEF, NG_ELEMENT_ID as ɵNG_ELEMENT_ID, NG_INJ_DEF as ɵNG_INJ_DEF, NG_MOD_DEF as ɵNG_MOD_DEF, NG_PIPE_DEF as ɵNG_PIPE_DEF, NG_PROV_DEF as ɵNG_PROV_DEF, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, NO_CHANGE as ɵNO_CHANGE, NgModuleFactory as ɵNgModuleFactory, NoopNgZone as ɵNoopNgZone, ReflectionCapabilities as ɵReflectionCapabilities, ComponentFactory as ɵRender3ComponentFactory, ComponentRef as ɵRender3ComponentRef, NgModuleRef as ɵRender3NgModuleRef, RuntimeError as ɵRuntimeError, TESTABILITY as ɵTESTABILITY, TESTABILITY_GETTER as ɵTESTABILITY_GETTER, ViewRef$1 as ɵViewRef, _sanitizeHtml as ɵ_sanitizeHtml, _sanitizeUrl as ɵ_sanitizeUrl, allowSanitizationBypassAndThrow as ɵallowSanitizationBypassAndThrow, bypassSanitizationTrustHtml as ɵbypassSanitizationTrustHtml, bypassSanitizationTrustResourceUrl as ɵbypassSanitizationTrustResourceUrl, bypassSanitizationTrustScript as ɵbypassSanitizationTrustScript, bypassSanitizationTrustStyle as ɵbypassSanitizationTrustStyle, bypassSanitizationTrustUrl as ɵbypassSanitizationTrustUrl, clearResolutionOfComponentResourcesQueue as ɵclearResolutionOfComponentResourcesQueue, coerceToBoolean as ɵcoerceToBoolean, compileComponent as ɵcompileComponent, compileDirective as ɵcompileDirective, compileNgModule as ɵcompileNgModule, compileNgModuleDefs as ɵcompileNgModuleDefs, compileNgModuleFactory as ɵcompileNgModuleFactory, compilePipe as ɵcompilePipe, createInjector as ɵcreateInjector, defaultIterableDiffers as ɵdefaultIterableDiffers, defaultKeyValueDiffers as ɵdefaultKeyValueDiffers, detectChanges as ɵdetectChanges, devModeEqual as ɵdevModeEqual, findLocaleData as ɵfindLocaleData, flushModuleScopingQueueAsMuchAsPossible as ɵflushModuleScopingQueueAsMuchAsPossible, formatRuntimeError as ɵformatRuntimeError, getDebugNode as ɵgetDebugNode, getDebugNodeR2 as ɵgetDebugNodeR2, getDirectives as ɵgetDirectives, getHostElement as ɵgetHostElement, getInjectableDef as ɵgetInjectableDef, getLContext as ɵgetLContext, getLocaleCurrencyCode as ɵgetLocaleCurrencyCode, getLocalePluralCase as ɵgetLocalePluralCase, getSanitizationBypassType as ɵgetSanitizationBypassType, ɵgetUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode, _global as ɵglobal, injectChangeDetectorRef as ɵinjectChangeDetectorRef, internalCreateApplication as ɵinternalCreateApplication, isBoundToModule as ɵisBoundToModule, isDefaultChangeDetectionStrategy as ɵisDefaultChangeDetectionStrategy, isInjectable as ɵisInjectable, isListLikeIterable as ɵisListLikeIterable, isObservable as ɵisObservable, isPromise as ɵisPromise, isStandalone as ɵisStandalone, isSubscribable as ɵisSubscribable, ɵivyEnabled, makeDecorator as ɵmakeDecorator, noSideEffects as ɵnoSideEffects, patchComponentDefWithScope as ɵpatchComponentDefWithScope, publishDefaultGlobalUtils$1 as ɵpublishDefaultGlobalUtils, publishGlobalUtil as ɵpublishGlobalUtil, registerLocaleData as ɵregisterLocaleData, resetCompiledComponents as ɵresetCompiledComponents, resetJitOptions as ɵresetJitOptions, resolveComponentResources as ɵresolveComponentResources, setAllowDuplicateNgModuleIdsForTest as ɵsetAllowDuplicateNgModuleIdsForTest, setClassMetadata as ɵsetClassMetadata, setCurrentInjector as ɵsetCurrentInjector, setDocument as ɵsetDocument, setLocaleId as ɵsetLocaleId, ɵsetUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode, store as ɵstore, stringify as ɵstringify, transitiveScopesFor as ɵtransitiveScopesFor, unregisterAllLocaleData as ɵunregisterLocaleData, unwrapSafeValue as ɵunwrapSafeValue, ɵɵCopyDefinitionFeature, FactoryTarget as ɵɵFactoryTarget, ɵɵHostDirectivesFeature, ɵɵInheritDefinitionFeature, ɵɵNgOnChangesFeature, ɵɵProvidersFeature, ɵɵStandaloneFeature, ɵɵadvance, ɵɵattribute, ɵɵattributeInterpolate1, ɵɵattributeInterpolate2, ɵɵattributeInterpolate3, ɵɵattributeInterpolate4, ɵɵattributeInterpolate5, ɵɵattributeInterpolate6, ɵɵattributeInterpolate7, ɵɵattributeInterpolate8, ɵɵattributeInterpolateV, ɵɵclassMap, ɵɵclassMapInterpolate1, ɵɵclassMapInterpolate2, ɵɵclassMapInterpolate3, ɵɵclassMapInterpolate4, ɵɵclassMapInterpolate5, ɵɵclassMapInterpolate6, ɵɵclassMapInterpolate7, ɵɵclassMapInterpolate8, ɵɵclassMapInterpolateV, ɵɵclassProp, ɵɵcontentQuery, ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdefineInjectable, ɵɵdefineInjector, ɵɵdefineNgModule, ɵɵdefinePipe, ɵɵdirectiveInject, ɵɵdisableBindings, ɵɵelement, ɵɵelementContainer, ɵɵelementContainerEnd, ɵɵelementContainerStart, ɵɵelementEnd, ɵɵelementStart, ɵɵenableBindings, ɵɵgetCurrentView, ɵɵgetInheritedFactory, ɵɵhostProperty, ɵɵi18n, ɵɵi18nApply, ɵɵi18nAttributes, ɵɵi18nEnd, ɵɵi18nExp, ɵɵi18nPostprocess, ɵɵi18nStart, ɵɵinject, ɵɵinjectAttribute, ɵɵinvalidFactory, ɵɵinvalidFactoryDep, ɵɵlistener, ɵɵloadQuery, ɵɵnamespaceHTML, ɵɵnamespaceMathML, ɵɵnamespaceSVG, ɵɵnextContext, ɵɵngDeclareClassMetadata, ɵɵngDeclareComponent, ɵɵngDeclareDirective, ɵɵngDeclareFactory, ɵɵngDeclareInjectable, ɵɵngDeclareInjector, ɵɵngDeclareNgModule, ɵɵngDeclarePipe, ɵɵpipe, ɵɵpipeBind1, ɵɵpipeBind2, ɵɵpipeBind3, ɵɵpipeBind4, ɵɵpipeBindV, ɵɵprojection, ɵɵprojectionDef, ɵɵproperty, ɵɵpropertyInterpolate, ɵɵpropertyInterpolate1, ɵɵpropertyInterpolate2, ɵɵpropertyInterpolate3, ɵɵpropertyInterpolate4, ɵɵpropertyInterpolate5, ɵɵpropertyInterpolate6, ɵɵpropertyInterpolate7, ɵɵpropertyInterpolate8, ɵɵpropertyInterpolateV, ɵɵpureFunction0, ɵɵpureFunction1, ɵɵpureFunction2, ɵɵpureFunction3, ɵɵpureFunction4, ɵɵpureFunction5, ɵɵpureFunction6, ɵɵpureFunction7, ɵɵpureFunction8, ɵɵpureFunctionV, ɵɵqueryRefresh, ɵɵreference, registerNgModuleType as ɵɵregisterNgModuleType, ɵɵresetView, ɵɵresolveBody, ɵɵresolveDocument, ɵɵresolveWindow, ɵɵrestoreView, ɵɵsanitizeHtml, ɵɵsanitizeResourceUrl, ɵɵsanitizeScript, ɵɵsanitizeStyle, ɵɵsanitizeUrl, ɵɵsanitizeUrlOrResourceUrl, ɵɵsetComponentScope, ɵɵsetNgModuleScope, ɵɵstyleMap, ɵɵstyleMapInterpolate1, ɵɵstyleMapInterpolate2, ɵɵstyleMapInterpolate3, ɵɵstyleMapInterpolate4, ɵɵstyleMapInterpolate5, ɵɵstyleMapInterpolate6, ɵɵstyleMapInterpolate7, ɵɵstyleMapInterpolate8, ɵɵstyleMapInterpolateV, ɵɵstyleProp, ɵɵstylePropInterpolate1, ɵɵstylePropInterpolate2, ɵɵstylePropInterpolate3, ɵɵstylePropInterpolate4, ɵɵstylePropInterpolate5, ɵɵstylePropInterpolate6, ɵɵstylePropInterpolate7, ɵɵstylePropInterpolate8, ɵɵstylePropInterpolateV, ɵɵsyntheticHostListener, ɵɵsyntheticHostProperty, ɵɵtemplate, ɵɵtemplateRefExtractor, ɵɵtext, ɵɵtextInterpolate, ɵɵtextInterpolate1, ɵɵtextInterpolate2, ɵɵtextInterpolate3, ɵɵtextInterpolate4, ɵɵtextInterpolate5, ɵɵtextInterpolate6, ɵɵtextInterpolate7, ɵɵtextInterpolate8, ɵɵtextInterpolateV, ɵɵtrustConstantHtml, ɵɵtrustConstantResourceUrl, ɵɵviewQuery };
29896
+ export { ANALYZE_FOR_ENTRY_COMPONENTS, ANIMATION_MODULE_TYPE, APP_BOOTSTRAP_LISTENER, APP_ID, APP_INITIALIZER, ApplicationInitStatus, ApplicationModule, ApplicationRef, Attribute, COMPILER_OPTIONS, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, ChangeDetectorRef, Compiler, CompilerFactory, Component, ComponentFactory$1 as ComponentFactory, ComponentFactoryResolver$1 as ComponentFactoryResolver, ComponentRef$1 as ComponentRef, ContentChild, ContentChildren, DEFAULT_CURRENCY_CODE, DebugElement, DebugEventListener, DebugNode, DefaultIterableDiffer, Directive, ENVIRONMENT_INITIALIZER, ElementRef, EmbeddedViewRef, EnvironmentInjector, ErrorHandler, EventEmitter, Host, HostBinding, HostListener, INJECTOR, Inject, InjectFlags, Injectable, InjectionToken, Injector, Input, IterableDiffers, KeyValueDiffers, LOCALE_ID, MissingTranslationStrategy, ModuleWithComponentFactories, NO_ERRORS_SCHEMA, NgModule, NgModuleFactory$1 as NgModuleFactory, NgModuleRef$1 as NgModuleRef, NgProbeToken, NgZone, Optional, Output, PACKAGE_ROOT_URL, PLATFORM_ID, PLATFORM_INITIALIZER, Pipe, PlatformRef, Query, QueryList, ReflectiveInjector, ReflectiveKey, Renderer2, RendererFactory2, RendererStyleFlags2, ResolvedReflectiveFactory, Sanitizer, SecurityContext, Self, SimpleChange, SkipSelf, TRANSLATIONS, TRANSLATIONS_FORMAT, TemplateRef, Testability, TestabilityRegistry, Type, VERSION, Version, ViewChild, ViewChildren, ViewContainerRef, ViewEncapsulation$1 as ViewEncapsulation, ViewRef, asNativeElements, assertPlatform, createComponent, createEnvironmentInjector, createNgModule, createNgModuleRef, createPlatform, createPlatformFactory, defineInjectable, destroyPlatform, enableProdMode, forwardRef, getDebugNode, getModuleFactory, getNgModuleById, getPlatform, importProvidersFrom, inject, isDevMode, platformCore, reflectComponentType, resolveForwardRef, setTestabilityGetter, ALLOW_MULTIPLE_PLATFORMS as ɵALLOW_MULTIPLE_PLATFORMS, APP_ID_RANDOM_PROVIDER as ɵAPP_ID_RANDOM_PROVIDER, ChangeDetectorStatus as ɵChangeDetectorStatus, ComponentFactory$1 as ɵComponentFactory, Console as ɵConsole, DEFAULT_LOCALE_ID as ɵDEFAULT_LOCALE_ID, INJECTOR_SCOPE as ɵINJECTOR_SCOPE, LContext as ɵLContext, LifecycleHooksFeature as ɵLifecycleHooksFeature, LocaleDataIndex as ɵLocaleDataIndex, NG_COMP_DEF as ɵNG_COMP_DEF, NG_DIR_DEF as ɵNG_DIR_DEF, NG_ELEMENT_ID as ɵNG_ELEMENT_ID, NG_INJ_DEF as ɵNG_INJ_DEF, NG_MOD_DEF as ɵNG_MOD_DEF, NG_PIPE_DEF as ɵNG_PIPE_DEF, NG_PROV_DEF as ɵNG_PROV_DEF, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, NO_CHANGE as ɵNO_CHANGE, NgModuleFactory as ɵNgModuleFactory, NoopNgZone as ɵNoopNgZone, ReflectionCapabilities as ɵReflectionCapabilities, ComponentFactory as ɵRender3ComponentFactory, ComponentRef as ɵRender3ComponentRef, NgModuleRef as ɵRender3NgModuleRef, RuntimeError as ɵRuntimeError, TESTABILITY as ɵTESTABILITY, TESTABILITY_GETTER as ɵTESTABILITY_GETTER, ViewRef$1 as ɵViewRef, _sanitizeHtml as ɵ_sanitizeHtml, _sanitizeUrl as ɵ_sanitizeUrl, allowSanitizationBypassAndThrow as ɵallowSanitizationBypassAndThrow, bypassSanitizationTrustHtml as ɵbypassSanitizationTrustHtml, bypassSanitizationTrustResourceUrl as ɵbypassSanitizationTrustResourceUrl, bypassSanitizationTrustScript as ɵbypassSanitizationTrustScript, bypassSanitizationTrustStyle as ɵbypassSanitizationTrustStyle, bypassSanitizationTrustUrl as ɵbypassSanitizationTrustUrl, clearResolutionOfComponentResourcesQueue as ɵclearResolutionOfComponentResourcesQueue, coerceToBoolean as ɵcoerceToBoolean, compileComponent as ɵcompileComponent, compileDirective as ɵcompileDirective, compileNgModule as ɵcompileNgModule, compileNgModuleDefs as ɵcompileNgModuleDefs, compileNgModuleFactory as ɵcompileNgModuleFactory, compilePipe as ɵcompilePipe, convertToBitFlags as ɵconvertToBitFlags, createInjector as ɵcreateInjector, defaultIterableDiffers as ɵdefaultIterableDiffers, defaultKeyValueDiffers as ɵdefaultKeyValueDiffers, detectChanges as ɵdetectChanges, devModeEqual as ɵdevModeEqual, findLocaleData as ɵfindLocaleData, flushModuleScopingQueueAsMuchAsPossible as ɵflushModuleScopingQueueAsMuchAsPossible, formatRuntimeError as ɵformatRuntimeError, getDebugNode as ɵgetDebugNode, getDebugNodeR2 as ɵgetDebugNodeR2, getDirectives as ɵgetDirectives, getHostElement as ɵgetHostElement, getInjectableDef as ɵgetInjectableDef, getLContext as ɵgetLContext, getLocaleCurrencyCode as ɵgetLocaleCurrencyCode, getLocalePluralCase as ɵgetLocalePluralCase, getSanitizationBypassType as ɵgetSanitizationBypassType, ɵgetUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode, _global as ɵglobal, injectChangeDetectorRef as ɵinjectChangeDetectorRef, internalCreateApplication as ɵinternalCreateApplication, isBoundToModule as ɵisBoundToModule, isDefaultChangeDetectionStrategy as ɵisDefaultChangeDetectionStrategy, isInjectable as ɵisInjectable, isListLikeIterable as ɵisListLikeIterable, isObservable as ɵisObservable, isPromise as ɵisPromise, isStandalone as ɵisStandalone, isSubscribable as ɵisSubscribable, ɵivyEnabled, makeDecorator as ɵmakeDecorator, noSideEffects as ɵnoSideEffects, patchComponentDefWithScope as ɵpatchComponentDefWithScope, publishDefaultGlobalUtils$1 as ɵpublishDefaultGlobalUtils, publishGlobalUtil as ɵpublishGlobalUtil, registerLocaleData as ɵregisterLocaleData, resetCompiledComponents as ɵresetCompiledComponents, resetJitOptions as ɵresetJitOptions, resolveComponentResources as ɵresolveComponentResources, setAllowDuplicateNgModuleIdsForTest as ɵsetAllowDuplicateNgModuleIdsForTest, setClassMetadata as ɵsetClassMetadata, setCurrentInjector as ɵsetCurrentInjector, setDocument as ɵsetDocument, setLocaleId as ɵsetLocaleId, ɵsetUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode, store as ɵstore, stringify as ɵstringify, transitiveScopesFor as ɵtransitiveScopesFor, unregisterAllLocaleData as ɵunregisterLocaleData, unwrapSafeValue as ɵunwrapSafeValue, ɵɵCopyDefinitionFeature, FactoryTarget as ɵɵFactoryTarget, ɵɵHostDirectivesFeature, ɵɵInheritDefinitionFeature, ɵɵNgOnChangesFeature, ɵɵProvidersFeature, ɵɵStandaloneFeature, ɵɵadvance, ɵɵattribute, ɵɵattributeInterpolate1, ɵɵattributeInterpolate2, ɵɵattributeInterpolate3, ɵɵattributeInterpolate4, ɵɵattributeInterpolate5, ɵɵattributeInterpolate6, ɵɵattributeInterpolate7, ɵɵattributeInterpolate8, ɵɵattributeInterpolateV, ɵɵclassMap, ɵɵclassMapInterpolate1, ɵɵclassMapInterpolate2, ɵɵclassMapInterpolate3, ɵɵclassMapInterpolate4, ɵɵclassMapInterpolate5, ɵɵclassMapInterpolate6, ɵɵclassMapInterpolate7, ɵɵclassMapInterpolate8, ɵɵclassMapInterpolateV, ɵɵclassProp, ɵɵcontentQuery, ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdefineInjectable, ɵɵdefineInjector, ɵɵdefineNgModule, ɵɵdefinePipe, ɵɵdirectiveInject, ɵɵdisableBindings, ɵɵelement, ɵɵelementContainer, ɵɵelementContainerEnd, ɵɵelementContainerStart, ɵɵelementEnd, ɵɵelementStart, ɵɵenableBindings, ɵɵgetCurrentView, ɵɵgetInheritedFactory, ɵɵhostProperty, ɵɵi18n, ɵɵi18nApply, ɵɵi18nAttributes, ɵɵi18nEnd, ɵɵi18nExp, ɵɵi18nPostprocess, ɵɵi18nStart, ɵɵinject, ɵɵinjectAttribute, ɵɵinvalidFactory, ɵɵinvalidFactoryDep, ɵɵlistener, ɵɵloadQuery, ɵɵnamespaceHTML, ɵɵnamespaceMathML, ɵɵnamespaceSVG, ɵɵnextContext, ɵɵngDeclareClassMetadata, ɵɵngDeclareComponent, ɵɵngDeclareDirective, ɵɵngDeclareFactory, ɵɵngDeclareInjectable, ɵɵngDeclareInjector, ɵɵngDeclareNgModule, ɵɵngDeclarePipe, ɵɵpipe, ɵɵpipeBind1, ɵɵpipeBind2, ɵɵpipeBind3, ɵɵpipeBind4, ɵɵpipeBindV, ɵɵprojection, ɵɵprojectionDef, ɵɵproperty, ɵɵpropertyInterpolate, ɵɵpropertyInterpolate1, ɵɵpropertyInterpolate2, ɵɵpropertyInterpolate3, ɵɵpropertyInterpolate4, ɵɵpropertyInterpolate5, ɵɵpropertyInterpolate6, ɵɵpropertyInterpolate7, ɵɵpropertyInterpolate8, ɵɵpropertyInterpolateV, ɵɵpureFunction0, ɵɵpureFunction1, ɵɵpureFunction2, ɵɵpureFunction3, ɵɵpureFunction4, ɵɵpureFunction5, ɵɵpureFunction6, ɵɵpureFunction7, ɵɵpureFunction8, ɵɵpureFunctionV, ɵɵqueryRefresh, ɵɵreference, registerNgModuleType as ɵɵregisterNgModuleType, ɵɵresetView, ɵɵresolveBody, ɵɵresolveDocument, ɵɵresolveWindow, ɵɵrestoreView, ɵɵsanitizeHtml, ɵɵsanitizeResourceUrl, ɵɵsanitizeScript, ɵɵsanitizeStyle, ɵɵsanitizeUrl, ɵɵsanitizeUrlOrResourceUrl, ɵɵsetComponentScope, ɵɵsetNgModuleScope, ɵɵstyleMap, ɵɵstyleMapInterpolate1, ɵɵstyleMapInterpolate2, ɵɵstyleMapInterpolate3, ɵɵstyleMapInterpolate4, ɵɵstyleMapInterpolate5, ɵɵstyleMapInterpolate6, ɵɵstyleMapInterpolate7, ɵɵstyleMapInterpolate8, ɵɵstyleMapInterpolateV, ɵɵstyleProp, ɵɵstylePropInterpolate1, ɵɵstylePropInterpolate2, ɵɵstylePropInterpolate3, ɵɵstylePropInterpolate4, ɵɵstylePropInterpolate5, ɵɵstylePropInterpolate6, ɵɵstylePropInterpolate7, ɵɵstylePropInterpolate8, ɵɵstylePropInterpolateV, ɵɵsyntheticHostListener, ɵɵsyntheticHostProperty, ɵɵtemplate, ɵɵtemplateRefExtractor, ɵɵtext, ɵɵtextInterpolate, ɵɵtextInterpolate1, ɵɵtextInterpolate2, ɵɵtextInterpolate3, ɵɵtextInterpolate4, ɵɵtextInterpolate5, ɵɵtextInterpolate6, ɵɵtextInterpolate7, ɵɵtextInterpolate8, ɵɵtextInterpolateV, ɵɵtrustConstantHtml, ɵɵtrustConstantResourceUrl, ɵɵviewQuery };
29861
29897
  //# sourceMappingURL=core.mjs.map