@angular/core 7.2.0-rc.0 → 7.2.0

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 (128) hide show
  1. package/bundles/core-testing.umd.js +190 -128
  2. package/bundles/core-testing.umd.js.map +1 -1
  3. package/bundles/core-testing.umd.min.js +10 -10
  4. package/bundles/core-testing.umd.min.js.map +1 -1
  5. package/bundles/core.umd.js +1772 -1324
  6. package/bundles/core.umd.js.map +1 -1
  7. package/bundles/core.umd.min.js +110 -124
  8. package/bundles/core.umd.min.js.map +1 -1
  9. package/core.metadata.json +1 -1
  10. package/esm2015/index.js +2 -2
  11. package/esm2015/public_api.js +2 -2
  12. package/esm2015/src/change_detection/constants.js +3 -3
  13. package/esm2015/src/core.js +2 -2
  14. package/esm2015/src/core_render3_private_export.js +2 -2
  15. package/esm2015/src/debug/debug_node.js +6 -6
  16. package/esm2015/src/render3/bindings.js +3 -3
  17. package/esm2015/src/render3/component.js +8 -6
  18. package/esm2015/src/render3/component_ref.js +5 -5
  19. package/esm2015/src/render3/context_discovery.js +2 -2
  20. package/esm2015/src/render3/definition.js +3 -10
  21. package/esm2015/src/render3/di.js +107 -93
  22. package/esm2015/src/render3/discovery_utils.js +5 -5
  23. package/esm2015/src/render3/empty.js +28 -0
  24. package/esm2015/src/render3/features/inherit_definition_feature.js +3 -3
  25. package/esm2015/src/render3/hooks.js +14 -12
  26. package/esm2015/src/render3/i18n.js +3 -3
  27. package/esm2015/src/render3/index.js +2 -2
  28. package/esm2015/src/render3/instructions.js +319 -370
  29. package/esm2015/src/render3/interfaces/container.js +10 -1
  30. package/esm2015/src/render3/interfaces/definition.js +1 -6
  31. package/esm2015/src/render3/interfaces/injector.js +1 -2
  32. package/esm2015/src/render3/interfaces/node.js +37 -2
  33. package/esm2015/src/render3/interfaces/styling.js +304 -113
  34. package/esm2015/src/render3/interfaces/view.js +15 -7
  35. package/esm2015/src/render3/jit/compiler_facade_interface.js +3 -1
  36. package/esm2015/src/render3/jit/directive.js +6 -7
  37. package/esm2015/src/render3/jit/environment.js +3 -1
  38. package/esm2015/src/render3/jit/module.js +11 -9
  39. package/esm2015/src/render3/node_manipulation.js +5 -22
  40. package/esm2015/src/render3/node_selector_matcher.js +2 -2
  41. package/esm2015/src/render3/pipe.js +2 -2
  42. package/esm2015/src/render3/pure_function.js +3 -3
  43. package/esm2015/src/render3/query.js +3 -3
  44. package/esm2015/src/render3/state.js +14 -20
  45. package/esm2015/src/render3/styling/class_and_style_bindings.js +893 -213
  46. package/esm2015/src/render3/styling/util.js +37 -14
  47. package/esm2015/src/render3/util.js +21 -5
  48. package/esm2015/src/render3/view_engine_compatibility.js +5 -6
  49. package/esm2015/src/render3/view_ref.js +6 -16
  50. package/esm2015/src/sanitization/inert_body.js +4 -4
  51. package/esm2015/src/version.js +1 -1
  52. package/esm2015/testing/src/r3_test_bed.js +234 -152
  53. package/esm2015/testing/src/resolvers.js +12 -5
  54. package/esm2015/testing/src/testing_internal.js +2 -2
  55. package/esm5/src/change_detection/constants.js +3 -3
  56. package/esm5/src/core_render3_private_export.js +2 -2
  57. package/esm5/src/debug/debug_node.js +6 -6
  58. package/esm5/src/render3/bindings.js +3 -3
  59. package/esm5/src/render3/component.js +8 -6
  60. package/esm5/src/render3/component_ref.js +5 -5
  61. package/esm5/src/render3/context_discovery.js +2 -2
  62. package/esm5/src/render3/definition.js +3 -8
  63. package/esm5/src/render3/di.js +94 -84
  64. package/esm5/src/render3/discovery_utils.js +5 -5
  65. package/esm5/src/render3/empty.js +22 -0
  66. package/esm5/src/render3/features/inherit_definition_feature.js +3 -3
  67. package/esm5/src/render3/hooks.js +11 -9
  68. package/esm5/src/render3/i18n.js +3 -3
  69. package/esm5/src/render3/index.js +2 -2
  70. package/esm5/src/render3/instructions.js +282 -282
  71. package/esm5/src/render3/interfaces/container.js +9 -1
  72. package/esm5/src/render3/interfaces/definition.js +1 -1
  73. package/esm5/src/render3/interfaces/injector.js +1 -1
  74. package/esm5/src/render3/interfaces/node.js +1 -1
  75. package/esm5/src/render3/interfaces/styling.js +1 -1
  76. package/esm5/src/render3/interfaces/view.js +1 -1
  77. package/esm5/src/render3/jit/compiler_facade_interface.js +1 -1
  78. package/esm5/src/render3/jit/directive.js +6 -6
  79. package/esm5/src/render3/jit/environment.js +3 -1
  80. package/esm5/src/render3/jit/module.js +10 -8
  81. package/esm5/src/render3/node_manipulation.js +5 -21
  82. package/esm5/src/render3/node_selector_matcher.js +2 -2
  83. package/esm5/src/render3/pipe.js +2 -2
  84. package/esm5/src/render3/pure_function.js +3 -3
  85. package/esm5/src/render3/query.js +3 -3
  86. package/esm5/src/render3/state.js +14 -19
  87. package/esm5/src/render3/styling/class_and_style_bindings.js +681 -210
  88. package/esm5/src/render3/styling/util.js +26 -13
  89. package/esm5/src/render3/util.js +20 -5
  90. package/esm5/src/render3/view_engine_compatibility.js +5 -6
  91. package/esm5/src/render3/view_ref.js +6 -15
  92. package/esm5/src/sanitization/inert_body.js +4 -4
  93. package/esm5/src/version.js +1 -1
  94. package/esm5/testing/src/r3_test_bed.js +174 -127
  95. package/esm5/testing/src/resolvers.js +11 -6
  96. package/esm5/testing/src/testing_internal.js +2 -2
  97. package/fesm2015/core.js +2304 -1731
  98. package/fesm2015/core.js.map +1 -1
  99. package/fesm2015/testing.js +223 -150
  100. package/fesm2015/testing.js.map +1 -1
  101. package/fesm5/core.js +1777 -1331
  102. package/fesm5/core.js.map +1 -1
  103. package/fesm5/testing.js +181 -130
  104. package/fesm5/testing.js.map +1 -1
  105. package/package.json +1 -1
  106. package/src/change_detection/constants.d.ts +2 -2
  107. package/src/core_render3_private_export.d.ts +1 -1
  108. package/src/render3/definition.d.ts +2 -4
  109. package/src/render3/di.d.ts +4 -3
  110. package/src/render3/empty.d.ts +16 -0
  111. package/src/render3/hooks.d.ts +3 -3
  112. package/src/render3/index.d.ts +1 -1
  113. package/src/render3/instructions.d.ts +117 -72
  114. package/src/render3/interfaces/container.d.ts +1 -0
  115. package/src/render3/interfaces/definition.d.ts +0 -3
  116. package/src/render3/interfaces/injector.d.ts +0 -1
  117. package/src/render3/interfaces/node.d.ts +37 -2
  118. package/src/render3/interfaces/styling.d.ts +392 -117
  119. package/src/render3/interfaces/view.d.ts +14 -6
  120. package/src/render3/jit/compiler_facade_interface.d.ts +2 -0
  121. package/src/render3/node_manipulation.d.ts +0 -7
  122. package/src/render3/state.d.ts +3 -4
  123. package/src/render3/styling/class_and_style_bindings.d.ts +114 -43
  124. package/src/render3/styling/util.d.ts +5 -2
  125. package/src/render3/util.d.ts +7 -0
  126. package/testing/src/r3_test_bed.d.ts +15 -0
  127. package/testing/testing.metadata.json +1 -1
  128. package/testing.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v7.2.0-rc.0
2
+ * @license Angular v7.2.0
3
3
  * (c) 2010-2018 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -537,7 +537,7 @@
537
537
  /**
538
538
  * Use the `CheckOnce` strategy, meaning that automatic change detection is deactivated
539
539
  * until reactivated by setting the strategy to `Default` (`CheckAlways`).
540
- * Change detection can still be explictly invoked.
540
+ * Change detection can still be explicitly invoked.
541
541
  */
542
542
  ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 0] = "OnPush";
543
543
  /**
@@ -558,7 +558,7 @@
558
558
  */
559
559
  ChangeDetectorStatus[ChangeDetectorStatus["Checked"] = 1] = "Checked";
560
560
  /**
561
- * A state in which change detection continues automatically until explictly
561
+ * A state in which change detection continues automatically until explicitly
562
562
  * deactivated.
563
563
  */
564
564
  ChangeDetectorStatus[ChangeDetectorStatus["CheckAlways"] = 2] = "CheckAlways";
@@ -590,6 +590,140 @@
590
590
  changeDetectionStrategy === exports.ChangeDetectionStrategy.Default;
591
591
  }
592
592
 
593
+ /**
594
+ * @license
595
+ * Copyright Google Inc. All Rights Reserved.
596
+ *
597
+ * Use of this source code is governed by an MIT-style license that can be
598
+ * found in the LICENSE file at https://angular.io/license
599
+ */
600
+ var __window = typeof window !== 'undefined' && window;
601
+ var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
602
+ self instanceof WorkerGlobalScope && self;
603
+ var __global = typeof global !== 'undefined' && global;
604
+ // Check __global first, because in Node tests both __global and __window may be defined and _global
605
+ // should be __global in that case.
606
+ var _global = __global || __window || __self;
607
+ var promise = Promise.resolve(0);
608
+ var _symbolIterator = null;
609
+ function getSymbolIterator() {
610
+ if (!_symbolIterator) {
611
+ var Symbol_1 = _global['Symbol'];
612
+ if (Symbol_1 && Symbol_1.iterator) {
613
+ _symbolIterator = Symbol_1.iterator;
614
+ }
615
+ else {
616
+ // es6-shim specific logic
617
+ var keys = Object.getOwnPropertyNames(Map.prototype);
618
+ for (var i = 0; i < keys.length; ++i) {
619
+ var key = keys[i];
620
+ if (key !== 'entries' && key !== 'size' &&
621
+ Map.prototype[key] === Map.prototype['entries']) {
622
+ _symbolIterator = key;
623
+ }
624
+ }
625
+ }
626
+ }
627
+ return _symbolIterator;
628
+ }
629
+ function scheduleMicroTask(fn) {
630
+ if (typeof Zone === 'undefined') {
631
+ // use promise to schedule microTask instead of use Zone
632
+ promise.then(function () { fn && fn.apply(null, null); });
633
+ }
634
+ else {
635
+ Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
636
+ }
637
+ }
638
+ // JS has NaN !== NaN
639
+ function looseIdentical(a, b) {
640
+ return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
641
+ }
642
+ function stringify(token) {
643
+ if (typeof token === 'string') {
644
+ return token;
645
+ }
646
+ if (token instanceof Array) {
647
+ return '[' + token.map(stringify).join(', ') + ']';
648
+ }
649
+ if (token == null) {
650
+ return '' + token;
651
+ }
652
+ if (token.overriddenName) {
653
+ return "" + token.overriddenName;
654
+ }
655
+ if (token.name) {
656
+ return "" + token.name;
657
+ }
658
+ var res = token.toString();
659
+ if (res == null) {
660
+ return '' + res;
661
+ }
662
+ var newLineIndex = res.indexOf('\n');
663
+ return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
664
+ }
665
+ /**
666
+ * Convince closure compiler that the wrapped function has no side-effects.
667
+ *
668
+ * Closure compiler always assumes that `toString` has no side-effects. We use this quirk to
669
+ * allow us to execute a function but have closure compiler mark the call as no-side-effects.
670
+ * It is important that the return value for the `noSideEffects` function be assigned
671
+ * to something which is retained otherwise the call to `noSideEffects` will be removed by closure
672
+ * compiler.
673
+ */
674
+ function noSideEffects(fn) {
675
+ return '' + { toString: fn };
676
+ }
677
+
678
+ /**
679
+ * @license
680
+ * Copyright Google Inc. All Rights Reserved.
681
+ *
682
+ * Use of this source code is governed by an MIT-style license that can be
683
+ * found in the LICENSE file at https://angular.io/license
684
+ */
685
+ var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
686
+ /**
687
+ * Allows to refer to references which are not yet defined.
688
+ *
689
+ * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
690
+ * DI is declared, but not yet defined. It is also used when the `token` which we use when creating
691
+ * a query is not yet defined.
692
+ *
693
+ * @usageNotes
694
+ * ### Example
695
+ * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
696
+ * @publicApi
697
+ */
698
+ function forwardRef(forwardRefFn) {
699
+ forwardRefFn.__forward_ref__ = forwardRef;
700
+ forwardRefFn.toString = function () { return stringify(this()); };
701
+ return forwardRefFn;
702
+ }
703
+ /**
704
+ * Lazily retrieves the reference value from a forwardRef.
705
+ *
706
+ * Acts as the identity function when given a non-forward-ref value.
707
+ *
708
+ * @usageNotes
709
+ * ### Example
710
+ *
711
+ * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
712
+ *
713
+ * @see `forwardRef`
714
+ * @publicApi
715
+ */
716
+ function resolveForwardRef(type) {
717
+ var fn = type;
718
+ if (typeof fn === 'function' && fn.hasOwnProperty(__forward_ref__) &&
719
+ fn.__forward_ref__ === forwardRef) {
720
+ return fn();
721
+ }
722
+ else {
723
+ return type;
724
+ }
725
+ }
726
+
593
727
  /**
594
728
  * @license
595
729
  * Copyright Google Inc. All Rights Reserved.
@@ -720,91 +854,6 @@
720
854
  ViewEncapsulation[ViewEncapsulation["ShadowDom"] = 3] = "ShadowDom";
721
855
  })(exports.ViewEncapsulation || (exports.ViewEncapsulation = {}));
722
856
 
723
- /**
724
- * @license
725
- * Copyright Google Inc. All Rights Reserved.
726
- *
727
- * Use of this source code is governed by an MIT-style license that can be
728
- * found in the LICENSE file at https://angular.io/license
729
- */
730
- var __window = typeof window !== 'undefined' && window;
731
- var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
732
- self instanceof WorkerGlobalScope && self;
733
- var __global = typeof global !== 'undefined' && global;
734
- // Check __global first, because in Node tests both __global and __window may be defined and _global
735
- // should be __global in that case.
736
- var _global = __global || __window || __self;
737
- var promise = Promise.resolve(0);
738
- var _symbolIterator = null;
739
- function getSymbolIterator() {
740
- if (!_symbolIterator) {
741
- var Symbol_1 = _global['Symbol'];
742
- if (Symbol_1 && Symbol_1.iterator) {
743
- _symbolIterator = Symbol_1.iterator;
744
- }
745
- else {
746
- // es6-shim specific logic
747
- var keys = Object.getOwnPropertyNames(Map.prototype);
748
- for (var i = 0; i < keys.length; ++i) {
749
- var key = keys[i];
750
- if (key !== 'entries' && key !== 'size' &&
751
- Map.prototype[key] === Map.prototype['entries']) {
752
- _symbolIterator = key;
753
- }
754
- }
755
- }
756
- }
757
- return _symbolIterator;
758
- }
759
- function scheduleMicroTask(fn) {
760
- if (typeof Zone === 'undefined') {
761
- // use promise to schedule microTask instead of use Zone
762
- promise.then(function () { fn && fn.apply(null, null); });
763
- }
764
- else {
765
- Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
766
- }
767
- }
768
- // JS has NaN !== NaN
769
- function looseIdentical(a, b) {
770
- return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
771
- }
772
- function stringify(token) {
773
- if (typeof token === 'string') {
774
- return token;
775
- }
776
- if (token instanceof Array) {
777
- return '[' + token.map(stringify).join(', ') + ']';
778
- }
779
- if (token == null) {
780
- return '' + token;
781
- }
782
- if (token.overriddenName) {
783
- return "" + token.overriddenName;
784
- }
785
- if (token.name) {
786
- return "" + token.name;
787
- }
788
- var res = token.toString();
789
- if (res == null) {
790
- return '' + res;
791
- }
792
- var newLineIndex = res.indexOf('\n');
793
- return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
794
- }
795
- /**
796
- * Convince closure compiler that the wrapped function has no side-effects.
797
- *
798
- * Closure compiler always assumes that `toString` has no side-effects. We use this quirk to
799
- * allow us to execute a function but have closure compiler mark the call as no-side-effects.
800
- * It is important that the return value for the `noSideEffects` function be assigned
801
- * to something which is retained otherwise the call to `noSideEffects` will be removed by closure
802
- * compiler.
803
- */
804
- function noSideEffects(fn) {
805
- return '' + { toString: fn };
806
- }
807
-
808
857
  /**
809
858
  * @license
810
859
  * Copyright Google Inc. All Rights Reserved.
@@ -863,6 +912,27 @@
863
912
  ngDevModeResetPerfCounters();
864
913
  }
865
914
 
915
+ /**
916
+ * @license
917
+ * Copyright Google Inc. All Rights Reserved.
918
+ *
919
+ * Use of this source code is governed by an MIT-style license that can be
920
+ * found in the LICENSE file at https://angular.io/license
921
+ */
922
+ /**
923
+ * This file contains reuseable "empty" symbols that can be used as default return values
924
+ * in different parts of the rendering code. Because the same symbols are returned, this
925
+ * allows for identity checks against these values to be consistently used by the framework
926
+ * code.
927
+ */
928
+ var EMPTY_OBJ = {};
929
+ var EMPTY_ARRAY = [];
930
+ // freezing the values prevents any code from accidentally inserting new values in
931
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
932
+ Object.freeze(EMPTY_OBJ);
933
+ Object.freeze(EMPTY_ARRAY);
934
+ }
935
+
866
936
  /**
867
937
  * @license
868
938
  * Copyright Google Inc. All Rights Reserved.
@@ -870,12 +940,6 @@
870
940
  * Use of this source code is governed by an MIT-style license that can be
871
941
  * found in the LICENSE file at https://angular.io/license
872
942
  */
873
- var EMPTY = {};
874
- var EMPTY_ARRAY = [];
875
- if (typeof ngDevMode !== 'undefined' && ngDevMode) {
876
- Object.freeze(EMPTY);
877
- Object.freeze(EMPTY_ARRAY);
878
- }
879
943
  var _renderCompCount = 0;
880
944
  /**
881
945
  * Create a component definition object.
@@ -1032,7 +1096,7 @@
1032
1096
  */
1033
1097
  function invertObject(obj, secondary) {
1034
1098
  if (obj == null)
1035
- return EMPTY;
1099
+ return EMPTY_OBJ;
1036
1100
  var newLookup = {};
1037
1101
  for (var minifiedKey in obj) {
1038
1102
  if (obj.hasOwnProperty(minifiedKey)) {
@@ -1129,204 +1193,6 @@
1129
1193
  return ngModuleDef;
1130
1194
  }
1131
1195
 
1132
- /**
1133
- * @license
1134
- * Copyright Google Inc. All Rights Reserved.
1135
- *
1136
- * Use of this source code is governed by an MIT-style license that can be
1137
- * found in the LICENSE file at https://angular.io/license
1138
- */
1139
- var R3ResolvedDependencyType;
1140
- (function (R3ResolvedDependencyType) {
1141
- R3ResolvedDependencyType[R3ResolvedDependencyType["Token"] = 0] = "Token";
1142
- R3ResolvedDependencyType[R3ResolvedDependencyType["Attribute"] = 1] = "Attribute";
1143
- })(R3ResolvedDependencyType || (R3ResolvedDependencyType = {}));
1144
-
1145
- /**
1146
- * @license
1147
- * Copyright Google Inc. All Rights Reserved.
1148
- *
1149
- * Use of this source code is governed by an MIT-style license that can be
1150
- * found in the LICENSE file at https://angular.io/license
1151
- */
1152
- function getCompilerFacade() {
1153
- var globalNg = _global.ng;
1154
- if (!globalNg || !globalNg.ɵcompilerFacade) {
1155
- throw new Error("Angular JIT compilation failed: '@angular/compiler' not loaded!\n" +
1156
- " - JIT compilation is discouraged for production use-cases! Consider AOT mode instead.\n" +
1157
- " - Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?\n" +
1158
- " - Alternatively provide the compiler with 'import \"@angular/compiler\";' before bootstrapping.");
1159
- }
1160
- return globalNg.ɵcompilerFacade;
1161
- }
1162
-
1163
- /**
1164
- * @license
1165
- * Copyright Google Inc. All Rights Reserved.
1166
- *
1167
- * Use of this source code is governed by an MIT-style license that can be
1168
- * found in the LICENSE file at https://angular.io/license
1169
- */
1170
- /**
1171
- * Inject decorator and metadata.
1172
- *
1173
- * @Annotation
1174
- * @publicApi
1175
- */
1176
- var Inject = makeParamDecorator('Inject', function (token) { return ({ token: token }); });
1177
- /**
1178
- * Optional decorator and metadata.
1179
- *
1180
- * @Annotation
1181
- * @publicApi
1182
- */
1183
- var Optional = makeParamDecorator('Optional');
1184
- /**
1185
- * Self decorator and metadata.
1186
- *
1187
- * @Annotation
1188
- * @publicApi
1189
- */
1190
- var Self = makeParamDecorator('Self');
1191
- /**
1192
- * SkipSelf decorator and metadata.
1193
- *
1194
- * @Annotation
1195
- * @publicApi
1196
- */
1197
- var SkipSelf = makeParamDecorator('SkipSelf');
1198
- /**
1199
- * Host decorator and metadata.
1200
- *
1201
- * @Annotation
1202
- * @publicApi
1203
- */
1204
- var Host = makeParamDecorator('Host');
1205
-
1206
- /**
1207
- * @license
1208
- * Copyright Google Inc. All Rights Reserved.
1209
- *
1210
- * Use of this source code is governed by an MIT-style license that can be
1211
- * found in the LICENSE file at https://angular.io/license
1212
- */
1213
- (function (InjectFlags) {
1214
- // TODO(alxhub): make this 'const' when ngc no longer writes exports of it into ngfactory files.
1215
- InjectFlags[InjectFlags["Default"] = 0] = "Default";
1216
- /**
1217
- * Specifies that an injector should retrieve a dependency from any injector until reaching the
1218
- * host element of the current component. (Only used with Element Injector)
1219
- */
1220
- InjectFlags[InjectFlags["Host"] = 1] = "Host";
1221
- /** Don't descend into ancestors of the node requesting injection. */
1222
- InjectFlags[InjectFlags["Self"] = 2] = "Self";
1223
- /** Skip the node that is requesting injection. */
1224
- InjectFlags[InjectFlags["SkipSelf"] = 4] = "SkipSelf";
1225
- /** Inject `defaultValue` instead if token not found. */
1226
- InjectFlags[InjectFlags["Optional"] = 8] = "Optional";
1227
- })(exports.InjectFlags || (exports.InjectFlags = {}));
1228
- /**
1229
- * Current injector value used by `inject`.
1230
- * - `undefined`: it is an error to call `inject`
1231
- * - `null`: `inject` can be called but there is no injector (limp-mode).
1232
- * - Injector instance: Use the injector for resolution.
1233
- */
1234
- var _currentInjector = undefined;
1235
- function setCurrentInjector(injector) {
1236
- var former = _currentInjector;
1237
- _currentInjector = injector;
1238
- return former;
1239
- }
1240
- /**
1241
- * Current implementation of inject.
1242
- *
1243
- * By default, it is `injectInjectorOnly`, which makes it `Injector`-only aware. It can be changed
1244
- * to `directiveInject`, which brings in the `NodeInjector` system of ivy. It is designed this
1245
- * way for two reasons:
1246
- * 1. `Injector` should not depend on ivy logic.
1247
- * 2. To maintain tree shake-ability we don't want to bring in unnecessary code.
1248
- */
1249
- var _injectImplementation;
1250
- /**
1251
- * Sets the current inject implementation.
1252
- */
1253
- function setInjectImplementation(impl) {
1254
- var previous = _injectImplementation;
1255
- _injectImplementation = impl;
1256
- return previous;
1257
- }
1258
- function injectInjectorOnly(token, flags) {
1259
- if (flags === void 0) { flags = exports.InjectFlags.Default; }
1260
- if (_currentInjector === undefined) {
1261
- throw new Error("inject() must be called from an injection context");
1262
- }
1263
- else if (_currentInjector === null) {
1264
- return injectRootLimpMode(token, undefined, flags);
1265
- }
1266
- else {
1267
- return _currentInjector.get(token, flags & exports.InjectFlags.Optional ? null : undefined, flags);
1268
- }
1269
- }
1270
- function inject(token, flags) {
1271
- if (flags === void 0) { flags = exports.InjectFlags.Default; }
1272
- return (_injectImplementation || injectInjectorOnly)(token, flags);
1273
- }
1274
- /**
1275
- * Injects `root` tokens in limp mode.
1276
- *
1277
- * If no injector exists, we can still inject tree-shakable providers which have `providedIn` set to
1278
- * `"root"`. This is known as the limp mode injection. In such case the value is stored in the
1279
- * `InjectableDef`.
1280
- */
1281
- function injectRootLimpMode(token, notFoundValue, flags) {
1282
- var injectableDef = getInjectableDef(token);
1283
- if (injectableDef && injectableDef.providedIn == 'root') {
1284
- return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() :
1285
- injectableDef.value;
1286
- }
1287
- if (flags & exports.InjectFlags.Optional)
1288
- return null;
1289
- if (notFoundValue !== undefined)
1290
- return notFoundValue;
1291
- throw new Error("Injector: NOT_FOUND [" + stringify(token) + "]");
1292
- }
1293
- function injectArgs(types) {
1294
- var args = [];
1295
- for (var i = 0; i < types.length; i++) {
1296
- var arg = types[i];
1297
- if (Array.isArray(arg)) {
1298
- if (arg.length === 0) {
1299
- throw new Error('Arguments array must have arguments.');
1300
- }
1301
- var type = undefined;
1302
- var flags = exports.InjectFlags.Default;
1303
- for (var j = 0; j < arg.length; j++) {
1304
- var meta = arg[j];
1305
- if (meta instanceof Optional || meta.ngMetadataName === 'Optional') {
1306
- flags |= exports.InjectFlags.Optional;
1307
- }
1308
- else if (meta instanceof SkipSelf || meta.ngMetadataName === 'SkipSelf') {
1309
- flags |= exports.InjectFlags.SkipSelf;
1310
- }
1311
- else if (meta instanceof Self || meta.ngMetadataName === 'Self') {
1312
- flags |= exports.InjectFlags.Self;
1313
- }
1314
- else if (meta instanceof Inject) {
1315
- type = meta.token;
1316
- }
1317
- else {
1318
- type = meta;
1319
- }
1320
- }
1321
- args.push(inject(type, flags));
1322
- }
1323
- else {
1324
- args.push(inject(arg));
1325
- }
1326
- }
1327
- return args;
1328
- }
1329
-
1330
1196
  /**
1331
1197
  * @license
1332
1198
  * Copyright Google Inc. All Rights Reserved.
@@ -1389,6 +1255,76 @@
1389
1255
  assertLessThan(index, arr ? arr.length : 0, 'index expected to be a valid data index');
1390
1256
  }
1391
1257
 
1258
+ /**
1259
+ * @license
1260
+ * Copyright Google Inc. All Rights Reserved.
1261
+ *
1262
+ * Use of this source code is governed by an MIT-style license that can be
1263
+ * found in the LICENSE file at https://angular.io/license
1264
+ */
1265
+ // Below are constants for LView indices to help us look up LView members
1266
+ // without having to remember the specific indices.
1267
+ // Uglify will inline these when minifying so there shouldn't be a cost.
1268
+ var TVIEW = 0;
1269
+ var FLAGS = 1;
1270
+ var PARENT = 2;
1271
+ var NEXT = 3;
1272
+ var QUERIES = 4;
1273
+ var HOST = 5;
1274
+ var HOST_NODE = 6; // Rename to `T_HOST`?
1275
+ var BINDING_INDEX = 7;
1276
+ var CLEANUP = 8;
1277
+ var CONTEXT = 9;
1278
+ var INJECTOR = 10;
1279
+ var RENDERER_FACTORY = 11;
1280
+ var RENDERER = 12;
1281
+ var SANITIZER = 13;
1282
+ var TAIL = 14;
1283
+ var CONTAINER_INDEX = 15;
1284
+ var CONTENT_QUERIES = 16;
1285
+ var DECLARATION_VIEW = 17;
1286
+ /** Size of LView's header. Necessary to adjust for it when setting slots. */
1287
+ var HEADER_OFFSET = 18;
1288
+
1289
+ /**
1290
+ * @license
1291
+ * Copyright Google Inc. All Rights Reserved.
1292
+ *
1293
+ * Use of this source code is governed by an MIT-style license that can be
1294
+ * found in the LICENSE file at https://angular.io/license
1295
+ */
1296
+ /**
1297
+ * Below are constants for LContainer indices to help us look up LContainer members
1298
+ * without having to remember the specific indices.
1299
+ * Uglify will inline these when minifying so there shouldn't be a cost.
1300
+ */
1301
+ var ACTIVE_INDEX = 0;
1302
+ var VIEWS = 1;
1303
+ // PARENT, NEXT, QUERIES, and HOST are indices 2, 3, 4, and 5.
1304
+ // As we already have these constants in LView, we don't need to re-create them.
1305
+ var NATIVE = 6;
1306
+ var RENDER_PARENT = 7;
1307
+ // Because interfaces in TS/JS cannot be instanceof-checked this means that we
1308
+ // need to rely on predictable characteristics of data-structures to check if they
1309
+ // are what we expect for them to be. The `LContainer` interface code below has a
1310
+ // fixed length and the constant value below references that. Using the length value
1311
+ // below we can predictably gaurantee that we are dealing with an `LContainer` array.
1312
+ // This value MUST be kept up to date with the length of the `LContainer` array
1313
+ // interface below so that runtime type checking can work.
1314
+ var LCONTAINER_LENGTH = 8;
1315
+
1316
+ /**
1317
+ * @license
1318
+ * Copyright Google Inc. All Rights Reserved.
1319
+ *
1320
+ * Use of this source code is governed by an MIT-style license that can be
1321
+ * found in the LICENSE file at https://angular.io/license
1322
+ */
1323
+ /**
1324
+ * This property will be monkey-patched on elements, components and directives
1325
+ */
1326
+ var MONKEY_PATCH_KEY_NAME = '__ngContext__';
1327
+
1392
1328
  /**
1393
1329
  * @license
1394
1330
  * Copyright Google Inc. All Rights Reserved.
@@ -1521,210 +1457,6 @@
1521
1457
  return obj != null && typeof obj == 'object' && Object.getPrototypeOf(obj) == FactoryPrototype;
1522
1458
  }
1523
1459
 
1524
- /**
1525
- * @license
1526
- * Copyright Google Inc. All Rights Reserved.
1527
- *
1528
- * Use of this source code is governed by an MIT-style license that can be
1529
- * found in the LICENSE file at https://angular.io/license
1530
- */
1531
- // Below are constants for LView indices to help us look up LView members
1532
- // without having to remember the specific indices.
1533
- // Uglify will inline these when minifying so there shouldn't be a cost.
1534
- var TVIEW = 0;
1535
- var FLAGS = 1;
1536
- var PARENT = 2;
1537
- var NEXT = 3;
1538
- var QUERIES = 4;
1539
- var HOST = 5;
1540
- var HOST_NODE = 6; // Rename to `T_HOST`?
1541
- var BINDING_INDEX = 7;
1542
- var CLEANUP = 8;
1543
- var CONTEXT = 9;
1544
- var INJECTOR = 10;
1545
- var RENDERER_FACTORY = 11;
1546
- var RENDERER = 12;
1547
- var SANITIZER = 13;
1548
- var TAIL = 14;
1549
- var CONTAINER_INDEX = 15;
1550
- var CONTENT_QUERIES = 16;
1551
- var DECLARATION_VIEW = 17;
1552
- /** Size of LView's header. Necessary to adjust for it when setting slots. */
1553
- var HEADER_OFFSET = 18;
1554
-
1555
- /**
1556
- * @license
1557
- * Copyright Google Inc. All Rights Reserved.
1558
- *
1559
- * Use of this source code is governed by an MIT-style license that can be
1560
- * found in the LICENSE file at https://angular.io/license
1561
- */
1562
- function assertNodeType(tNode, type) {
1563
- assertDefined(tNode, 'should be called with a TNode');
1564
- assertEqual(tNode.type, type, "should be a " + typeName(type));
1565
- }
1566
- function assertNodeOfPossibleTypes(tNode) {
1567
- var types = [];
1568
- for (var _i = 1; _i < arguments.length; _i++) {
1569
- types[_i - 1] = arguments[_i];
1570
- }
1571
- assertDefined(tNode, 'should be called with a TNode');
1572
- var found = types.some(function (type) { return tNode.type === type; });
1573
- assertEqual(found, true, "Should be one of " + types.map(typeName).join(', ') + " but got " + typeName(tNode.type));
1574
- }
1575
- function typeName(type) {
1576
- if (type == 1 /* Projection */)
1577
- return 'Projection';
1578
- if (type == 0 /* Container */)
1579
- return 'Container';
1580
- if (type == 2 /* View */)
1581
- return 'View';
1582
- if (type == 3 /* Element */)
1583
- return 'Element';
1584
- if (type == 4 /* ElementContainer */)
1585
- return 'ElementContainer';
1586
- return '<unknown>';
1587
- }
1588
-
1589
- /**
1590
- * @license
1591
- * Copyright Google Inc. All Rights Reserved.
1592
- *
1593
- * Use of this source code is governed by an MIT-style license that can be
1594
- * found in the LICENSE file at https://angular.io/license
1595
- */
1596
- /**
1597
- * If this is the first template pass, any ngOnInit or ngDoCheck hooks will be queued into
1598
- * TView.initHooks during directiveCreate.
1599
- *
1600
- * The directive index and hook type are encoded into one number (1st bit: type, remaining bits:
1601
- * directive index), then saved in the even indices of the initHooks array. The odd indices
1602
- * hold the hook functions themselves.
1603
- *
1604
- * @param index The index of the directive in LView
1605
- * @param hooks The static hooks map on the directive def
1606
- * @param tView The current TView
1607
- */
1608
- function queueInitHooks(index, onInit, doCheck, tView) {
1609
- ngDevMode &&
1610
- assertEqual(tView.firstTemplatePass, true, 'Should only be called on first template pass');
1611
- if (onInit) {
1612
- (tView.initHooks || (tView.initHooks = [])).push(index, onInit);
1613
- }
1614
- if (doCheck) {
1615
- (tView.initHooks || (tView.initHooks = [])).push(index, doCheck);
1616
- (tView.checkHooks || (tView.checkHooks = [])).push(index, doCheck);
1617
- }
1618
- }
1619
- /**
1620
- * Loops through the directives on a node and queues all their hooks except ngOnInit
1621
- * and ngDoCheck, which are queued separately in directiveCreate.
1622
- */
1623
- function queueLifecycleHooks(tView, tNode) {
1624
- if (tView.firstTemplatePass) {
1625
- // It's necessary to loop through the directives at elementEnd() (rather than processing in
1626
- // directiveCreate) so we can preserve the current hook order. Content, view, and destroy
1627
- // hooks for projected components and directives must be called *before* their hosts.
1628
- for (var i = tNode.directiveStart, end = tNode.directiveEnd; i < end; i++) {
1629
- var def = tView.data[i];
1630
- queueContentHooks(def, tView, i);
1631
- queueViewHooks(def, tView, i);
1632
- queueDestroyHooks(def, tView, i);
1633
- }
1634
- }
1635
- }
1636
- /** Queues afterContentInit and afterContentChecked hooks on TView */
1637
- function queueContentHooks(def, tView, i) {
1638
- if (def.afterContentInit) {
1639
- (tView.contentHooks || (tView.contentHooks = [])).push(i, def.afterContentInit);
1640
- }
1641
- if (def.afterContentChecked) {
1642
- (tView.contentHooks || (tView.contentHooks = [])).push(i, def.afterContentChecked);
1643
- (tView.contentCheckHooks || (tView.contentCheckHooks = [])).push(i, def.afterContentChecked);
1644
- }
1645
- }
1646
- /** Queues afterViewInit and afterViewChecked hooks on TView */
1647
- function queueViewHooks(def, tView, i) {
1648
- if (def.afterViewInit) {
1649
- (tView.viewHooks || (tView.viewHooks = [])).push(i, def.afterViewInit);
1650
- }
1651
- if (def.afterViewChecked) {
1652
- (tView.viewHooks || (tView.viewHooks = [])).push(i, def.afterViewChecked);
1653
- (tView.viewCheckHooks || (tView.viewCheckHooks = [])).push(i, def.afterViewChecked);
1654
- }
1655
- }
1656
- /** Queues onDestroy hooks on TView */
1657
- function queueDestroyHooks(def, tView, i) {
1658
- if (def.onDestroy != null) {
1659
- (tView.destroyHooks || (tView.destroyHooks = [])).push(i, def.onDestroy);
1660
- }
1661
- }
1662
- /**
1663
- * Calls onInit and doCheck calls if they haven't already been called.
1664
- *
1665
- * @param currentView The current view
1666
- */
1667
- function executeInitHooks(currentView, tView, creationMode) {
1668
- if (currentView[FLAGS] & 16 /* RunInit */) {
1669
- executeHooks(currentView, tView.initHooks, tView.checkHooks, creationMode);
1670
- currentView[FLAGS] &= ~16 /* RunInit */;
1671
- }
1672
- }
1673
- /**
1674
- * Iterates over afterViewInit and afterViewChecked functions and calls them.
1675
- *
1676
- * @param currentView The current view
1677
- */
1678
- function executeHooks(data, allHooks, checkHooks, creationMode) {
1679
- var hooksToCall = creationMode ? allHooks : checkHooks;
1680
- if (hooksToCall) {
1681
- callHooks(data, hooksToCall);
1682
- }
1683
- }
1684
- /**
1685
- * Calls lifecycle hooks with their contexts, skipping init hooks if it's not
1686
- * creation mode.
1687
- *
1688
- * @param currentView The current view
1689
- * @param arr The array in which the hooks are found
1690
- */
1691
- function callHooks(currentView, arr) {
1692
- for (var i = 0; i < arr.length; i += 2) {
1693
- arr[i + 1].call(currentView[arr[i]]);
1694
- }
1695
- }
1696
-
1697
- /**
1698
- * @license
1699
- * Copyright Google Inc. All Rights Reserved.
1700
- *
1701
- * Use of this source code is governed by an MIT-style license that can be
1702
- * found in the LICENSE file at https://angular.io/license
1703
- */
1704
- /**
1705
- * Below are constants for LContainer indices to help us look up LContainer members
1706
- * without having to remember the specific indices.
1707
- * Uglify will inline these when minifying so there shouldn't be a cost.
1708
- */
1709
- var ACTIVE_INDEX = 0;
1710
- var VIEWS = 1;
1711
- // PARENT, NEXT, QUERIES, and HOST are indices 2, 3, 4, and 5.
1712
- // As we already have these constants in LView, we don't need to re-create them.
1713
- var NATIVE = 6;
1714
- var RENDER_PARENT = 7;
1715
-
1716
- /**
1717
- * @license
1718
- * Copyright Google Inc. All Rights Reserved.
1719
- *
1720
- * Use of this source code is governed by an MIT-style license that can be
1721
- * found in the LICENSE file at https://angular.io/license
1722
- */
1723
- /**
1724
- * This property will be monkey-patched on elements, components and directives
1725
- */
1726
- var MONKEY_PATCH_KEY_NAME = '__ngContext__';
1727
-
1728
1460
  /**
1729
1461
  * @license
1730
1462
  * Copyright Google Inc. All Rights Reserved.
@@ -1830,120 +1562,477 @@
1830
1562
  }
1831
1563
  function isLContainer(value) {
1832
1564
  // Styling contexts are also arrays, but their first index contains an element node
1833
- return Array.isArray(value) && typeof value[ACTIVE_INDEX] === 'number';
1565
+ return Array.isArray(value) && value.length === LCONTAINER_LENGTH;
1834
1566
  }
1835
1567
  function isRootView(target) {
1836
- return (target[FLAGS] & 64 /* IsRoot */) !== 0;
1568
+ return (target[FLAGS] & 128 /* IsRoot */) !== 0;
1837
1569
  }
1838
1570
  /**
1839
1571
  * Retrieve the root view from any component by walking the parent `LView` until
1840
1572
  * reaching the root `LView`.
1841
1573
  *
1842
- * @param component any component
1574
+ * @param component any component
1575
+ */
1576
+ function getRootView(target) {
1577
+ ngDevMode && assertDefined(target, 'component');
1578
+ var lView = Array.isArray(target) ? target : readPatchedLView(target);
1579
+ while (lView && !(lView[FLAGS] & 128 /* IsRoot */)) {
1580
+ lView = lView[PARENT];
1581
+ }
1582
+ return lView;
1583
+ }
1584
+ function getRootContext(viewOrComponent) {
1585
+ var rootView = getRootView(viewOrComponent);
1586
+ ngDevMode &&
1587
+ assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');
1588
+ return rootView[CONTEXT];
1589
+ }
1590
+ /**
1591
+ * Returns the monkey-patch value data present on the target (which could be
1592
+ * a component, directive or a DOM node).
1593
+ */
1594
+ function readPatchedData(target) {
1595
+ ngDevMode && assertDefined(target, 'Target expected');
1596
+ return target[MONKEY_PATCH_KEY_NAME];
1597
+ }
1598
+ function readPatchedLView(target) {
1599
+ var value = readPatchedData(target);
1600
+ if (value) {
1601
+ return Array.isArray(value) ? value : value.lView;
1602
+ }
1603
+ return null;
1604
+ }
1605
+ function hasParentInjector(parentLocation) {
1606
+ return parentLocation !== NO_PARENT_INJECTOR;
1607
+ }
1608
+ function getParentInjectorIndex(parentLocation) {
1609
+ return parentLocation & 32767 /* InjectorIndexMask */;
1610
+ }
1611
+ function getParentInjectorViewOffset(parentLocation) {
1612
+ return parentLocation >> 16 /* ViewOffsetShift */;
1613
+ }
1614
+ /**
1615
+ * Unwraps a parent injector location number to find the view offset from the current injector,
1616
+ * then walks up the declaration view tree until the view is found that contains the parent
1617
+ * injector.
1618
+ *
1619
+ * @param location The location of the parent injector, which contains the view offset
1620
+ * @param startView The LView instance from which to start walking up the view tree
1621
+ * @returns The LView instance that contains the parent injector
1622
+ */
1623
+ function getParentInjectorView(location, startView) {
1624
+ var viewOffset = getParentInjectorViewOffset(location);
1625
+ var parentView = startView;
1626
+ // For most cases, the parent injector can be found on the host node (e.g. for component
1627
+ // or container), but we must keep the loop here to support the rarer case of deeply nested
1628
+ // <ng-template> tags or inline views, where the parent injector might live many views
1629
+ // above the child injector.
1630
+ while (viewOffset > 0) {
1631
+ parentView = parentView[DECLARATION_VIEW];
1632
+ viewOffset--;
1633
+ }
1634
+ return parentView;
1635
+ }
1636
+ /**
1637
+ * Unwraps a parent injector location number to find the view offset from the current injector,
1638
+ * then walks up the declaration view tree until the TNode of the parent injector is found.
1639
+ *
1640
+ * @param location The location of the parent injector, which contains the view offset
1641
+ * @param startView The LView instance from which to start walking up the view tree
1642
+ * @param startTNode The TNode instance of the starting element
1643
+ * @returns The TNode of the parent injector
1644
+ */
1645
+ function getParentInjectorTNode(location, startView, startTNode) {
1646
+ if (startTNode.parent && startTNode.parent.injectorIndex !== -1) {
1647
+ // view offset is 0
1648
+ var injectorIndex = startTNode.parent.injectorIndex;
1649
+ var parentTNode_1 = startTNode.parent;
1650
+ while (parentTNode_1.parent != null && injectorIndex == parentTNode_1.injectorIndex) {
1651
+ parentTNode_1 = parentTNode_1.parent;
1652
+ }
1653
+ return parentTNode_1;
1654
+ }
1655
+ var viewOffset = getParentInjectorViewOffset(location);
1656
+ // view offset is 1
1657
+ var parentView = startView;
1658
+ var parentTNode = startView[HOST_NODE];
1659
+ // view offset is superior to 1
1660
+ while (viewOffset > 1) {
1661
+ parentView = parentView[DECLARATION_VIEW];
1662
+ parentTNode = parentView[HOST_NODE];
1663
+ viewOffset--;
1664
+ }
1665
+ return parentTNode;
1666
+ }
1667
+ var defaultScheduler = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame || // browser only
1668
+ setTimeout // everything else
1669
+ ).bind(_global);
1670
+ /**
1671
+ * Equivalent to ES6 spread, add each item to an array.
1672
+ *
1673
+ * @param items The items to add
1674
+ * @param arr The array to which you want to add the items
1675
+ */
1676
+ function addAllToArray(items, arr) {
1677
+ for (var i = 0; i < items.length; i++) {
1678
+ arr.push(items[i]);
1679
+ }
1680
+ }
1681
+ /**
1682
+ * Given a current view, finds the nearest component's host (LElement).
1683
+ *
1684
+ * @param lView LView for which we want a host element node
1685
+ * @returns The host node
1686
+ */
1687
+ function findComponentView(lView) {
1688
+ var rootTNode = lView[HOST_NODE];
1689
+ while (rootTNode && rootTNode.type === 2 /* View */) {
1690
+ ngDevMode && assertDefined(lView[DECLARATION_VIEW], 'lView[DECLARATION_VIEW]');
1691
+ lView = lView[DECLARATION_VIEW];
1692
+ rootTNode = lView[HOST_NODE];
1693
+ }
1694
+ return lView;
1695
+ }
1696
+
1697
+ /**
1698
+ * @license
1699
+ * Copyright Google Inc. All Rights Reserved.
1700
+ *
1701
+ * Use of this source code is governed by an MIT-style license that can be
1702
+ * found in the LICENSE file at https://angular.io/license
1703
+ */
1704
+ var R3ResolvedDependencyType;
1705
+ (function (R3ResolvedDependencyType) {
1706
+ R3ResolvedDependencyType[R3ResolvedDependencyType["Token"] = 0] = "Token";
1707
+ R3ResolvedDependencyType[R3ResolvedDependencyType["Attribute"] = 1] = "Attribute";
1708
+ })(R3ResolvedDependencyType || (R3ResolvedDependencyType = {}));
1709
+
1710
+ /**
1711
+ * @license
1712
+ * Copyright Google Inc. All Rights Reserved.
1713
+ *
1714
+ * Use of this source code is governed by an MIT-style license that can be
1715
+ * found in the LICENSE file at https://angular.io/license
1716
+ */
1717
+ function getCompilerFacade() {
1718
+ var globalNg = _global.ng;
1719
+ if (!globalNg || !globalNg.ɵcompilerFacade) {
1720
+ throw new Error("Angular JIT compilation failed: '@angular/compiler' not loaded!\n" +
1721
+ " - JIT compilation is discouraged for production use-cases! Consider AOT mode instead.\n" +
1722
+ " - Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?\n" +
1723
+ " - Alternatively provide the compiler with 'import \"@angular/compiler\";' before bootstrapping.");
1724
+ }
1725
+ return globalNg.ɵcompilerFacade;
1726
+ }
1727
+
1728
+ /**
1729
+ * @license
1730
+ * Copyright Google Inc. All Rights Reserved.
1731
+ *
1732
+ * Use of this source code is governed by an MIT-style license that can be
1733
+ * found in the LICENSE file at https://angular.io/license
1734
+ */
1735
+ /**
1736
+ * Inject decorator and metadata.
1737
+ *
1738
+ * @Annotation
1739
+ * @publicApi
1740
+ */
1741
+ var Inject = makeParamDecorator('Inject', function (token) { return ({ token: token }); });
1742
+ /**
1743
+ * Optional decorator and metadata.
1744
+ *
1745
+ * @Annotation
1746
+ * @publicApi
1747
+ */
1748
+ var Optional = makeParamDecorator('Optional');
1749
+ /**
1750
+ * Self decorator and metadata.
1751
+ *
1752
+ * @Annotation
1753
+ * @publicApi
1754
+ */
1755
+ var Self = makeParamDecorator('Self');
1756
+ /**
1757
+ * SkipSelf decorator and metadata.
1758
+ *
1759
+ * @Annotation
1760
+ * @publicApi
1761
+ */
1762
+ var SkipSelf = makeParamDecorator('SkipSelf');
1763
+ /**
1764
+ * Host decorator and metadata.
1765
+ *
1766
+ * @Annotation
1767
+ * @publicApi
1768
+ */
1769
+ var Host = makeParamDecorator('Host');
1770
+
1771
+ /**
1772
+ * @license
1773
+ * Copyright Google Inc. All Rights Reserved.
1774
+ *
1775
+ * Use of this source code is governed by an MIT-style license that can be
1776
+ * found in the LICENSE file at https://angular.io/license
1777
+ */
1778
+ (function (InjectFlags) {
1779
+ // TODO(alxhub): make this 'const' when ngc no longer writes exports of it into ngfactory files.
1780
+ InjectFlags[InjectFlags["Default"] = 0] = "Default";
1781
+ /**
1782
+ * Specifies that an injector should retrieve a dependency from any injector until reaching the
1783
+ * host element of the current component. (Only used with Element Injector)
1784
+ */
1785
+ InjectFlags[InjectFlags["Host"] = 1] = "Host";
1786
+ /** Don't descend into ancestors of the node requesting injection. */
1787
+ InjectFlags[InjectFlags["Self"] = 2] = "Self";
1788
+ /** Skip the node that is requesting injection. */
1789
+ InjectFlags[InjectFlags["SkipSelf"] = 4] = "SkipSelf";
1790
+ /** Inject `defaultValue` instead if token not found. */
1791
+ InjectFlags[InjectFlags["Optional"] = 8] = "Optional";
1792
+ })(exports.InjectFlags || (exports.InjectFlags = {}));
1793
+ /**
1794
+ * Current injector value used by `inject`.
1795
+ * - `undefined`: it is an error to call `inject`
1796
+ * - `null`: `inject` can be called but there is no injector (limp-mode).
1797
+ * - Injector instance: Use the injector for resolution.
1798
+ */
1799
+ var _currentInjector = undefined;
1800
+ function setCurrentInjector(injector) {
1801
+ var former = _currentInjector;
1802
+ _currentInjector = injector;
1803
+ return former;
1804
+ }
1805
+ /**
1806
+ * Current implementation of inject.
1807
+ *
1808
+ * By default, it is `injectInjectorOnly`, which makes it `Injector`-only aware. It can be changed
1809
+ * to `directiveInject`, which brings in the `NodeInjector` system of ivy. It is designed this
1810
+ * way for two reasons:
1811
+ * 1. `Injector` should not depend on ivy logic.
1812
+ * 2. To maintain tree shake-ability we don't want to bring in unnecessary code.
1813
+ */
1814
+ var _injectImplementation;
1815
+ /**
1816
+ * Sets the current inject implementation.
1817
+ */
1818
+ function setInjectImplementation(impl) {
1819
+ var previous = _injectImplementation;
1820
+ _injectImplementation = impl;
1821
+ return previous;
1822
+ }
1823
+ function injectInjectorOnly(token, flags) {
1824
+ if (flags === void 0) { flags = exports.InjectFlags.Default; }
1825
+ if (_currentInjector === undefined) {
1826
+ throw new Error("inject() must be called from an injection context");
1827
+ }
1828
+ else if (_currentInjector === null) {
1829
+ return injectRootLimpMode(token, undefined, flags);
1830
+ }
1831
+ else {
1832
+ return _currentInjector.get(token, flags & exports.InjectFlags.Optional ? null : undefined, flags);
1833
+ }
1834
+ }
1835
+ function inject(token, flags) {
1836
+ if (flags === void 0) { flags = exports.InjectFlags.Default; }
1837
+ return (_injectImplementation || injectInjectorOnly)(token, flags);
1838
+ }
1839
+ /**
1840
+ * Injects `root` tokens in limp mode.
1841
+ *
1842
+ * If no injector exists, we can still inject tree-shakable providers which have `providedIn` set to
1843
+ * `"root"`. This is known as the limp mode injection. In such case the value is stored in the
1844
+ * `InjectableDef`.
1845
+ */
1846
+ function injectRootLimpMode(token, notFoundValue, flags) {
1847
+ var injectableDef = getInjectableDef(token);
1848
+ if (injectableDef && injectableDef.providedIn == 'root') {
1849
+ return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() :
1850
+ injectableDef.value;
1851
+ }
1852
+ if (flags & exports.InjectFlags.Optional)
1853
+ return null;
1854
+ if (notFoundValue !== undefined)
1855
+ return notFoundValue;
1856
+ throw new Error("Injector: NOT_FOUND [" + stringify(token) + "]");
1857
+ }
1858
+ function injectArgs(types) {
1859
+ var args = [];
1860
+ for (var i = 0; i < types.length; i++) {
1861
+ var arg = types[i];
1862
+ if (Array.isArray(arg)) {
1863
+ if (arg.length === 0) {
1864
+ throw new Error('Arguments array must have arguments.');
1865
+ }
1866
+ var type = undefined;
1867
+ var flags = exports.InjectFlags.Default;
1868
+ for (var j = 0; j < arg.length; j++) {
1869
+ var meta = arg[j];
1870
+ if (meta instanceof Optional || meta.ngMetadataName === 'Optional') {
1871
+ flags |= exports.InjectFlags.Optional;
1872
+ }
1873
+ else if (meta instanceof SkipSelf || meta.ngMetadataName === 'SkipSelf') {
1874
+ flags |= exports.InjectFlags.SkipSelf;
1875
+ }
1876
+ else if (meta instanceof Self || meta.ngMetadataName === 'Self') {
1877
+ flags |= exports.InjectFlags.Self;
1878
+ }
1879
+ else if (meta instanceof Inject) {
1880
+ type = meta.token;
1881
+ }
1882
+ else {
1883
+ type = meta;
1884
+ }
1885
+ }
1886
+ args.push(inject(type, flags));
1887
+ }
1888
+ else {
1889
+ args.push(inject(arg));
1890
+ }
1891
+ }
1892
+ return args;
1893
+ }
1894
+
1895
+ /**
1896
+ * @license
1897
+ * Copyright Google Inc. All Rights Reserved.
1898
+ *
1899
+ * Use of this source code is governed by an MIT-style license that can be
1900
+ * found in the LICENSE file at https://angular.io/license
1901
+ */
1902
+ function assertNodeType(tNode, type) {
1903
+ assertDefined(tNode, 'should be called with a TNode');
1904
+ assertEqual(tNode.type, type, "should be a " + typeName(type));
1905
+ }
1906
+ function assertNodeOfPossibleTypes(tNode) {
1907
+ var types = [];
1908
+ for (var _i = 1; _i < arguments.length; _i++) {
1909
+ types[_i - 1] = arguments[_i];
1910
+ }
1911
+ assertDefined(tNode, 'should be called with a TNode');
1912
+ var found = types.some(function (type) { return tNode.type === type; });
1913
+ assertEqual(found, true, "Should be one of " + types.map(typeName).join(', ') + " but got " + typeName(tNode.type));
1914
+ }
1915
+ function typeName(type) {
1916
+ if (type == 1 /* Projection */)
1917
+ return 'Projection';
1918
+ if (type == 0 /* Container */)
1919
+ return 'Container';
1920
+ if (type == 2 /* View */)
1921
+ return 'View';
1922
+ if (type == 3 /* Element */)
1923
+ return 'Element';
1924
+ if (type == 4 /* ElementContainer */)
1925
+ return 'ElementContainer';
1926
+ return '<unknown>';
1927
+ }
1928
+
1929
+ /**
1930
+ * @license
1931
+ * Copyright Google Inc. All Rights Reserved.
1932
+ *
1933
+ * Use of this source code is governed by an MIT-style license that can be
1934
+ * found in the LICENSE file at https://angular.io/license
1935
+ */
1936
+ /**
1937
+ * If this is the first template pass, any ngOnInit or ngDoCheck hooks will be queued into
1938
+ * TView.initHooks during directiveCreate.
1939
+ *
1940
+ * The directive index and hook type are encoded into one number (1st bit: type, remaining bits:
1941
+ * directive index), then saved in the even indices of the initHooks array. The odd indices
1942
+ * hold the hook functions themselves.
1943
+ *
1944
+ * @param index The index of the directive in LView
1945
+ * @param hooks The static hooks map on the directive def
1946
+ * @param tView The current TView
1843
1947
  */
1844
- function getRootView(target) {
1845
- ngDevMode && assertDefined(target, 'component');
1846
- var lView = Array.isArray(target) ? target : readPatchedLView(target);
1847
- while (lView && !(lView[FLAGS] & 64 /* IsRoot */)) {
1848
- lView = lView[PARENT];
1849
- }
1850
- return lView;
1851
- }
1852
- function getRootContext(viewOrComponent) {
1853
- var rootView = getRootView(viewOrComponent);
1948
+ function queueInitHooks(index, onInit, doCheck, tView) {
1854
1949
  ngDevMode &&
1855
- assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');
1856
- return rootView[CONTEXT];
1950
+ assertEqual(tView.firstTemplatePass, true, 'Should only be called on first template pass');
1951
+ if (onInit) {
1952
+ (tView.initHooks || (tView.initHooks = [])).push(index, onInit);
1953
+ }
1954
+ if (doCheck) {
1955
+ (tView.initHooks || (tView.initHooks = [])).push(index, doCheck);
1956
+ (tView.checkHooks || (tView.checkHooks = [])).push(index, doCheck);
1957
+ }
1857
1958
  }
1858
1959
  /**
1859
- * Returns the monkey-patch value data present on the target (which could be
1860
- * a component, directive or a DOM node).
1960
+ * Loops through the directives on a node and queues all their hooks except ngOnInit
1961
+ * and ngDoCheck, which are queued separately in directiveCreate.
1861
1962
  */
1862
- function readPatchedData(target) {
1863
- ngDevMode && assertDefined(target, 'Target expected');
1864
- return target[MONKEY_PATCH_KEY_NAME];
1865
- }
1866
- function readPatchedLView(target) {
1867
- var value = readPatchedData(target);
1868
- if (value) {
1869
- return Array.isArray(value) ? value : value.lView;
1963
+ function queueLifecycleHooks(tView, tNode) {
1964
+ if (tView.firstTemplatePass) {
1965
+ // It's necessary to loop through the directives at elementEnd() (rather than processing in
1966
+ // directiveCreate) so we can preserve the current hook order. Content, view, and destroy
1967
+ // hooks for projected components and directives must be called *before* their hosts.
1968
+ for (var i = tNode.directiveStart, end = tNode.directiveEnd; i < end; i++) {
1969
+ var def = tView.data[i];
1970
+ queueContentHooks(def, tView, i);
1971
+ queueViewHooks(def, tView, i);
1972
+ queueDestroyHooks(def, tView, i);
1973
+ }
1870
1974
  }
1871
- return null;
1872
1975
  }
1873
- function hasParentInjector(parentLocation) {
1874
- return parentLocation !== NO_PARENT_INJECTOR;
1976
+ /** Queues afterContentInit and afterContentChecked hooks on TView */
1977
+ function queueContentHooks(def, tView, i) {
1978
+ if (def.afterContentInit) {
1979
+ (tView.contentHooks || (tView.contentHooks = [])).push(i, def.afterContentInit);
1980
+ }
1981
+ if (def.afterContentChecked) {
1982
+ (tView.contentHooks || (tView.contentHooks = [])).push(i, def.afterContentChecked);
1983
+ (tView.contentCheckHooks || (tView.contentCheckHooks = [])).push(i, def.afterContentChecked);
1984
+ }
1875
1985
  }
1876
- function getParentInjectorIndex(parentLocation) {
1877
- return parentLocation & 32767 /* InjectorIndexMask */;
1986
+ /** Queues afterViewInit and afterViewChecked hooks on TView */
1987
+ function queueViewHooks(def, tView, i) {
1988
+ if (def.afterViewInit) {
1989
+ (tView.viewHooks || (tView.viewHooks = [])).push(i, def.afterViewInit);
1990
+ }
1991
+ if (def.afterViewChecked) {
1992
+ (tView.viewHooks || (tView.viewHooks = [])).push(i, def.afterViewChecked);
1993
+ (tView.viewCheckHooks || (tView.viewCheckHooks = [])).push(i, def.afterViewChecked);
1994
+ }
1878
1995
  }
1879
- function getParentInjectorViewOffset(parentLocation) {
1880
- return parentLocation >> 16 /* ViewOffsetShift */;
1996
+ /** Queues onDestroy hooks on TView */
1997
+ function queueDestroyHooks(def, tView, i) {
1998
+ if (def.onDestroy != null) {
1999
+ (tView.destroyHooks || (tView.destroyHooks = [])).push(i, def.onDestroy);
2000
+ }
1881
2001
  }
1882
2002
  /**
1883
- * Unwraps a parent injector location number to find the view offset from the current injector,
1884
- * then walks up the declaration view tree until the view is found that contains the parent
1885
- * injector.
2003
+ * Calls onInit and doCheck calls if they haven't already been called.
1886
2004
  *
1887
- * @param location The location of the parent injector, which contains the view offset
1888
- * @param startView The LView instance from which to start walking up the view tree
1889
- * @returns The LView instance that contains the parent injector
2005
+ * @param currentView The current view
1890
2006
  */
1891
- function getParentInjectorView(location, startView) {
1892
- var viewOffset = getParentInjectorViewOffset(location);
1893
- var parentView = startView;
1894
- // For most cases, the parent injector can be found on the host node (e.g. for component
1895
- // or container), but we must keep the loop here to support the rarer case of deeply nested
1896
- // <ng-template> tags or inline views, where the parent injector might live many views
1897
- // above the child injector.
1898
- while (viewOffset > 0) {
1899
- parentView = parentView[DECLARATION_VIEW];
1900
- viewOffset--;
2007
+ function executeInitHooks(currentView, tView, checkNoChangesMode) {
2008
+ if (!checkNoChangesMode && currentView[FLAGS] & 32 /* RunInit */) {
2009
+ executeHooks(currentView, tView.initHooks, tView.checkHooks, checkNoChangesMode);
2010
+ currentView[FLAGS] &= ~32 /* RunInit */;
1901
2011
  }
1902
- return parentView;
1903
2012
  }
1904
2013
  /**
1905
- * Unwraps a parent injector location number to find the view offset from the current injector,
1906
- * then walks up the declaration view tree until the TNode of the parent injector is found.
2014
+ * Iterates over afterViewInit and afterViewChecked functions and calls them.
1907
2015
  *
1908
- * @param location The location of the parent injector, which contains the view offset
1909
- * @param startView The LView instance from which to start walking up the view tree
1910
- * @param startTNode The TNode instance of the starting element
1911
- * @returns The TNode of the parent injector
2016
+ * @param currentView The current view
1912
2017
  */
1913
- function getParentInjectorTNode(location, startView, startTNode) {
1914
- if (startTNode.parent && startTNode.parent.injectorIndex !== -1) {
1915
- // view offset is 0
1916
- var injectorIndex = startTNode.parent.injectorIndex;
1917
- var parentTNode_1 = startTNode.parent;
1918
- while (parentTNode_1.parent != null && injectorIndex == parentTNode_1.injectorIndex) {
1919
- parentTNode_1 = parentTNode_1.parent;
1920
- }
1921
- return parentTNode_1;
1922
- }
1923
- var viewOffset = getParentInjectorViewOffset(location);
1924
- // view offset is 1
1925
- var parentView = startView;
1926
- var parentTNode = startView[HOST_NODE];
1927
- // view offset is superior to 1
1928
- while (viewOffset > 1) {
1929
- parentView = parentView[DECLARATION_VIEW];
1930
- parentTNode = parentView[HOST_NODE];
1931
- viewOffset--;
2018
+ function executeHooks(currentView, allHooks, checkHooks, checkNoChangesMode) {
2019
+ if (checkNoChangesMode)
2020
+ return;
2021
+ var hooksToCall = currentView[FLAGS] & 2 /* FirstLViewPass */ ? allHooks : checkHooks;
2022
+ if (hooksToCall) {
2023
+ callHooks(currentView, hooksToCall);
1932
2024
  }
1933
- return parentTNode;
1934
2025
  }
1935
- var defaultScheduler = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame || // browser only
1936
- setTimeout // everything else
1937
- ).bind(_global);
1938
2026
  /**
1939
- * Equivalent to ES6 spread, add each item to an array.
2027
+ * Calls lifecycle hooks with their contexts, skipping init hooks if it's not
2028
+ * the first LView pass.
1940
2029
  *
1941
- * @param items The items to add
1942
- * @param arr The array to which you want to add the items
2030
+ * @param currentView The current view
2031
+ * @param arr The array in which the hooks are found
1943
2032
  */
1944
- function addAllToArray(items, arr) {
1945
- for (var i = 0; i < items.length; i++) {
1946
- arr.push(items[i]);
2033
+ function callHooks(currentView, arr) {
2034
+ for (var i = 0; i < arr.length; i += 2) {
2035
+ arr[i + 1].call(currentView[arr[i]]);
1947
2036
  }
1948
2037
  }
1949
2038
 
@@ -2100,13 +2189,10 @@
2100
2189
  }
2101
2190
  return currentQueries || (lView[QUERIES] = new QueryType(null, null, null));
2102
2191
  }
2103
- /**
2104
- * This property gets set before entering a template.
2105
- */
2106
- var creationMode;
2107
- function getCreationMode() {
2108
- // top level variables should not be exported for performance reasons (PERF_NOTES.md)
2109
- return creationMode;
2192
+ /** Checks whether a given view is in creation mode */
2193
+ function isCreationMode(view) {
2194
+ if (view === void 0) { view = lView; }
2195
+ return (view[FLAGS] & 1 /* CreationMode */) === 1 /* CreationMode */;
2110
2196
  }
2111
2197
  /**
2112
2198
  * State of the current view being processed.
@@ -2176,7 +2262,6 @@
2176
2262
  var oldView = lView;
2177
2263
  if (newView) {
2178
2264
  var tView = newView[TVIEW];
2179
- creationMode = (newView[FLAGS] & 1 /* CreationMode */) === 1 /* CreationMode */;
2180
2265
  firstTemplatePass = tView.firstTemplatePass;
2181
2266
  bindingRootIndex = tView.bindingStartIndex;
2182
2267
  }
@@ -2212,20 +2297,19 @@
2212
2297
  * the direction of traversal (up or down the view tree) a bit clearer.
2213
2298
  *
2214
2299
  * @param newView New state to become active
2215
- * @param creationOnly An optional boolean to indicate that the view was processed in creation mode
2216
- * only, i.e. the first update will be done later. Only possible for dynamically created views.
2217
2300
  */
2218
- function leaveView(newView, creationOnly) {
2301
+ function leaveView(newView) {
2219
2302
  var tView = lView[TVIEW];
2220
- if (!creationOnly) {
2221
- if (!checkNoChangesMode) {
2222
- executeHooks(lView, tView.viewHooks, tView.viewCheckHooks, creationMode);
2223
- }
2303
+ if (isCreationMode(lView)) {
2304
+ lView[FLAGS] &= ~1 /* CreationMode */;
2305
+ }
2306
+ else {
2307
+ executeHooks(lView, tView.viewHooks, tView.viewCheckHooks, checkNoChangesMode);
2224
2308
  // Views are clean and in update mode after being checked, so these bits are cleared
2225
- lView[FLAGS] &= ~(1 /* CreationMode */ | 4 /* Dirty */);
2309
+ lView[FLAGS] &= ~(8 /* Dirty */ | 2 /* FirstLViewPass */);
2310
+ lView[FLAGS] |= 32 /* RunInit */;
2311
+ lView[BINDING_INDEX] = tView.bindingStartIndex;
2226
2312
  }
2227
- lView[FLAGS] |= 16 /* RunInit */;
2228
- lView[BINDING_INDEX] = tView.bindingStartIndex;
2229
2313
  enterView(newView, null);
2230
2314
  }
2231
2315
 
@@ -2272,7 +2356,7 @@
2272
2356
  *
2273
2357
  * ```
2274
2358
  */
2275
- var includeViewProviders = false;
2359
+ var includeViewProviders = true;
2276
2360
  function setIncludeViewProviders(v) {
2277
2361
  var oldValue = includeViewProviders;
2278
2362
  includeViewProviders = v;
@@ -2387,7 +2471,7 @@
2387
2471
  */
2388
2472
  function getParentInjectorLocation(tNode, view) {
2389
2473
  if (tNode.parent && tNode.parent.injectorIndex !== -1) {
2390
- return tNode.parent.injectorIndex; // ViewOffset is 0, AcrossHostBoundary is 0
2474
+ return tNode.parent.injectorIndex; // ViewOffset is 0
2391
2475
  }
2392
2476
  // For most cases, the parent injector index can be found on the host node (e.g. for component
2393
2477
  // or container), so this loop will be skipped, but we must keep the loop here to support
@@ -2396,15 +2480,11 @@
2396
2480
  var viewOffset = 1;
2397
2481
  while (hostTNode && hostTNode.injectorIndex === -1) {
2398
2482
  view = view[DECLARATION_VIEW];
2399
- hostTNode = view[HOST_NODE];
2483
+ hostTNode = view ? view[HOST_NODE] : null;
2400
2484
  viewOffset++;
2401
2485
  }
2402
- var acrossHostBoundary = hostTNode && hostTNode.type === 3 /* Element */ ?
2403
- 32768 /* AcrossHostBoundary */ :
2404
- 0;
2405
2486
  return hostTNode ?
2406
- hostTNode.injectorIndex | (viewOffset << 16 /* ViewOffsetShift */) |
2407
- acrossHostBoundary :
2487
+ hostTNode.injectorIndex | (viewOffset << 16 /* ViewOffsetShift */) :
2408
2488
  -1;
2409
2489
  }
2410
2490
  /**
@@ -2455,7 +2535,7 @@
2455
2535
  if (attrs) {
2456
2536
  for (var i = 0; i < attrs.length; i = i + 2) {
2457
2537
  var attrName = attrs[i];
2458
- if (attrName === 1 /* SelectOnly */)
2538
+ if (attrName === 3 /* SelectOnly */)
2459
2539
  break;
2460
2540
  if (attrName == attrNameToInject) {
2461
2541
  return attrs[i + 1];
@@ -2479,75 +2559,80 @@
2479
2559
  */
2480
2560
  function getOrCreateInjectable(tNode, lView, token, flags, notFoundValue) {
2481
2561
  if (flags === void 0) { flags = exports.InjectFlags.Default; }
2482
- var bloomHash = bloomHashBitOrFactory(token);
2483
- // If the ID stored here is a function, this is a special object like ElementRef or TemplateRef
2484
- // so just call the factory function to create it.
2485
- if (typeof bloomHash === 'function') {
2486
- var savePreviousOrParentTNode = getPreviousOrParentTNode();
2487
- var saveLView = getLView();
2488
- setTNodeAndViewData(tNode, lView);
2489
- try {
2490
- var value = bloomHash();
2491
- if (value == null && !(flags & exports.InjectFlags.Optional)) {
2492
- throw new Error("No provider for " + stringify$1(token) + "!");
2493
- }
2494
- else {
2495
- return value;
2496
- }
2497
- }
2498
- finally {
2499
- setTNodeAndViewData(savePreviousOrParentTNode, saveLView);
2500
- }
2501
- }
2502
- else if (typeof bloomHash == 'number') {
2503
- // If the token has a bloom hash, then it is a token which could be in NodeInjector.
2504
- // A reference to the previous injector TView that was found while climbing the element injector
2505
- // tree. This is used to know if viewProviders can be accessed on the current injector.
2506
- var previousTView = null;
2507
- var injectorIndex = getInjectorIndex(tNode, lView);
2508
- var parentLocation = NO_PARENT_INJECTOR;
2509
- // If we should skip this injector, or if there is no injector on this node, start by searching
2510
- // the parent injector.
2511
- if (injectorIndex === -1 || flags & exports.InjectFlags.SkipSelf) {
2512
- parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lView) :
2513
- lView[injectorIndex + PARENT_INJECTOR];
2514
- if (!shouldSearchParent(flags, parentLocation)) {
2515
- injectorIndex = -1;
2516
- }
2517
- else {
2518
- previousTView = lView[TVIEW];
2519
- injectorIndex = getParentInjectorIndex(parentLocation);
2520
- lView = getParentInjectorView(parentLocation, lView);
2521
- }
2522
- }
2523
- // Traverse up the injector tree until we find a potential match or until we know there
2524
- // *isn't* a match.
2525
- while (injectorIndex !== -1) {
2526
- parentLocation = lView[injectorIndex + PARENT_INJECTOR];
2527
- // Check the current injector. If it matches, see if it contains token.
2528
- var tView = lView[TVIEW];
2529
- if (bloomHasToken(bloomHash, injectorIndex, tView.data)) {
2530
- // At this point, we have an injector which *may* contain the token, so we step through
2531
- // the providers and directives associated with the injector's corresponding node to get
2532
- // the instance.
2533
- var instance = searchTokensOnInjector(injectorIndex, lView, token, previousTView);
2534
- if (instance !== NOT_FOUND) {
2535
- return instance;
2562
+ if (tNode) {
2563
+ var bloomHash = bloomHashBitOrFactory(token);
2564
+ // If the ID stored here is a function, this is a special object like ElementRef or TemplateRef
2565
+ // so just call the factory function to create it.
2566
+ if (typeof bloomHash === 'function') {
2567
+ var savePreviousOrParentTNode = getPreviousOrParentTNode();
2568
+ var saveLView = getLView();
2569
+ setTNodeAndViewData(tNode, lView);
2570
+ try {
2571
+ var value = bloomHash();
2572
+ if (value == null && !(flags & exports.InjectFlags.Optional)) {
2573
+ throw new Error("No provider for " + stringify$1(token) + "!");
2574
+ }
2575
+ else {
2576
+ return value;
2536
2577
  }
2537
2578
  }
2538
- if (shouldSearchParent(flags, parentLocation) &&
2539
- bloomHasToken(bloomHash, injectorIndex, lView)) {
2540
- // The def wasn't found anywhere on this node, so it was a false positive.
2541
- // Traverse up the tree and continue searching.
2542
- previousTView = tView;
2543
- injectorIndex = getParentInjectorIndex(parentLocation);
2544
- lView = getParentInjectorView(parentLocation, lView);
2579
+ finally {
2580
+ setTNodeAndViewData(savePreviousOrParentTNode, saveLView);
2581
+ }
2582
+ }
2583
+ else if (typeof bloomHash == 'number') {
2584
+ // If the token has a bloom hash, then it is a token which could be in NodeInjector.
2585
+ // A reference to the previous injector TView that was found while climbing the element
2586
+ // injector tree. This is used to know if viewProviders can be accessed on the current
2587
+ // injector.
2588
+ var previousTView = null;
2589
+ var injectorIndex = getInjectorIndex(tNode, lView);
2590
+ var parentLocation = NO_PARENT_INJECTOR;
2591
+ var hostTElementNode = flags & exports.InjectFlags.Host ? findComponentView(lView)[HOST_NODE] : null;
2592
+ // If we should skip this injector, or if there is no injector on this node, start by
2593
+ // searching
2594
+ // the parent injector.
2595
+ if (injectorIndex === -1 || flags & exports.InjectFlags.SkipSelf) {
2596
+ parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lView) :
2597
+ lView[injectorIndex + PARENT_INJECTOR];
2598
+ if (!shouldSearchParent(flags, false)) {
2599
+ injectorIndex = -1;
2600
+ }
2601
+ else {
2602
+ previousTView = lView[TVIEW];
2603
+ injectorIndex = getParentInjectorIndex(parentLocation);
2604
+ lView = getParentInjectorView(parentLocation, lView);
2605
+ }
2545
2606
  }
2546
- else {
2547
- // If we should not search parent OR If the ancestor bloom filter value does not have the
2548
- // bit corresponding to the directive we can give up on traversing up to find the specific
2549
- // injector.
2550
- injectorIndex = -1;
2607
+ // Traverse up the injector tree until we find a potential match or until we know there
2608
+ // *isn't* a match.
2609
+ while (injectorIndex !== -1) {
2610
+ parentLocation = lView[injectorIndex + PARENT_INJECTOR];
2611
+ // Check the current injector. If it matches, see if it contains token.
2612
+ var tView = lView[TVIEW];
2613
+ if (bloomHasToken(bloomHash, injectorIndex, tView.data)) {
2614
+ // At this point, we have an injector which *may* contain the token, so we step through
2615
+ // the providers and directives associated with the injector's corresponding node to get
2616
+ // the instance.
2617
+ var instance = searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode);
2618
+ if (instance !== NOT_FOUND) {
2619
+ return instance;
2620
+ }
2621
+ }
2622
+ if (shouldSearchParent(flags, lView[TVIEW].data[injectorIndex + TNODE] === hostTElementNode) &&
2623
+ bloomHasToken(bloomHash, injectorIndex, lView)) {
2624
+ // The def wasn't found anywhere on this node, so it was a false positive.
2625
+ // Traverse up the tree and continue searching.
2626
+ previousTView = tView;
2627
+ injectorIndex = getParentInjectorIndex(parentLocation);
2628
+ lView = getParentInjectorView(parentLocation, lView);
2629
+ }
2630
+ else {
2631
+ // If we should not search parent OR If the ancestor bloom filter value does not have the
2632
+ // bit corresponding to the directive we can give up on traversing up to find the specific
2633
+ // injector.
2634
+ injectorIndex = -1;
2635
+ }
2551
2636
  }
2552
2637
  }
2553
2638
  }
@@ -2572,7 +2657,7 @@
2572
2657
  }
2573
2658
  }
2574
2659
  var NOT_FOUND = {};
2575
- function searchTokensOnInjector(injectorIndex, lView, token, previousTView) {
2660
+ function searchTokensOnInjector(injectorIndex, lView, token, previousTView, flags, hostTElementNode) {
2576
2661
  var currentTView = lView[TVIEW];
2577
2662
  var tNode = currentTView.data[injectorIndex + TNODE];
2578
2663
  // First, we need to determine if view providers can be accessed by the starting element.
@@ -2593,7 +2678,10 @@
2593
2678
  // This means that we just came from the Component's View and therefore are allowed to see
2594
2679
  // into the ViewProviders.
2595
2680
  (previousTView != currentTView && (tNode.type === 3 /* Element */));
2596
- var injectableIdx = locateDirectiveOrProvider(tNode, lView, token, canAccessViewProviders);
2681
+ // This special case happens when there is a @host on the inject and when we are searching
2682
+ // on the host element node.
2683
+ var isHostSpecialCase = (flags & exports.InjectFlags.Host) && hostTElementNode === tNode;
2684
+ var injectableIdx = locateDirectiveOrProvider(tNode, lView, token, canAccessViewProviders, isHostSpecialCase);
2597
2685
  if (injectableIdx !== null) {
2598
2686
  return getNodeInjectable(currentTView.data, lView, injectableIdx, tNode);
2599
2687
  }
@@ -2608,11 +2696,11 @@
2608
2696
  * @param lView The view we are currently processing
2609
2697
  * @param token Provider token or type of a directive to look for.
2610
2698
  * @param canAccessViewProviders Whether view providers should be considered.
2699
+ * @param isHostSpecialCase Whether the host special case applies.
2611
2700
  * @returns Index of a found directive or provider, or null when none found.
2612
2701
  */
2613
- function locateDirectiveOrProvider(tNode, lView, token, canAccessViewProviders) {
2702
+ function locateDirectiveOrProvider(tNode, lView, token, canAccessViewProviders, isHostSpecialCase) {
2614
2703
  var tView = lView[TVIEW];
2615
- var nodeFlags = tNode.flags;
2616
2704
  var nodeProviderIndexes = tNode.providerIndexes;
2617
2705
  var tInjectables = tView.data;
2618
2706
  var injectablesStart = nodeProviderIndexes & 65535 /* ProvidersStartIndexMask */;
@@ -2620,13 +2708,21 @@
2620
2708
  var directiveEnd = tNode.directiveEnd;
2621
2709
  var cptViewProvidersCount = nodeProviderIndexes >> 16 /* CptViewProvidersCountShift */;
2622
2710
  var startingIndex = canAccessViewProviders ? injectablesStart : injectablesStart + cptViewProvidersCount;
2623
- for (var i = startingIndex; i < directiveEnd; i++) {
2711
+ // When the host special case applies, only the viewProviders and the component are visible
2712
+ var endIndex = isHostSpecialCase ? injectablesStart + cptViewProvidersCount : directiveEnd;
2713
+ for (var i = startingIndex; i < endIndex; i++) {
2624
2714
  var providerTokenOrDef = tInjectables[i];
2625
2715
  if (i < directivesStart && token === providerTokenOrDef ||
2626
2716
  i >= directivesStart && providerTokenOrDef.type === token) {
2627
2717
  return i;
2628
2718
  }
2629
2719
  }
2720
+ if (isHostSpecialCase) {
2721
+ var dirDef = tInjectables[directivesStart];
2722
+ if (dirDef && isComponentDef(dirDef) && dirDef.type === token) {
2723
+ return directivesStart;
2724
+ }
2725
+ }
2630
2726
  return null;
2631
2727
  }
2632
2728
  /**
@@ -2709,10 +2805,8 @@
2709
2805
  return !!(value & mask);
2710
2806
  }
2711
2807
  /** Returns true if flags prevent parent injector from being searched for tokens */
2712
- function shouldSearchParent(flags, parentLocation) {
2713
- return !(flags & exports.InjectFlags.Self ||
2714
- (flags & exports.InjectFlags.Host &&
2715
- (parentLocation & 32768 /* AcrossHostBoundary */)));
2808
+ function shouldSearchParent(flags, isFirstHostTNode) {
2809
+ return !(flags & exports.InjectFlags.Self) && !(flags & exports.InjectFlags.Host && isFirstHostTNode);
2716
2810
  }
2717
2811
  function injectInjector() {
2718
2812
  var tNode = getPreviousOrParentTNode();
@@ -3124,7 +3218,7 @@
3124
3218
  // As long as lView[HOST] is null we know we are part of sub-template such as `*ngIf`
3125
3219
  lView = lView[PARENT];
3126
3220
  }
3127
- return lView[FLAGS] & 64 /* IsRoot */ ? null : lView[CONTEXT];
3221
+ return lView[FLAGS] & 128 /* IsRoot */ ? null : lView[CONTEXT];
3128
3222
  }
3129
3223
  /**
3130
3224
  * Returns the `RootContext` instance that is associated with
@@ -3229,7 +3323,7 @@
3229
3323
  ngDevMode && assertDefined(componentOrView, 'component');
3230
3324
  lView = readPatchedLView(componentOrView);
3231
3325
  }
3232
- while (lView && !(lView[FLAGS] & 64 /* IsRoot */)) {
3326
+ while (lView && !(lView[FLAGS] & 128 /* IsRoot */)) {
3233
3327
  lView = lView[PARENT];
3234
3328
  }
3235
3329
  return lView;
@@ -3306,7 +3400,7 @@
3306
3400
  var secondParam = tCleanup[i++];
3307
3401
  if (typeof firstParam === 'string') {
3308
3402
  var name_1 = firstParam;
3309
- var listenerElement = lView[secondParam];
3403
+ var listenerElement = readElementValue(lView[secondParam]);
3310
3404
  var callback = lCleanup[tCleanup[i++]];
3311
3405
  var useCaptureOrIndx = tCleanup[i++];
3312
3406
  // if useCaptureOrIndx is boolean then report it as is.
@@ -3338,55 +3432,6 @@
3338
3432
  return obj.type !== undefined && obj.template !== undefined && obj.declaredInputs !== undefined;
3339
3433
  }
3340
3434
 
3341
- /**
3342
- * @license
3343
- * Copyright Google Inc. All Rights Reserved.
3344
- *
3345
- * Use of this source code is governed by an MIT-style license that can be
3346
- * found in the LICENSE file at https://angular.io/license
3347
- */
3348
- var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
3349
- /**
3350
- * Allows to refer to references which are not yet defined.
3351
- *
3352
- * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
3353
- * DI is declared, but not yet defined. It is also used when the `token` which we use when creating
3354
- * a query is not yet defined.
3355
- *
3356
- * @usageNotes
3357
- * ### Example
3358
- * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
3359
- * @publicApi
3360
- */
3361
- function forwardRef(forwardRefFn) {
3362
- forwardRefFn.__forward_ref__ = forwardRef;
3363
- forwardRefFn.toString = function () { return stringify(this()); };
3364
- return forwardRefFn;
3365
- }
3366
- /**
3367
- * Lazily retrieves the reference value from a forwardRef.
3368
- *
3369
- * Acts as the identity function when given a non-forward-ref value.
3370
- *
3371
- * @usageNotes
3372
- * ### Example
3373
- *
3374
- * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
3375
- *
3376
- * @see `forwardRef`
3377
- * @publicApi
3378
- */
3379
- function resolveForwardRef(type) {
3380
- var fn = type;
3381
- if (typeof fn === 'function' && fn.hasOwnProperty(__forward_ref__) &&
3382
- fn.__forward_ref__ === forwardRef) {
3383
- return fn();
3384
- }
3385
- else {
3386
- return type;
3387
- }
3388
- }
3389
-
3390
3435
  /**
3391
3436
  * @license
3392
3437
  * Copyright Google Inc. All Rights Reserved.
@@ -3592,7 +3637,7 @@
3592
3637
  else if (isDifferent(lView[bindingIndex], value)) {
3593
3638
  if (ngDevMode && getCheckNoChangesMode()) {
3594
3639
  if (!devModeEqual(lView[bindingIndex], value)) {
3595
- throwErrorIfNoChangesMode(getCreationMode(), lView[bindingIndex], value);
3640
+ throwErrorIfNoChangesMode(isCreationMode(lView), lView[bindingIndex], value);
3596
3641
  }
3597
3642
  }
3598
3643
  lView[bindingIndex] = value;
@@ -3805,29 +3850,14 @@
3805
3850
  if (tNode.type === 2 /* View */ && currentView[NEXT]) {
3806
3851
  currentView = currentView[NEXT];
3807
3852
  nextTNode = currentView[TVIEW].node;
3808
- }
3809
- else {
3810
- nextTNode = tNode.next;
3811
- }
3812
- }
3813
- }
3814
- tNode = nextTNode;
3815
- }
3816
- }
3817
- /**
3818
- * Given a current view, finds the nearest component's host (LElement).
3819
- *
3820
- * @param lView LView for which we want a host element node
3821
- * @returns The host node
3822
- */
3823
- function findComponentView(lView) {
3824
- var rootTNode = lView[HOST_NODE];
3825
- while (rootTNode && rootTNode.type === 2 /* View */) {
3826
- ngDevMode && assertDefined(lView[PARENT], 'lView.parent');
3827
- lView = lView[PARENT];
3828
- rootTNode = lView[HOST_NODE];
3853
+ }
3854
+ else {
3855
+ nextTNode = tNode.next;
3856
+ }
3857
+ }
3858
+ }
3859
+ tNode = nextTNode;
3829
3860
  }
3830
- return lView;
3831
3861
  }
3832
3862
  /**
3833
3863
  * NOTE: for performance reasons, the possible actions are inlined within the function instead of
@@ -3946,7 +3976,7 @@
3946
3976
  lView[QUERIES].insertView(index);
3947
3977
  }
3948
3978
  // Sets the attached flag
3949
- lView[FLAGS] |= 8 /* Attached */;
3979
+ lView[FLAGS] |= 16 /* Attached */;
3950
3980
  }
3951
3981
  /**
3952
3982
  * Detaches a view from a container.
@@ -3975,7 +4005,7 @@
3975
4005
  viewToDetach[CONTAINER_INDEX] = -1;
3976
4006
  viewToDetach[PARENT] = null;
3977
4007
  // Unsets the attached flag
3978
- viewToDetach[FLAGS] &= ~8 /* Attached */;
4008
+ viewToDetach[FLAGS] &= ~16 /* Attached */;
3979
4009
  return viewToDetach;
3980
4010
  }
3981
4011
  /**
@@ -4008,7 +4038,7 @@
4008
4038
  }
4009
4039
  destroyViewTree(view);
4010
4040
  // Sets the destroyed flag
4011
- view[FLAGS] |= 32 /* Destroyed */;
4041
+ view[FLAGS] |= 64 /* Destroyed */;
4012
4042
  }
4013
4043
  /**
4014
4044
  * Determines which LViewOrLContainer to jump to when traversing back up the
@@ -4408,7 +4438,7 @@
4408
4438
  ngDevMode && assertDefined(selector[0], 'Selector should have a tag name');
4409
4439
  var mode = 4 /* ELEMENT */;
4410
4440
  var nodeAttrs = tNode.attrs;
4411
- var selectOnlyMarkerIdx = nodeAttrs ? nodeAttrs.indexOf(1 /* SelectOnly */) : -1;
4441
+ var selectOnlyMarkerIdx = nodeAttrs ? nodeAttrs.indexOf(3 /* SelectOnly */) : -1;
4412
4442
  // When processing ":not" selectors, we skip to the next ":not" if the
4413
4443
  // current one doesn't match
4414
4444
  var skipToNextSelector = false;
@@ -4497,7 +4527,7 @@
4497
4527
  i += 4;
4498
4528
  }
4499
4529
  else {
4500
- if (maybeAttrName === 1 /* SelectOnly */) {
4530
+ if (maybeAttrName === 3 /* SelectOnly */) {
4501
4531
  selectOnlyMode = true;
4502
4532
  }
4503
4533
  i += selectOnlyMode ? 1 : 2;
@@ -4599,16 +4629,17 @@
4599
4629
  * found in the LICENSE file at https://angular.io/license
4600
4630
  */
4601
4631
  var ANIMATION_PROP_PREFIX = '@';
4602
- function createEmptyStylingContext(element, sanitizer, initialStylingValues) {
4632
+ function createEmptyStylingContext(element, sanitizer, initialStyles, initialClasses) {
4603
4633
  return [
4604
- null,
4605
- sanitizer || null,
4606
- initialStylingValues || [null],
4607
- 0,
4608
4634
  0,
4635
+ [null, -1, false, sanitizer || null],
4636
+ initialStyles || [null],
4637
+ initialClasses || [null],
4638
+ [0, 0],
4609
4639
  element || null,
4610
4640
  null,
4611
- null // PreviousMultiStyleValue
4641
+ null,
4642
+ null,
4612
4643
  ];
4613
4644
  }
4614
4645
  /**
@@ -4621,6 +4652,8 @@
4621
4652
  // each instance gets a copy
4622
4653
  var context = templateStyleContext.slice();
4623
4654
  context[5 /* ElementPosition */] = element;
4655
+ // this will prevent any other directives from extending the context
4656
+ context[0 /* MasterFlagPosition */] |= 32 /* BindingAllocationLocked */;
4624
4657
  return context;
4625
4658
  }
4626
4659
  /**
@@ -4658,8 +4691,8 @@
4658
4691
  }
4659
4692
  function isStylingContext(value) {
4660
4693
  // Not an LView or an LContainer
4661
- return Array.isArray(value) && typeof value[FLAGS] !== 'number' &&
4662
- typeof value[ACTIVE_INDEX] !== 'number';
4694
+ return Array.isArray(value) && typeof value[0 /* MasterFlagPosition */] === 'number' &&
4695
+ Array.isArray(value[2 /* InitialStyleValuesPosition */]);
4663
4696
  }
4664
4697
  function isAnimationProp(name) {
4665
4698
  return name[0] === ANIMATION_PROP_PREFIX;
@@ -4723,140 +4756,392 @@
4723
4756
  return getPlayerContext(stylingContext) || allocPlayerContext(stylingContext);
4724
4757
  }
4725
4758
  function getPlayerContext(stylingContext) {
4726
- return stylingContext[0 /* PlayerContext */];
4759
+ return stylingContext[8 /* PlayerContext */];
4727
4760
  }
4728
4761
  function allocPlayerContext(data) {
4729
- return data[0 /* PlayerContext */] =
4762
+ return data[8 /* PlayerContext */] =
4730
4763
  [5 /* SinglePlayerBuildersStartPosition */, null, null, null, null];
4731
4764
  }
4732
4765
  function throwInvalidRefError() {
4733
4766
  throw new Error('Only elements that exist in an Angular application can be used for animations');
4734
4767
  }
4768
+ function hasStyling(attrs) {
4769
+ for (var i = 0; i < attrs.length; i++) {
4770
+ var attr = attrs[i];
4771
+ if (attr == 1 /* Classes */ || attr == 2 /* Styles */)
4772
+ return true;
4773
+ }
4774
+ return false;
4775
+ }
4776
+ function hasClassInput(tNode) {
4777
+ return tNode.flags & 8 /* hasClassInput */ ? true : false;
4778
+ }
4735
4779
 
4736
- var EMPTY_ARR = [];
4737
- var EMPTY_OBJ = {};
4738
4780
  /**
4739
- * Creates a styling context template where styling information is stored.
4740
- * Any styles that are later referenced using `updateStyleProp` must be
4741
- * passed in within this function. Initial values for those styles are to
4742
- * be declared after all initial style properties are declared (this change in
4743
- * mode between declarations and initial styles is made possible using a special
4744
- * enum value found in `definition.ts`).
4745
- *
4746
- * @param initialStyleDeclarations a list of style declarations and initial style values
4747
- * that are used later within the styling context.
4748
- *
4749
- * -> ['width', 'height', SPECIAL_ENUM_VAL, 'width', '100px']
4750
- * This implies that `width` and `height` will be later styled and that the `width`
4751
- * property has an initial value of `100px`.
4752
- *
4753
- * @param initialClassDeclarations a list of class declarations and initial class values
4754
- * that are used later within the styling context.
4755
- *
4756
- * -> ['foo', 'bar', SPECIAL_ENUM_VAL, 'foo', true]
4757
- * This implies that `foo` and `bar` will be later styled and that the `foo`
4758
- * class will be applied to the element as an initial class since it's true
4759
- */
4760
- function createStylingContextTemplate(initialClassDeclarations, initialStyleDeclarations, styleSanitizer, onlyProcessSingleClasses) {
4761
- var initialStylingValues = [null];
4762
- var context = createEmptyStylingContext(null, styleSanitizer, initialStylingValues);
4763
- // we use two maps since a class name might collide with a CSS style prop
4764
- var stylesLookup = {};
4765
- var classesLookup = {};
4766
- var totalStyleDeclarations = 0;
4767
- if (initialStyleDeclarations) {
4768
- var hasPassedDeclarations = false;
4769
- for (var i = 0; i < initialStyleDeclarations.length; i++) {
4770
- var v = initialStyleDeclarations[i];
4771
- // this flag value marks where the declarations end the initial values begin
4772
- if (v === 1 /* VALUES_MODE */) {
4773
- hasPassedDeclarations = true;
4781
+ * This file includes the code to power all styling-binding operations in Angular.
4782
+ *
4783
+ * These include:
4784
+ * [style]="myStyleObj"
4785
+ * [class]="myClassObj"
4786
+ * [style.prop]="myPropValue"
4787
+ * [class.name]="myClassValue"
4788
+ *
4789
+ * There are many different ways in which these functions below are called. Please see
4790
+ * `interfaces/styles.ts` to get a better idea of how the styling algorithm works.
4791
+ */
4792
+ /**
4793
+ * Creates a new StylingContext an fills it with the provided static styling attribute values.
4794
+ */
4795
+ function initializeStaticContext(attrs) {
4796
+ var context = createEmptyStylingContext();
4797
+ var initialClasses = context[3 /* InitialClassValuesPosition */] =
4798
+ [null];
4799
+ var initialStyles = context[2 /* InitialStyleValuesPosition */] =
4800
+ [null];
4801
+ // The attributes array has marker values (numbers) indicating what the subsequent
4802
+ // values represent. When we encounter a number, we set the mode to that type of attribute.
4803
+ var mode = -1;
4804
+ for (var i = 0; i < attrs.length; i++) {
4805
+ var attr = attrs[i];
4806
+ if (typeof attr == 'number') {
4807
+ mode = attr;
4808
+ }
4809
+ else if (mode === 2 /* Styles */) {
4810
+ initialStyles.push(attr, attrs[++i]);
4811
+ }
4812
+ else if (mode === 1 /* Classes */) {
4813
+ initialClasses.push(attr, true);
4814
+ }
4815
+ else if (mode === 3 /* SelectOnly */) {
4816
+ break;
4817
+ }
4818
+ }
4819
+ return context;
4820
+ }
4821
+ /**
4822
+ * Designed to update an existing styling context with new static styling
4823
+ * data (classes and styles).
4824
+ *
4825
+ * @param context the existing styling context
4826
+ * @param attrs an array of new static styling attributes that will be
4827
+ * assigned to the context
4828
+ * @param directive the directive instance with which static data is associated with.
4829
+ */
4830
+ function patchContextWithStaticAttrs(context, attrs, directive) {
4831
+ // If the styling context has already been patched with the given directive's bindings,
4832
+ // then there is no point in doing it again. The reason why this may happen (the directive
4833
+ // styling being patched twice) is because the `stylingBinding` function is called each time
4834
+ // an element is created (both within a template function and within directive host bindings).
4835
+ var directives = context[1 /* DirectiveRegistryPosition */];
4836
+ if (getDirectiveRegistryValuesIndexOf(directives, directive) == -1) {
4837
+ // this is a new directive which we have not seen yet.
4838
+ directives.push(directive, -1, false, null);
4839
+ var initialClasses = null;
4840
+ var initialStyles = null;
4841
+ var mode = -1;
4842
+ for (var i = 0; i < attrs.length; i++) {
4843
+ var attr = attrs[i];
4844
+ if (typeof attr == 'number') {
4845
+ mode = attr;
4846
+ }
4847
+ else if (mode == 1 /* Classes */) {
4848
+ initialClasses = initialClasses || context[3 /* InitialClassValuesPosition */];
4849
+ patchInitialStylingValue(initialClasses, attr, true);
4850
+ }
4851
+ else if (mode == 2 /* Styles */) {
4852
+ initialStyles = initialStyles || context[2 /* InitialStyleValuesPosition */];
4853
+ patchInitialStylingValue(initialStyles, attr, attrs[++i]);
4854
+ }
4855
+ }
4856
+ }
4857
+ }
4858
+ /**
4859
+ * Designed to add a style or class value into the existing set of initial styles.
4860
+ *
4861
+ * The function will search and figure out if a style/class value is already present
4862
+ * within the provided initial styling array. If and when a style/class value is not
4863
+ * present (or if it's value is falsy) then it will be inserted/updated in the list
4864
+ * of initial styling values.
4865
+ */
4866
+ function patchInitialStylingValue(initialStyling, prop, value) {
4867
+ // Even values are keys; Odd numbers are values; Search keys only
4868
+ for (var i = 1 /* KeyValueStartPosition */; i < initialStyling.length;) {
4869
+ var key = initialStyling[i];
4870
+ if (key === prop) {
4871
+ var existingValue = initialStyling[i + 1 /* ValueOffset */];
4872
+ // If there is no previous style value (when `null`) or no previous class
4873
+ // applied (when `false`) then we update the the newly given value.
4874
+ if (existingValue == null || existingValue == false) {
4875
+ initialStyling[i + 1 /* ValueOffset */] = value;
4876
+ }
4877
+ return;
4878
+ }
4879
+ i = i + 2 /* Size */;
4880
+ }
4881
+ // We did not find existing key, add a new one.
4882
+ initialStyling.push(prop, value);
4883
+ }
4884
+ /**
4885
+ * Runs through the initial styling data present in the context and renders
4886
+ * them via the renderer on the element.
4887
+ */
4888
+ function renderInitialStylesAndClasses(element, context, renderer) {
4889
+ var initialClasses = context[3 /* InitialClassValuesPosition */];
4890
+ renderInitialStylingValues(element, renderer, initialClasses, true);
4891
+ var initialStyles = context[2 /* InitialStyleValuesPosition */];
4892
+ renderInitialStylingValues(element, renderer, initialStyles, false);
4893
+ }
4894
+ /**
4895
+ * This is a helper function designed to render each entry present within the
4896
+ * provided list of initialStylingValues.
4897
+ */
4898
+ function renderInitialStylingValues(element, renderer, initialStylingValues, isEntryClassBased) {
4899
+ for (var i = 1 /* KeyValueStartPosition */; i < initialStylingValues.length; i += 2 /* Size */) {
4900
+ var value = initialStylingValues[i + 1 /* ValueOffset */];
4901
+ if (value) {
4902
+ if (isEntryClassBased) {
4903
+ setClass(element, initialStylingValues[i + 0 /* PropOffset */], true, renderer, null);
4774
4904
  }
4775
4905
  else {
4776
- var prop = v;
4777
- if (hasPassedDeclarations) {
4778
- var value = initialStyleDeclarations[++i];
4779
- initialStylingValues.push(value);
4780
- stylesLookup[prop] = initialStylingValues.length - 1;
4781
- }
4782
- else {
4783
- totalStyleDeclarations++;
4784
- stylesLookup[prop] = 0;
4785
- }
4906
+ setStyle(element, initialStylingValues[i + 0 /* PropOffset */], value, renderer, null);
4786
4907
  }
4787
4908
  }
4788
4909
  }
4789
- // make where the class offsets begin
4790
- context[4 /* ClassOffsetPosition */] = totalStyleDeclarations;
4791
- var initialStaticClasses = onlyProcessSingleClasses ? [] : null;
4792
- if (initialClassDeclarations) {
4793
- var hasPassedDeclarations = false;
4794
- for (var i = 0; i < initialClassDeclarations.length; i++) {
4795
- var v = initialClassDeclarations[i];
4796
- // this flag value marks where the declarations end the initial values begin
4797
- if (v === 1 /* VALUES_MODE */) {
4798
- hasPassedDeclarations = true;
4910
+ }
4911
+ /**
4912
+ * Adds in new binding values to a styling context.
4913
+ *
4914
+ * If a directive value is provided then all provided class/style binding names will
4915
+ * reference the provided directive.
4916
+ *
4917
+ * @param context the existing styling context
4918
+ * @param directiveRef the directive that the new bindings will reference
4919
+ * @param classBindingNames an array of class binding names that will be added to the context
4920
+ * @param styleBindingNames an array of style binding names that will be added to the context
4921
+ * @param styleSanitizer an optional sanitizer that handle all sanitization on for each of
4922
+ * the bindings added to the context. Note that if a directive is provided then the sanitizer
4923
+ * instance will only be active if and when the directive updates the bindings that it owns.
4924
+ */
4925
+ function updateContextWithBindings(context, directiveRef, classBindingNames, styleBindingNames, styleSanitizer, onlyProcessSingleClasses) {
4926
+ if (context[0 /* MasterFlagPosition */] & 32 /* BindingAllocationLocked */)
4927
+ return;
4928
+ // this means the context has already been patched with the directive's bindings
4929
+ var directiveIndex = findOrPatchDirectiveIntoRegistry(context, directiveRef, styleSanitizer);
4930
+ if (directiveIndex === -1) {
4931
+ // this means the directive has already been patched in ... No point in doing anything
4932
+ return;
4933
+ }
4934
+ // there are alot of variables being used below to track where in the context the new
4935
+ // binding values will be placed. Because the context consists of multiple types of
4936
+ // entries (single classes/styles and multi classes/styles) alot of the index positions
4937
+ // need to be computed ahead of time and the context needs to be extended before the values
4938
+ // are inserted in.
4939
+ var singlePropOffsetValues = context[4 /* SinglePropOffsetPositions */];
4940
+ var totalCurrentClassBindings = singlePropOffsetValues[1 /* ClassesCountPosition */];
4941
+ var totalCurrentStyleBindings = singlePropOffsetValues[0 /* StylesCountPosition */];
4942
+ var classesOffset = totalCurrentClassBindings * 4 /* Size */;
4943
+ var stylesOffset = totalCurrentStyleBindings * 4 /* Size */;
4944
+ var singleStylesStartIndex = 9 /* SingleStylesStartPosition */;
4945
+ var singleClassesStartIndex = singleStylesStartIndex + stylesOffset;
4946
+ var multiStylesStartIndex = singleClassesStartIndex + classesOffset;
4947
+ var multiClassesStartIndex = multiStylesStartIndex + stylesOffset;
4948
+ // because we're inserting more bindings into the context, this means that the
4949
+ // binding values need to be referenced the singlePropOffsetValues array so that
4950
+ // the template/directive can easily find them inside of the `elementStyleProp`
4951
+ // and the `elementClassProp` functions without iterating through the entire context.
4952
+ // The first step to setting up these reference points is to mark how many bindings
4953
+ // are being added. Even if these bindings already exist in the context, the directive
4954
+ // or template code will still call them unknowingly. Therefore the total values need
4955
+ // to be registered so that we know how many bindings are assigned to each directive.
4956
+ var currentSinglePropsLength = singlePropOffsetValues.length;
4957
+ singlePropOffsetValues.push(styleBindingNames ? styleBindingNames.length : 0, classBindingNames ? classBindingNames.length : 0);
4958
+ // the code below will check to see if a new style binding already exists in the context
4959
+ // if so then there is no point in inserting it into the context again. Whether or not it
4960
+ // exists the styling offset code will now know exactly where it is
4961
+ var insertionOffset = 0;
4962
+ var filteredStyleBindingNames = [];
4963
+ if (styleBindingNames && styleBindingNames.length) {
4964
+ for (var i_1 = 0; i_1 < styleBindingNames.length; i_1++) {
4965
+ var name_1 = styleBindingNames[i_1];
4966
+ var singlePropIndex = getMatchingBindingIndex(context, name_1, singleStylesStartIndex, singleClassesStartIndex);
4967
+ if (singlePropIndex == -1) {
4968
+ singlePropIndex = singleClassesStartIndex + insertionOffset;
4969
+ insertionOffset += 4 /* Size */;
4970
+ filteredStyleBindingNames.push(name_1);
4971
+ }
4972
+ singlePropOffsetValues.push(singlePropIndex);
4973
+ }
4974
+ }
4975
+ // just like with the style binding loop above, the new class bindings get the same treatment...
4976
+ var filteredClassBindingNames = [];
4977
+ if (classBindingNames && classBindingNames.length) {
4978
+ for (var i_2 = 0; i_2 < classBindingNames.length; i_2++) {
4979
+ var name_2 = classBindingNames[i_2];
4980
+ var singlePropIndex = getMatchingBindingIndex(context, name_2, singleClassesStartIndex, multiStylesStartIndex);
4981
+ if (singlePropIndex == -1) {
4982
+ singlePropIndex = multiStylesStartIndex + insertionOffset;
4983
+ insertionOffset += 4 /* Size */;
4984
+ filteredClassBindingNames.push(name_2);
4799
4985
  }
4800
4986
  else {
4801
- var className = v;
4802
- if (hasPassedDeclarations) {
4803
- var value = initialClassDeclarations[++i];
4804
- initialStylingValues.push(value);
4805
- classesLookup[className] = initialStylingValues.length - 1;
4806
- initialStaticClasses && initialStaticClasses.push(className);
4807
- }
4808
- else {
4809
- classesLookup[className] = 0;
4987
+ singlePropIndex += filteredStyleBindingNames.length * 4 /* Size */;
4988
+ }
4989
+ singlePropOffsetValues.push(singlePropIndex);
4990
+ }
4991
+ }
4992
+ // because new styles are being inserted, this means the existing collection of style offset
4993
+ // index values are incorrect (they point to the wrong values). The code below will run through
4994
+ // the entire offset array and update the existing set of index values to point to their new
4995
+ // locations while taking the new binding values into consideration.
4996
+ var i = 2 /* ValueStartPosition */;
4997
+ if (filteredStyleBindingNames.length) {
4998
+ while (i < currentSinglePropsLength) {
4999
+ var totalStyles = singlePropOffsetValues[i + 0 /* StylesCountPosition */];
5000
+ var totalClasses = singlePropOffsetValues[i + 1 /* ClassesCountPosition */];
5001
+ if (totalClasses) {
5002
+ var start = i + 2 /* ValueStartPosition */ + totalStyles;
5003
+ for (var j = start; j < start + totalClasses; j++) {
5004
+ singlePropOffsetValues[j] += filteredStyleBindingNames.length * 4 /* Size */;
4810
5005
  }
4811
5006
  }
5007
+ var total = totalStyles + totalClasses;
5008
+ i += 2 /* ValueStartPosition */ + total;
4812
5009
  }
4813
5010
  }
4814
- var styleProps = Object.keys(stylesLookup);
4815
- var classNames = Object.keys(classesLookup);
4816
- var classNamesIndexStart = styleProps.length;
4817
- var totalProps = styleProps.length + classNames.length;
4818
- // *2 because we are filling for both single and multi style spaces
4819
- var maxLength = totalProps * 4 /* Size */ * 2 + 8 /* SingleStylesStartPosition */;
4820
- // we need to fill the array from the start so that we can access
4821
- // both the multi and the single array positions in the same loop block
4822
- for (var i = 8 /* SingleStylesStartPosition */; i < maxLength; i++) {
5011
+ var totalNewEntries = filteredClassBindingNames.length + filteredStyleBindingNames.length;
5012
+ // in the event that there are new style values being inserted, all existing class and style
5013
+ // bindings need to have their pointer values offsetted with the new amount of space that is
5014
+ // used for the new style/class bindings.
5015
+ for (var i_3 = singleStylesStartIndex; i_3 < context.length; i_3 += 4 /* Size */) {
5016
+ var isMultiBased = i_3 >= multiStylesStartIndex;
5017
+ var isClassBased = i_3 >= (isMultiBased ? multiClassesStartIndex : singleClassesStartIndex);
5018
+ var flag = getPointers(context, i_3);
5019
+ var staticIndex = getInitialIndex(flag);
5020
+ var singleOrMultiIndex = getMultiOrSingleIndex(flag);
5021
+ if (isMultiBased) {
5022
+ singleOrMultiIndex +=
5023
+ isClassBased ? (filteredStyleBindingNames.length * 4 /* Size */) : 0;
5024
+ }
5025
+ else {
5026
+ singleOrMultiIndex += (totalNewEntries * 4 /* Size */) +
5027
+ ((isClassBased ? filteredStyleBindingNames.length : 0) * 4 /* Size */);
5028
+ }
5029
+ setFlag(context, i_3, pointers(flag, staticIndex, singleOrMultiIndex));
5030
+ }
5031
+ // this is where we make space in the context for the new style bindings
5032
+ for (var i_4 = 0; i_4 < filteredStyleBindingNames.length * 4 /* Size */; i_4++) {
5033
+ context.splice(multiClassesStartIndex, 0, null);
5034
+ context.splice(singleClassesStartIndex, 0, null);
5035
+ singleClassesStartIndex++;
5036
+ multiStylesStartIndex++;
5037
+ multiClassesStartIndex += 2; // both single + multi slots were inserted
5038
+ }
5039
+ // this is where we make space in the context for the new class bindings
5040
+ for (var i_5 = 0; i_5 < filteredClassBindingNames.length * 4 /* Size */; i_5++) {
5041
+ context.splice(multiStylesStartIndex, 0, null);
4823
5042
  context.push(null);
4824
- }
4825
- var singleStart = 8 /* SingleStylesStartPosition */;
4826
- var multiStart = totalProps * 4 /* Size */ + 8 /* SingleStylesStartPosition */;
4827
- // fill single and multi-level styles
4828
- for (var i = 0; i < totalProps; i++) {
4829
- var isClassBased_1 = i >= classNamesIndexStart;
4830
- var prop = isClassBased_1 ? classNames[i - classNamesIndexStart] : styleProps[i];
4831
- var indexForInitial = isClassBased_1 ? classesLookup[prop] : stylesLookup[prop];
4832
- var initialValue = initialStylingValues[indexForInitial];
4833
- var indexForMulti = i * 4 /* Size */ + multiStart;
4834
- var indexForSingle = i * 4 /* Size */ + singleStart;
4835
- var initialFlag = prepareInitialFlag(prop, isClassBased_1, styleSanitizer || null);
4836
- setFlag(context, indexForSingle, pointers(initialFlag, indexForInitial, indexForMulti));
4837
- setProp(context, indexForSingle, prop);
4838
- setValue(context, indexForSingle, null);
4839
- setPlayerBuilderIndex(context, indexForSingle, 0);
4840
- var flagForMulti = initialFlag | (initialValue !== null ? 1 /* Dirty */ : 0 /* None */);
4841
- setFlag(context, indexForMulti, pointers(flagForMulti, indexForInitial, indexForSingle));
4842
- setProp(context, indexForMulti, prop);
4843
- setValue(context, indexForMulti, null);
4844
- setPlayerBuilderIndex(context, indexForMulti, 0);
4845
- }
5043
+ multiStylesStartIndex++;
5044
+ multiClassesStartIndex++;
5045
+ }
5046
+ var initialClasses = context[3 /* InitialClassValuesPosition */];
5047
+ var initialStyles = context[2 /* InitialStyleValuesPosition */];
5048
+ // the code below will insert each new entry into the context and assign the appropriate
5049
+ // flags and index values to them. It's important this runs at the end of this function
5050
+ // because the context, property offset and index values have all been computed just before.
5051
+ for (var i_6 = 0; i_6 < totalNewEntries; i_6++) {
5052
+ var entryIsClassBased = i_6 >= filteredStyleBindingNames.length;
5053
+ var adjustedIndex = entryIsClassBased ? (i_6 - filteredStyleBindingNames.length) : i_6;
5054
+ var propName = entryIsClassBased ? filteredClassBindingNames[adjustedIndex] :
5055
+ filteredStyleBindingNames[adjustedIndex];
5056
+ var multiIndex = void 0, singleIndex = void 0;
5057
+ if (entryIsClassBased) {
5058
+ multiIndex = multiClassesStartIndex +
5059
+ ((totalCurrentClassBindings + adjustedIndex) * 4 /* Size */);
5060
+ singleIndex = singleClassesStartIndex +
5061
+ ((totalCurrentClassBindings + adjustedIndex) * 4 /* Size */);
5062
+ }
5063
+ else {
5064
+ multiIndex =
5065
+ multiStylesStartIndex + ((totalCurrentStyleBindings + adjustedIndex) * 4 /* Size */);
5066
+ singleIndex = singleStylesStartIndex +
5067
+ ((totalCurrentStyleBindings + adjustedIndex) * 4 /* Size */);
5068
+ }
5069
+ // if a property is not found in the initial style values list then it
5070
+ // is ALWAYS added incase a follow-up directive introduces the same initial
5071
+ // style/class value later on.
5072
+ var initialValuesToLookup = entryIsClassBased ? initialClasses : initialStyles;
5073
+ var indexForInitial = getInitialStylingValuesIndexOf(initialValuesToLookup, propName);
5074
+ if (indexForInitial === -1) {
5075
+ indexForInitial = initialValuesToLookup.length + 1 /* ValueOffset */;
5076
+ initialValuesToLookup.push(propName, entryIsClassBased ? false : null);
5077
+ }
5078
+ else {
5079
+ indexForInitial += 1 /* ValueOffset */;
5080
+ }
5081
+ var initialFlag = prepareInitialFlag(context, propName, entryIsClassBased, styleSanitizer || null);
5082
+ setFlag(context, singleIndex, pointers(initialFlag, indexForInitial, multiIndex));
5083
+ setProp(context, singleIndex, propName);
5084
+ setValue(context, singleIndex, null);
5085
+ setPlayerBuilderIndex(context, singleIndex, 0, directiveIndex);
5086
+ setFlag(context, multiIndex, pointers(initialFlag, indexForInitial, singleIndex));
5087
+ setProp(context, multiIndex, propName);
5088
+ setValue(context, multiIndex, null);
5089
+ setPlayerBuilderIndex(context, multiIndex, 0, directiveIndex);
5090
+ }
5091
+ // the total classes/style values are updated so the next time the context is patched
5092
+ // additional style/class bindings from another directive then it knows exactly where
5093
+ // to insert them in the context
5094
+ singlePropOffsetValues[1 /* ClassesCountPosition */] =
5095
+ totalCurrentClassBindings + filteredClassBindingNames.length;
5096
+ singlePropOffsetValues[0 /* StylesCountPosition */] =
5097
+ totalCurrentStyleBindings + filteredStyleBindingNames.length;
4846
5098
  // there is no initial value flag for the master index since it doesn't
4847
5099
  // reference an initial style value
4848
- var masterFlag = pointers(0, 0, multiStart) |
5100
+ var masterFlag = pointers(0, 0, multiStylesStartIndex) |
4849
5101
  (onlyProcessSingleClasses ? 16 /* OnlyProcessSingleClasses */ : 0);
4850
- setFlag(context, 3 /* MasterFlagPosition */, masterFlag);
4851
- setContextDirty(context, initialStylingValues.length > 1);
4852
- if (initialStaticClasses) {
4853
- context[6 /* PreviousOrCachedMultiClassValue */] = initialStaticClasses.join(' ');
5102
+ setFlag(context, 0 /* MasterFlagPosition */, masterFlag);
5103
+ }
5104
+ /**
5105
+ * Searches through the existing registry of directives
5106
+ */
5107
+ function findOrPatchDirectiveIntoRegistry(context, directiveRef, styleSanitizer) {
5108
+ var directiveRefs = context[1 /* DirectiveRegistryPosition */];
5109
+ var nextOffsetInsertionIndex = context[4 /* SinglePropOffsetPositions */].length;
5110
+ var directiveIndex;
5111
+ var detectedIndex = getDirectiveRegistryValuesIndexOf(directiveRefs, directiveRef);
5112
+ if (detectedIndex === -1) {
5113
+ directiveIndex = directiveRefs.length / 4 /* Size */;
5114
+ directiveRefs.push(directiveRef, nextOffsetInsertionIndex, false, styleSanitizer || null);
4854
5115
  }
4855
- return context;
5116
+ else {
5117
+ var singlePropStartPosition = detectedIndex + 1 /* SinglePropValuesIndexOffset */;
5118
+ if (directiveRefs[singlePropStartPosition] >= 0) {
5119
+ // the directive has already been patched into the context
5120
+ return -1;
5121
+ }
5122
+ directiveIndex = detectedIndex / 4 /* Size */;
5123
+ // because the directive already existed this means that it was set during elementHostAttrs or
5124
+ // elementStart which means that the binding values were not here. Therefore, the values below
5125
+ // need to be applied so that single class and style properties can be assigned later.
5126
+ var singlePropPositionIndex = detectedIndex + 1 /* SinglePropValuesIndexOffset */;
5127
+ directiveRefs[singlePropPositionIndex] = nextOffsetInsertionIndex;
5128
+ // the sanitizer is also apart of the binding process and will be used when bindings are
5129
+ // applied.
5130
+ var styleSanitizerIndex = detectedIndex + 3 /* StyleSanitizerOffset */;
5131
+ directiveRefs[styleSanitizerIndex] = styleSanitizer || null;
5132
+ }
5133
+ return directiveIndex;
5134
+ }
5135
+ function getMatchingBindingIndex(context, bindingName, start, end) {
5136
+ for (var j = start; j < end; j += 4 /* Size */) {
5137
+ if (getProp(context, j) === bindingName)
5138
+ return j;
5139
+ }
5140
+ return -1;
4856
5141
  }
4857
5142
  /**
4858
5143
  * Sets and resolves all `multi` styling on an `StylingContext` so that they can be
4859
- * applied to the element once `renderStyleAndClassBindings` is called.
5144
+ * applied to the element once `renderStyling` is called.
4860
5145
  *
4861
5146
  * All missing styles/class (any values that are not provided in the new `styles`
4862
5147
  * or `classes` params) will resolve to `null` within their respective positions
@@ -4867,8 +5152,9 @@
4867
5152
  * @param classesInput The key/value map of CSS class names that will be used for the update.
4868
5153
  * @param stylesInput The key/value map of CSS styles that will be used for the update.
4869
5154
  */
4870
- function updateStylingMap(context, classesInput, stylesInput) {
5155
+ function updateStylingMap(context, classesInput, stylesInput, directiveRef) {
4871
5156
  stylesInput = stylesInput || null;
5157
+ var directiveIndex = getDirectiveIndexFromRegistry(context, directiveRef || null);
4872
5158
  var element = context[5 /* ElementPosition */];
4873
5159
  var classesPlayerBuilder = classesInput instanceof BoundPlayerFactory ?
4874
5160
  new ClassAndStylePlayerBuilder(classesInput, element, 1 /* Class */) :
@@ -4882,13 +5168,13 @@
4882
5168
  var stylesValue = stylesPlayerBuilder ? stylesInput.value : stylesInput;
4883
5169
  // early exit (this is what's done to avoid using ctx.bind() to cache the value)
4884
5170
  var ignoreAllClassUpdates = limitToSingleClasses(context) || classesValue === NO_CHANGE ||
4885
- classesValue === context[6 /* PreviousOrCachedMultiClassValue */];
4886
- var ignoreAllStyleUpdates = stylesValue === NO_CHANGE || stylesValue === context[7 /* PreviousMultiStyleValue */];
5171
+ classesValue === context[6 /* CachedClassValueOrInitialClassString */];
5172
+ var ignoreAllStyleUpdates = stylesValue === NO_CHANGE || stylesValue === context[7 /* CachedStyleValue */];
4887
5173
  if (ignoreAllClassUpdates && ignoreAllStyleUpdates)
4888
5174
  return;
4889
- context[6 /* PreviousOrCachedMultiClassValue */] = classesValue;
4890
- context[7 /* PreviousMultiStyleValue */] = stylesValue;
4891
- var classNames = EMPTY_ARR;
5175
+ context[6 /* CachedClassValueOrInitialClassString */] = classesValue;
5176
+ context[7 /* CachedStyleValue */] = stylesValue;
5177
+ var classNames = EMPTY_ARRAY;
4892
5178
  var applyAllClasses = false;
4893
5179
  var playerBuildersAreDirty = false;
4894
5180
  var classesPlayerBuilderIndex = classesPlayerBuilder ? 1 /* ClassMapPlayerBuilderPosition */ : 0;
@@ -4911,11 +5197,11 @@
4911
5197
  applyAllClasses = true;
4912
5198
  }
4913
5199
  else {
4914
- classNames = classesValue ? Object.keys(classesValue) : EMPTY_ARR;
5200
+ classNames = classesValue ? Object.keys(classesValue) : EMPTY_ARRAY;
4915
5201
  }
4916
5202
  }
4917
5203
  var classes = (classesValue || EMPTY_OBJ);
4918
- var styleProps = stylesValue ? Object.keys(stylesValue) : EMPTY_ARR;
5204
+ var styleProps = stylesValue ? Object.keys(stylesValue) : EMPTY_ARRAY;
4919
5205
  var styles = stylesValue || EMPTY_OBJ;
4920
5206
  var classesStartIndex = styleProps.length;
4921
5207
  var multiStartIndex = getMultiStartIndex(context);
@@ -4927,27 +5213,31 @@
4927
5213
  // styles differ with respect to the context. Later if the context/styles/classes
4928
5214
  // are off-balance then they will be dealt in another loop after this one
4929
5215
  while (ctxIndex < context.length && propIndex < propLimit) {
4930
- var isClassBased_2 = propIndex >= classesStartIndex;
4931
- var processValue = (!isClassBased_2 && !ignoreAllStyleUpdates) || (isClassBased_2 && !ignoreAllClassUpdates);
5216
+ var isClassBased = propIndex >= classesStartIndex;
5217
+ var processValue = (!isClassBased && !ignoreAllStyleUpdates) || (isClassBased && !ignoreAllClassUpdates);
4932
5218
  // when there is a cache-hit for a string-based class then we should
4933
5219
  // avoid doing any work diffing any of the changes
4934
5220
  if (processValue) {
4935
- var adjustedPropIndex = isClassBased_2 ? propIndex - classesStartIndex : propIndex;
4936
- var newProp = isClassBased_2 ? classNames[adjustedPropIndex] : styleProps[adjustedPropIndex];
4937
- var newValue = isClassBased_2 ? (applyAllClasses ? true : classes[newProp]) : styles[newProp];
4938
- var playerBuilderIndex = isClassBased_2 ? classesPlayerBuilderIndex : stylesPlayerBuilderIndex;
5221
+ var adjustedPropIndex = isClassBased ? propIndex - classesStartIndex : propIndex;
5222
+ var newProp = isClassBased ? classNames[adjustedPropIndex] : styleProps[adjustedPropIndex];
5223
+ var newValue = isClassBased ? (applyAllClasses ? true : classes[newProp]) : styles[newProp];
5224
+ var playerBuilderIndex = isClassBased ? classesPlayerBuilderIndex : stylesPlayerBuilderIndex;
4939
5225
  var prop = getProp(context, ctxIndex);
4940
5226
  if (prop === newProp) {
4941
5227
  var value = getValue(context, ctxIndex);
4942
5228
  var flag = getPointers(context, ctxIndex);
4943
- setPlayerBuilderIndex(context, ctxIndex, playerBuilderIndex);
5229
+ setPlayerBuilderIndex(context, ctxIndex, playerBuilderIndex, directiveIndex);
4944
5230
  if (hasValueChanged(flag, value, newValue)) {
4945
5231
  setValue(context, ctxIndex, newValue);
4946
5232
  playerBuildersAreDirty = playerBuildersAreDirty || !!playerBuilderIndex;
4947
5233
  var initialValue = getInitialValue(context, flag);
4948
- // there is no point in setting this to dirty if the previously
4949
- // rendered value was being referenced by the initial style (or null)
4950
- if (hasValueChanged(flag, initialValue, newValue)) {
5234
+ // SKIP IF INITIAL CHECK
5235
+ // If the former `value` is `null` then it means that an initial value
5236
+ // could be being rendered on screen. If that is the case then there is
5237
+ // no point in updating the value incase it matches. In other words if the
5238
+ // new value is the exact same as the previously rendered value (which
5239
+ // happens to be the initial value) then do nothing.
5240
+ if (value != null || hasValueChanged(flag, initialValue, newValue)) {
4951
5241
  setDirty(context, ctxIndex, true);
4952
5242
  dirty = true;
4953
5243
  }
@@ -4963,7 +5253,8 @@
4963
5253
  if (hasValueChanged(flagToCompare, valueToCompare, newValue)) {
4964
5254
  var initialValue = getInitialValue(context, flagToCompare);
4965
5255
  setValue(context, ctxIndex, newValue);
4966
- if (hasValueChanged(flagToCompare, initialValue, newValue)) {
5256
+ // same if statement logic as above (look for SKIP IF INITIAL CHECK).
5257
+ if (valueToCompare != null || hasValueChanged(flagToCompare, initialValue, newValue)) {
4967
5258
  setDirty(context, ctxIndex, true);
4968
5259
  playerBuildersAreDirty = playerBuildersAreDirty || !!playerBuilderIndex;
4969
5260
  dirty = true;
@@ -4972,9 +5263,9 @@
4972
5263
  }
4973
5264
  else {
4974
5265
  // we only care to do this if the insertion is in the middle
4975
- var newFlag = prepareInitialFlag(newProp, isClassBased_2, getStyleSanitizer(context));
5266
+ var newFlag = prepareInitialFlag(context, newProp, isClassBased, getStyleSanitizer(context, directiveIndex));
4976
5267
  playerBuildersAreDirty = playerBuildersAreDirty || !!playerBuilderIndex;
4977
- insertNewMultiProperty(context, ctxIndex, isClassBased_2, newProp, newFlag, newValue, playerBuilderIndex);
5268
+ insertNewMultiProperty(context, ctxIndex, isClassBased, newProp, newFlag, newValue, directiveIndex, playerBuilderIndex);
4978
5269
  dirty = true;
4979
5270
  }
4980
5271
  }
@@ -4987,19 +5278,19 @@
4987
5278
  // case the goal is to "remove" them from the context (by nullifying)
4988
5279
  while (ctxIndex < context.length) {
4989
5280
  var flag = getPointers(context, ctxIndex);
4990
- var isClassBased_3 = (flag & 2 /* Class */) === 2 /* Class */;
4991
- var processValue = (!isClassBased_3 && !ignoreAllStyleUpdates) || (isClassBased_3 && !ignoreAllClassUpdates);
5281
+ var isClassBased = (flag & 2 /* Class */) === 2 /* Class */;
5282
+ var processValue = (!isClassBased && !ignoreAllStyleUpdates) || (isClassBased && !ignoreAllClassUpdates);
4992
5283
  if (processValue) {
4993
5284
  var value = getValue(context, ctxIndex);
4994
- var doRemoveValue = valueExists(value, isClassBased_3);
5285
+ var doRemoveValue = valueExists(value, isClassBased);
4995
5286
  if (doRemoveValue) {
4996
5287
  setDirty(context, ctxIndex, true);
4997
5288
  setValue(context, ctxIndex, null);
4998
5289
  // we keep the player factory the same so that the `nulled` value can
4999
5290
  // be instructed into the player because removing a style and/or a class
5000
5291
  // is a valid animation player instruction.
5001
- var playerBuilderIndex = isClassBased_3 ? classesPlayerBuilderIndex : stylesPlayerBuilderIndex;
5002
- setPlayerBuilderIndex(context, ctxIndex, playerBuilderIndex);
5292
+ var playerBuilderIndex = isClassBased ? classesPlayerBuilderIndex : stylesPlayerBuilderIndex;
5293
+ setPlayerBuilderIndex(context, ctxIndex, playerBuilderIndex, directiveIndex);
5003
5294
  dirty = true;
5004
5295
  }
5005
5296
  }
@@ -5008,31 +5299,46 @@
5008
5299
  // this means that there are left-over properties in the context that
5009
5300
  // were not detected in the context during the loop above. In that
5010
5301
  // case we want to add the new entries into the list
5011
- var sanitizer = getStyleSanitizer(context);
5302
+ var sanitizer = getStyleSanitizer(context, directiveIndex);
5012
5303
  while (propIndex < propLimit) {
5013
- var isClassBased_4 = propIndex >= classesStartIndex;
5014
- var processValue = (!isClassBased_4 && !ignoreAllStyleUpdates) || (isClassBased_4 && !ignoreAllClassUpdates);
5304
+ var isClassBased = propIndex >= classesStartIndex;
5305
+ var processValue = (!isClassBased && !ignoreAllStyleUpdates) || (isClassBased && !ignoreAllClassUpdates);
5015
5306
  if (processValue) {
5016
- var adjustedPropIndex = isClassBased_4 ? propIndex - classesStartIndex : propIndex;
5017
- var prop = isClassBased_4 ? classNames[adjustedPropIndex] : styleProps[adjustedPropIndex];
5018
- var value = isClassBased_4 ? (applyAllClasses ? true : classes[prop]) : styles[prop];
5019
- var flag = prepareInitialFlag(prop, isClassBased_4, sanitizer) | 1 /* Dirty */;
5020
- var playerBuilderIndex = isClassBased_4 ? classesPlayerBuilderIndex : stylesPlayerBuilderIndex;
5021
- context.push(flag, prop, value, playerBuilderIndex);
5307
+ var adjustedPropIndex = isClassBased ? propIndex - classesStartIndex : propIndex;
5308
+ var prop = isClassBased ? classNames[adjustedPropIndex] : styleProps[adjustedPropIndex];
5309
+ var value = isClassBased ? (applyAllClasses ? true : classes[prop]) : styles[prop];
5310
+ var flag = prepareInitialFlag(context, prop, isClassBased, sanitizer) | 1 /* Dirty */;
5311
+ var playerBuilderIndex = isClassBased ? classesPlayerBuilderIndex : stylesPlayerBuilderIndex;
5312
+ var ctxIndex_1 = context.length;
5313
+ context.push(flag, prop, value, 0);
5314
+ setPlayerBuilderIndex(context, ctxIndex_1, playerBuilderIndex, directiveIndex);
5022
5315
  dirty = true;
5023
5316
  }
5024
5317
  propIndex++;
5025
5318
  }
5026
5319
  if (dirty) {
5027
5320
  setContextDirty(context, true);
5321
+ setDirectiveDirty(context, directiveIndex, true);
5028
5322
  }
5029
5323
  if (playerBuildersAreDirty) {
5030
5324
  setContextPlayersDirty(context, true);
5031
5325
  }
5032
5326
  }
5033
5327
  /**
5034
- * Sets and resolves a single styling property/value on the provided `StylingContext` so
5035
- * that they can be applied to the element once `renderStyleAndClassBindings` is called.
5328
+ * This method will toggle the referenced CSS class (by the provided index)
5329
+ * within the given context.
5330
+ *
5331
+ * @param context The styling context that will be updated with the
5332
+ * newly provided class value.
5333
+ * @param offset The index of the CSS class which is being updated.
5334
+ * @param addOrRemove Whether or not to add or remove the CSS class
5335
+ */
5336
+ function updateClassProp(context, offset, addOrRemove, directiveRef) {
5337
+ _updateSingleStylingValue(context, offset, addOrRemove, true, directiveRef);
5338
+ }
5339
+ /**
5340
+ * Sets and resolves a single style value on the provided `StylingContext` so
5341
+ * that they can be applied to the element once `renderStyling` is called.
5036
5342
  *
5037
5343
  * Note that prop-level styling values are considered higher priority than any styling that
5038
5344
  * has been applied using `updateStylingMap`, therefore, when styling values are rendered
@@ -5041,20 +5347,29 @@
5041
5347
  *
5042
5348
  * @param context The styling context that will be updated with the
5043
5349
  * newly provided style value.
5044
- * @param index The index of the property which is being updated.
5350
+ * @param offset The index of the property which is being updated.
5045
5351
  * @param value The CSS style value that will be assigned
5352
+ * @param directiveRef an optional reference to the directive responsible
5353
+ * for this binding change. If present then style binding will only
5354
+ * actualize if the directive has ownership over this binding
5355
+ * (see styling.ts#directives for more information about the algorithm).
5046
5356
  */
5047
- function updateStyleProp(context, index, input) {
5048
- var singleIndex = 8 /* SingleStylesStartPosition */ + index * 4 /* Size */;
5357
+ function updateStyleProp(context, offset, input, directiveRef) {
5358
+ _updateSingleStylingValue(context, offset, input, false, directiveRef);
5359
+ }
5360
+ function _updateSingleStylingValue(context, offset, input, isClassBased, directiveRef) {
5361
+ var directiveIndex = getDirectiveIndexFromRegistry(context, directiveRef || null);
5362
+ var singleIndex = getSinglePropIndexValue(context, directiveIndex, offset, isClassBased);
5049
5363
  var currValue = getValue(context, singleIndex);
5050
5364
  var currFlag = getPointers(context, singleIndex);
5365
+ var currDirective = getDirectiveIndexFromEntry(context, singleIndex);
5051
5366
  var value = (input instanceof BoundPlayerFactory) ? input.value : input;
5052
- // didn't change ... nothing to make a note of
5053
- if (hasValueChanged(currFlag, currValue, value)) {
5054
- var isClassBased_5 = (currFlag & 2 /* Class */) === 2 /* Class */;
5367
+ if (hasValueChanged(currFlag, currValue, value) &&
5368
+ allowValueChange(currValue, value, currDirective, directiveIndex)) {
5369
+ var isClassBased_1 = (currFlag & 2 /* Class */) === 2 /* Class */;
5055
5370
  var element = context[5 /* ElementPosition */];
5056
5371
  var playerBuilder = input instanceof BoundPlayerFactory ?
5057
- new ClassAndStylePlayerBuilder(input, element, isClassBased_5 ? 1 /* Class */ : 2 /* Style */) :
5372
+ new ClassAndStylePlayerBuilder(input, element, isClassBased_1 ? 1 /* Class */ : 2 /* Style */) :
5058
5373
  null;
5059
5374
  var value_1 = (playerBuilder ? input.value : input);
5060
5375
  var currPlayerIndex = getPlayerBuilderIndex(context, singleIndex);
@@ -5063,9 +5378,16 @@
5063
5378
  if (hasPlayerBuilderChanged(context, playerBuilder, currPlayerIndex)) {
5064
5379
  var newIndex = setPlayerBuilder(context, playerBuilder, currPlayerIndex);
5065
5380
  playerBuilderIndex = playerBuilder ? newIndex : 0;
5066
- setPlayerBuilderIndex(context, singleIndex, playerBuilderIndex);
5067
5381
  playerBuildersAreDirty = true;
5068
5382
  }
5383
+ if (playerBuildersAreDirty || currDirective !== directiveIndex) {
5384
+ setPlayerBuilderIndex(context, singleIndex, playerBuilderIndex, directiveIndex);
5385
+ }
5386
+ if (currDirective !== directiveIndex) {
5387
+ var prop = getProp(context, singleIndex);
5388
+ var sanitizer = getStyleSanitizer(context, directiveIndex);
5389
+ setSanitizeFlag(context, singleIndex, (sanitizer && sanitizer(prop)) ? true : false);
5390
+ }
5069
5391
  // the value will always get updated (even if the dirty flag is skipped)
5070
5392
  setValue(context, singleIndex, value_1);
5071
5393
  var indexForMulti = getMultiOrSingleIndex(currFlag);
@@ -5075,12 +5397,13 @@
5075
5397
  var multiDirty = false;
5076
5398
  var singleDirty = true;
5077
5399
  // only when the value is set to `null` should the multi-value get flagged
5078
- if (!valueExists(value_1, isClassBased_5) && valueExists(valueForMulti, isClassBased_5)) {
5400
+ if (!valueExists(value_1, isClassBased_1) && valueExists(valueForMulti, isClassBased_1)) {
5079
5401
  multiDirty = true;
5080
5402
  singleDirty = false;
5081
5403
  }
5082
5404
  setDirty(context, indexForMulti, multiDirty);
5083
5405
  setDirty(context, singleIndex, singleDirty);
5406
+ setDirectiveDirty(context, directiveIndex, true);
5084
5407
  setContextDirty(context, true);
5085
5408
  }
5086
5409
  if (playerBuildersAreDirty) {
@@ -5088,19 +5411,6 @@
5088
5411
  }
5089
5412
  }
5090
5413
  }
5091
- /**
5092
- * This method will toggle the referenced CSS class (by the provided index)
5093
- * within the given context.
5094
- *
5095
- * @param context The styling context that will be updated with the
5096
- * newly provided class value.
5097
- * @param index The index of the CSS class which is being updated.
5098
- * @param addOrRemove Whether or not to add or remove the CSS class
5099
- */
5100
- function updateClassProp(context, index, addOrRemove) {
5101
- var adjustedIndex = index + context[4 /* ClassOffsetPosition */];
5102
- updateStyleProp(context, adjustedIndex, addOrRemove);
5103
- }
5104
5414
  /**
5105
5415
  * Renders all queued styling using a renderer onto the given element.
5106
5416
  *
@@ -5118,31 +5428,41 @@
5118
5428
  * to this key/value map instead of being renderered via the renderer.
5119
5429
  * @param stylesStore if provided, the updated style values will be applied
5120
5430
  * to this key/value map instead of being renderered via the renderer.
5431
+ * @param directiveRef an optional directive that will be used to target which
5432
+ * styling values are rendered. If left empty, only the bindings that are
5433
+ * registered on the template will be rendered.
5121
5434
  * @returns number the total amount of players that got queued for animation (if any)
5122
5435
  */
5123
- function renderStyleAndClassBindings(context, renderer, rootOrView, isFirstRender, classesStore, stylesStore) {
5436
+ function renderStyling(context, renderer, rootOrView, isFirstRender, classesStore, stylesStore, directiveRef) {
5124
5437
  var totalPlayersQueued = 0;
5125
- if (isContextDirty(context)) {
5126
- var flushPlayerBuilders = context[3 /* MasterFlagPosition */] & 8 /* PlayerBuildersDirty */;
5438
+ var targetDirectiveIndex = getDirectiveIndexFromRegistry(context, directiveRef || null);
5439
+ if (isContextDirty(context) && isDirectiveDirty(context, targetDirectiveIndex)) {
5440
+ var flushPlayerBuilders = context[0 /* MasterFlagPosition */] & 8 /* PlayerBuildersDirty */;
5127
5441
  var native = context[5 /* ElementPosition */];
5128
5442
  var multiStartIndex = getMultiStartIndex(context);
5129
- var styleSanitizer = getStyleSanitizer(context);
5130
5443
  var onlySingleClasses = limitToSingleClasses(context);
5131
- for (var i = 8 /* SingleStylesStartPosition */; i < context.length; i += 4 /* Size */) {
5444
+ var stillDirty = false;
5445
+ for (var i = 9 /* SingleStylesStartPosition */; i < context.length; i += 4 /* Size */) {
5132
5446
  // there is no point in rendering styles that have not changed on screen
5133
5447
  if (isDirty(context, i)) {
5448
+ var flag = getPointers(context, i);
5449
+ var directiveIndex = getDirectiveIndexFromEntry(context, i);
5450
+ if (targetDirectiveIndex !== directiveIndex) {
5451
+ stillDirty = true;
5452
+ continue;
5453
+ }
5134
5454
  var prop = getProp(context, i);
5135
5455
  var value = getValue(context, i);
5136
- var flag = getPointers(context, i);
5456
+ var styleSanitizer = (flag & 4 /* Sanitize */) ? getStyleSanitizer(context, directiveIndex) : null;
5137
5457
  var playerBuilder = getPlayerBuilder(context, i);
5138
- var isClassBased_6 = flag & 2 /* Class */ ? true : false;
5458
+ var isClassBased = flag & 2 /* Class */ ? true : false;
5139
5459
  var isInSingleRegion = i < multiStartIndex;
5140
- var readInitialValue = !isClassBased_6 || !onlySingleClasses;
5460
+ var readInitialValue = !isClassBased || !onlySingleClasses;
5141
5461
  var valueToApply = value;
5142
5462
  // VALUE DEFER CASE 1: Use a multi value instead of a null single value
5143
5463
  // this check implies that a single value was removed and we
5144
5464
  // should now defer to a multi value and use that (if set).
5145
- if (isInSingleRegion && !valueExists(valueToApply, isClassBased_6)) {
5465
+ if (isInSingleRegion && !valueExists(valueToApply, isClassBased)) {
5146
5466
  // single values ALWAYS have a reference to a multi index
5147
5467
  var multiIndex = getMultiOrSingleIndex(flag);
5148
5468
  valueToApply = getValue(context, multiIndex);
@@ -5153,7 +5473,9 @@
5153
5473
  // note that this should always be a falsy check since `false` is used
5154
5474
  // for both class and style comparisons (styles can't be false and false
5155
5475
  // classes are turned off and should therefore defer to their initial values)
5156
- if (!valueExists(valueToApply, isClassBased_6) && readInitialValue) {
5476
+ // Note that we ignore class-based deferals because otherwise a class can never
5477
+ // be removed in the case that it exists as true in the initial classes list...
5478
+ if (!isClassBased && !valueExists(valueToApply, isClassBased) && readInitialValue) {
5157
5479
  valueToApply = getInitialValue(context, flag);
5158
5480
  }
5159
5481
  // if the first render is true then we do not want to start applying falsy
@@ -5162,12 +5484,11 @@
5162
5484
  // was truthy before.
5163
5485
  var doApplyValue = isFirstRender ? valueToApply : true;
5164
5486
  if (doApplyValue) {
5165
- if (isClassBased_6) {
5487
+ if (isClassBased) {
5166
5488
  setClass(native, prop, valueToApply ? true : false, renderer, classesStore, playerBuilder);
5167
5489
  }
5168
5490
  else {
5169
- var sanitizer = (flag & 4 /* Sanitize */) ? styleSanitizer : null;
5170
- setStyle(native, prop, valueToApply, renderer, sanitizer, stylesStore, playerBuilder);
5491
+ setStyle(native, prop, valueToApply, renderer, styleSanitizer, stylesStore, playerBuilder);
5171
5492
  }
5172
5493
  }
5173
5494
  setDirty(context, i, false);
@@ -5201,7 +5522,8 @@
5201
5522
  }
5202
5523
  setContextPlayersDirty(context, false);
5203
5524
  }
5204
- setContextDirty(context, false);
5525
+ setDirectiveDirty(context, targetDirectiveIndex, false);
5526
+ setContextDirty(context, stillDirty);
5205
5527
  }
5206
5528
  return totalPlayersQueued;
5207
5529
  }
@@ -5228,6 +5550,8 @@
5228
5550
  }
5229
5551
  }
5230
5552
  else if (value) {
5553
+ value = value.toString(); // opacity, z-index and flexbox all have number values which may not
5554
+ // assign as numbers
5231
5555
  ngDevMode && ngDevMode.rendererSetStyle++;
5232
5556
  isProceduralRenderer(renderer) ?
5233
5557
  renderer.setStyle(native, prop, value, RendererStyleFlags3.DashCase) :
@@ -5272,8 +5596,16 @@
5272
5596
  native['classList'].remove(className);
5273
5597
  }
5274
5598
  }
5599
+ function setSanitizeFlag(context, index, sanitizeYes) {
5600
+ if (sanitizeYes) {
5601
+ context[index] |= 4 /* Sanitize */;
5602
+ }
5603
+ else {
5604
+ context[index] &= ~4 /* Sanitize */;
5605
+ }
5606
+ }
5275
5607
  function setDirty(context, index, isDirtyYes) {
5276
- var adjustedIndex = index >= 8 /* SingleStylesStartPosition */ ? (index + 0 /* FlagsOffset */) : index;
5608
+ var adjustedIndex = index >= 9 /* SingleStylesStartPosition */ ? (index + 0 /* FlagsOffset */) : index;
5277
5609
  if (isDirtyYes) {
5278
5610
  context[adjustedIndex] |= 1 /* Dirty */;
5279
5611
  }
@@ -5282,37 +5614,37 @@
5282
5614
  }
5283
5615
  }
5284
5616
  function isDirty(context, index) {
5285
- var adjustedIndex = index >= 8 /* SingleStylesStartPosition */ ? (index + 0 /* FlagsOffset */) : index;
5617
+ var adjustedIndex = index >= 9 /* SingleStylesStartPosition */ ? (index + 0 /* FlagsOffset */) : index;
5286
5618
  return (context[adjustedIndex] & 1 /* Dirty */) == 1 /* Dirty */;
5287
5619
  }
5288
- function isClassBased(context, index) {
5289
- var adjustedIndex = index >= 8 /* SingleStylesStartPosition */ ? (index + 0 /* FlagsOffset */) : index;
5620
+ function isClassBasedValue(context, index) {
5621
+ var adjustedIndex = index >= 9 /* SingleStylesStartPosition */ ? (index + 0 /* FlagsOffset */) : index;
5290
5622
  return (context[adjustedIndex] & 2 /* Class */) == 2 /* Class */;
5291
5623
  }
5292
5624
  function isSanitizable(context, index) {
5293
- var adjustedIndex = index >= 8 /* SingleStylesStartPosition */ ? (index + 0 /* FlagsOffset */) : index;
5625
+ var adjustedIndex = index >= 9 /* SingleStylesStartPosition */ ? (index + 0 /* FlagsOffset */) : index;
5294
5626
  return (context[adjustedIndex] & 4 /* Sanitize */) == 4 /* Sanitize */;
5295
5627
  }
5296
5628
  function pointers(configFlag, staticIndex, dynamicIndex) {
5297
- return (configFlag & 31 /* BitMask */) | (staticIndex << 5 /* BitCountSize */) |
5298
- (dynamicIndex << (14 /* BitCountSize */ + 5 /* BitCountSize */));
5629
+ return (configFlag & 63 /* BitMask */) | (staticIndex << 6 /* BitCountSize */) |
5630
+ (dynamicIndex << (14 /* BitCountSize */ + 6 /* BitCountSize */));
5299
5631
  }
5300
5632
  function getInitialValue(context, flag) {
5301
5633
  var index = getInitialIndex(flag);
5302
- return context[2 /* InitialStylesPosition */][index];
5634
+ var entryIsClassBased = flag & 2 /* Class */;
5635
+ var initialValues = entryIsClassBased ? context[3 /* InitialClassValuesPosition */] :
5636
+ context[2 /* InitialStyleValuesPosition */];
5637
+ return initialValues[index];
5303
5638
  }
5304
5639
  function getInitialIndex(flag) {
5305
- return (flag >> 5 /* BitCountSize */) & 16383 /* BitMask */;
5640
+ return (flag >> 6 /* BitCountSize */) & 16383 /* BitMask */;
5306
5641
  }
5307
5642
  function getMultiOrSingleIndex(flag) {
5308
- var index = (flag >> (14 /* BitCountSize */ + 5 /* BitCountSize */)) & 16383 /* BitMask */;
5309
- return index >= 8 /* SingleStylesStartPosition */ ? index : -1;
5643
+ var index = (flag >> (14 /* BitCountSize */ + 6 /* BitCountSize */)) & 16383 /* BitMask */;
5644
+ return index >= 9 /* SingleStylesStartPosition */ ? index : -1;
5310
5645
  }
5311
5646
  function getMultiStartIndex(context) {
5312
- return getMultiOrSingleIndex(context[3 /* MasterFlagPosition */]);
5313
- }
5314
- function getStyleSanitizer(context) {
5315
- return context[1 /* StyleSanitizerPosition */];
5647
+ return getMultiOrSingleIndex(context[0 /* MasterFlagPosition */]);
5316
5648
  }
5317
5649
  function setProp(context, index, prop) {
5318
5650
  context[index + 1 /* PropertyOffset */] = prop;
@@ -5321,7 +5653,7 @@
5321
5653
  context[index + 2 /* ValueOffset */] = value;
5322
5654
  }
5323
5655
  function hasPlayerBuilderChanged(context, builder, index) {
5324
- var playerContext = context[0 /* PlayerContext */];
5656
+ var playerContext = context[8 /* PlayerContext */];
5325
5657
  if (builder) {
5326
5658
  if (!playerContext || index === 0) {
5327
5659
  return true;
@@ -5333,7 +5665,7 @@
5333
5665
  return playerContext[index] !== builder;
5334
5666
  }
5335
5667
  function setPlayerBuilder(context, builder, insertionIndex) {
5336
- var playerContext = context[0 /* PlayerContext */] || allocPlayerContext(context);
5668
+ var playerContext = context[8 /* PlayerContext */] || allocPlayerContext(context);
5337
5669
  if (insertionIndex > 0) {
5338
5670
  playerContext[insertionIndex] = builder;
5339
5671
  }
@@ -5345,16 +5677,23 @@
5345
5677
  }
5346
5678
  return insertionIndex;
5347
5679
  }
5348
- function setPlayerBuilderIndex(context, index, playerBuilderIndex) {
5349
- context[index + 3 /* PlayerBuilderIndexOffset */] = playerBuilderIndex;
5680
+ function directiveOwnerPointers(directiveIndex, playerIndex) {
5681
+ return (playerIndex << 16 /* BitCountSize */) | directiveIndex;
5682
+ }
5683
+ function setPlayerBuilderIndex(context, index, playerBuilderIndex, directiveIndex) {
5684
+ var value = directiveOwnerPointers(directiveIndex, playerBuilderIndex);
5685
+ context[index + 3 /* PlayerBuilderIndexOffset */] = value;
5350
5686
  }
5351
5687
  function getPlayerBuilderIndex(context, index) {
5352
- return context[index + 3 /* PlayerBuilderIndexOffset */] || 0;
5688
+ var flag = context[index + 3 /* PlayerBuilderIndexOffset */];
5689
+ var playerBuilderIndex = (flag >> 16 /* BitCountSize */) &
5690
+ 65535 /* BitMask */;
5691
+ return playerBuilderIndex;
5353
5692
  }
5354
5693
  function getPlayerBuilder(context, index) {
5355
5694
  var playerBuilderIndex = getPlayerBuilderIndex(context, index);
5356
5695
  if (playerBuilderIndex) {
5357
- var playerContext = context[0 /* PlayerContext */];
5696
+ var playerContext = context[8 /* PlayerContext */];
5358
5697
  if (playerContext) {
5359
5698
  return playerContext[playerBuilderIndex];
5360
5699
  }
@@ -5362,11 +5701,11 @@
5362
5701
  return null;
5363
5702
  }
5364
5703
  function setFlag(context, index, flag) {
5365
- var adjustedIndex = index === 3 /* MasterFlagPosition */ ? index : (index + 0 /* FlagsOffset */);
5704
+ var adjustedIndex = index === 0 /* MasterFlagPosition */ ? index : (index + 0 /* FlagsOffset */);
5366
5705
  context[adjustedIndex] = flag;
5367
5706
  }
5368
5707
  function getPointers(context, index) {
5369
- var adjustedIndex = index === 3 /* MasterFlagPosition */ ? index : (index + 0 /* FlagsOffset */);
5708
+ var adjustedIndex = index === 0 /* MasterFlagPosition */ ? index : (index + 0 /* FlagsOffset */);
5370
5709
  return context[adjustedIndex];
5371
5710
  }
5372
5711
  function getValue(context, index) {
@@ -5376,20 +5715,20 @@
5376
5715
  return context[index + 1 /* PropertyOffset */];
5377
5716
  }
5378
5717
  function isContextDirty(context) {
5379
- return isDirty(context, 3 /* MasterFlagPosition */);
5718
+ return isDirty(context, 0 /* MasterFlagPosition */);
5380
5719
  }
5381
5720
  function limitToSingleClasses(context) {
5382
- return context[3 /* MasterFlagPosition */] & 16 /* OnlyProcessSingleClasses */;
5721
+ return context[0 /* MasterFlagPosition */] & 16 /* OnlyProcessSingleClasses */;
5383
5722
  }
5384
5723
  function setContextDirty(context, isDirtyYes) {
5385
- setDirty(context, 3 /* MasterFlagPosition */, isDirtyYes);
5724
+ setDirty(context, 0 /* MasterFlagPosition */, isDirtyYes);
5386
5725
  }
5387
5726
  function setContextPlayersDirty(context, isDirtyYes) {
5388
5727
  if (isDirtyYes) {
5389
- context[3 /* MasterFlagPosition */] |= 8 /* PlayerBuildersDirty */;
5728
+ context[0 /* MasterFlagPosition */] |= 8 /* PlayerBuildersDirty */;
5390
5729
  }
5391
5730
  else {
5392
- context[3 /* MasterFlagPosition */] &= ~8 /* PlayerBuildersDirty */;
5731
+ context[0 /* MasterFlagPosition */] &= ~8 /* PlayerBuildersDirty */;
5393
5732
  }
5394
5733
  }
5395
5734
  function findEntryPositionByProp(context, prop, startIndex) {
@@ -5423,11 +5762,13 @@
5423
5762
  setValue(context, indexA, getValue(context, indexB));
5424
5763
  setProp(context, indexA, getProp(context, indexB));
5425
5764
  setFlag(context, indexA, getPointers(context, indexB));
5426
- setPlayerBuilderIndex(context, indexA, getPlayerBuilderIndex(context, indexB));
5765
+ var playerIndexA = getPlayerBuilderIndex(context, indexB);
5766
+ var directiveIndexA = 0;
5767
+ setPlayerBuilderIndex(context, indexA, playerIndexA, directiveIndexA);
5427
5768
  setValue(context, indexB, tmpValue);
5428
5769
  setProp(context, indexB, tmpProp);
5429
5770
  setFlag(context, indexB, tmpFlag);
5430
- setPlayerBuilderIndex(context, indexB, tmpPlayerBuilderIndex);
5771
+ setPlayerBuilderIndex(context, indexB, tmpPlayerBuilderIndex, directiveIndexA);
5431
5772
  }
5432
5773
  function updateSinglePointerValues(context, indexStartPosition) {
5433
5774
  for (var i = indexStartPosition; i < context.length; i += 4 /* Size */) {
@@ -5437,17 +5778,18 @@
5437
5778
  var singleFlag = getPointers(context, singleIndex);
5438
5779
  var initialIndexForSingle = getInitialIndex(singleFlag);
5439
5780
  var flagValue = (isDirty(context, singleIndex) ? 1 /* Dirty */ : 0 /* None */) |
5440
- (isClassBased(context, singleIndex) ? 2 /* Class */ : 0 /* None */) |
5781
+ (isClassBasedValue(context, singleIndex) ? 2 /* Class */ : 0 /* None */) |
5441
5782
  (isSanitizable(context, singleIndex) ? 4 /* Sanitize */ : 0 /* None */);
5442
5783
  var updatedFlag = pointers(flagValue, initialIndexForSingle, i);
5443
5784
  setFlag(context, singleIndex, updatedFlag);
5444
5785
  }
5445
5786
  }
5446
5787
  }
5447
- function insertNewMultiProperty(context, index, classBased, name, flag, value, playerIndex) {
5788
+ function insertNewMultiProperty(context, index, classBased, name, flag, value, directiveIndex, playerIndex) {
5448
5789
  var doShift = index < context.length;
5449
5790
  // prop does not exist in the list, add it in
5450
- context.splice(index, 0, flag | 1 /* Dirty */ | (classBased ? 2 /* Class */ : 0 /* None */), name, value, playerIndex);
5791
+ context.splice(index, 0, flag | 1 /* Dirty */ | (classBased ? 2 /* Class */ : 0 /* None */), name, value, 0);
5792
+ setPlayerBuilderIndex(context, index, playerIndex, directiveIndex);
5451
5793
  if (doShift) {
5452
5794
  // because the value was inserted midway into the array then we
5453
5795
  // need to update all the shifted multi values' single value
@@ -5461,14 +5803,20 @@
5461
5803
  }
5462
5804
  return value !== null;
5463
5805
  }
5464
- function prepareInitialFlag(name, isClassBased, sanitizer) {
5465
- if (isClassBased) {
5466
- return 2 /* Class */;
5806
+ function prepareInitialFlag(context, prop, entryIsClassBased, sanitizer) {
5807
+ var flag = (sanitizer && sanitizer(prop)) ? 4 /* Sanitize */ : 0 /* None */;
5808
+ var initialIndex;
5809
+ if (entryIsClassBased) {
5810
+ flag |= 2 /* Class */;
5811
+ initialIndex =
5812
+ getInitialStylingValuesIndexOf(context[3 /* InitialClassValuesPosition */], prop);
5467
5813
  }
5468
- else if (sanitizer && sanitizer(name)) {
5469
- return 4 /* Sanitize */;
5814
+ else {
5815
+ initialIndex =
5816
+ getInitialStylingValuesIndexOf(context[2 /* InitialStyleValuesPosition */], prop);
5470
5817
  }
5471
- return 0 /* None */;
5818
+ initialIndex = initialIndex > 0 ? (initialIndex + 1 /* ValueOffset */) : 0;
5819
+ return pointers(flag, initialIndex, 0);
5472
5820
  }
5473
5821
  function hasValueChanged(flag, a, b) {
5474
5822
  var isClassBased = flag & 2 /* Class */;
@@ -5512,6 +5860,108 @@
5512
5860
  };
5513
5861
  return ClassAndStylePlayerBuilder;
5514
5862
  }());
5863
+ function getDirectiveIndexFromEntry(context, index) {
5864
+ var value = context[index + 3 /* PlayerBuilderIndexOffset */];
5865
+ return value & 65535 /* BitMask */;
5866
+ }
5867
+ function getDirectiveIndexFromRegistry(context, directive) {
5868
+ var index = getDirectiveRegistryValuesIndexOf(context[1 /* DirectiveRegistryPosition */], directive);
5869
+ ngDevMode &&
5870
+ assertNotEqual(index, -1, "The provided directive " + directive + " has not been allocated to the element's style/class bindings");
5871
+ return index > 0 ? index / 4 /* Size */ : 0;
5872
+ // return index / DirectiveRegistryValuesIndex.Size;
5873
+ }
5874
+ function getDirectiveRegistryValuesIndexOf(directives, directive) {
5875
+ for (var i = 0; i < directives.length; i += 4 /* Size */) {
5876
+ if (directives[i] === directive) {
5877
+ return i;
5878
+ }
5879
+ }
5880
+ return -1;
5881
+ }
5882
+ function getInitialStylingValuesIndexOf(keyValues, key) {
5883
+ for (var i = 1 /* KeyValueStartPosition */; i < keyValues.length; i += 2 /* Size */) {
5884
+ if (keyValues[i] === key)
5885
+ return i;
5886
+ }
5887
+ return -1;
5888
+ }
5889
+ function getSinglePropIndexValue(context, directiveIndex, offset, isClassBased) {
5890
+ var singlePropOffsetRegistryIndex = context[1 /* DirectiveRegistryPosition */][(directiveIndex * 4 /* Size */) +
5891
+ 1 /* SinglePropValuesIndexOffset */];
5892
+ var offsets = context[4 /* SinglePropOffsetPositions */];
5893
+ var indexForOffset = singlePropOffsetRegistryIndex +
5894
+ 2 /* ValueStartPosition */ +
5895
+ (isClassBased ?
5896
+ offsets[singlePropOffsetRegistryIndex + 0 /* StylesCountPosition */] :
5897
+ 0) +
5898
+ offset;
5899
+ return offsets[indexForOffset];
5900
+ }
5901
+ function getStyleSanitizer(context, directiveIndex) {
5902
+ var dirs = context[1 /* DirectiveRegistryPosition */];
5903
+ var value = dirs[directiveIndex * 4 /* Size */ +
5904
+ 3 /* StyleSanitizerOffset */] ||
5905
+ dirs[3 /* StyleSanitizerOffset */] || null;
5906
+ return value;
5907
+ }
5908
+ function isDirectiveDirty(context, directiveIndex) {
5909
+ var dirs = context[1 /* DirectiveRegistryPosition */];
5910
+ return dirs[directiveIndex * 4 /* Size */ +
5911
+ 2 /* DirtyFlagOffset */];
5912
+ }
5913
+ function setDirectiveDirty(context, directiveIndex, dirtyYes) {
5914
+ var dirs = context[1 /* DirectiveRegistryPosition */];
5915
+ dirs[directiveIndex * 4 /* Size */ +
5916
+ 2 /* DirtyFlagOffset */] = dirtyYes;
5917
+ }
5918
+ function allowValueChange(currentValue, newValue, currentDirectiveOwner, newDirectiveOwner) {
5919
+ // the code below relies the importance of directive's being tied to their
5920
+ // index value. The index values for each directive are derived from being
5921
+ // registered into the styling context directive registry. The most important
5922
+ // directive is the parent component directive (the template) and each directive
5923
+ // that is added after is considered less important than the previous entry. This
5924
+ // prioritization of directives enables the styling algorithm to decide if a style
5925
+ // or class should be allowed to be updated/replaced incase an earlier directive
5926
+ // already wrote to the exact same style-property or className value. In other words
5927
+ // ... this decides what to do if and when there is a collision.
5928
+ if (currentValue) {
5929
+ if (newValue) {
5930
+ // if a directive index is lower than it always has priority over the
5931
+ // previous directive's value...
5932
+ return newDirectiveOwner <= currentDirectiveOwner;
5933
+ }
5934
+ else {
5935
+ // only write a null value incase it's the same owner writing it.
5936
+ // this avoids having a higher-priority directive write to null
5937
+ // only to have a lesser-priority directive change right to a
5938
+ // non-null value immediately afterwards.
5939
+ return currentDirectiveOwner === newDirectiveOwner;
5940
+ }
5941
+ }
5942
+ return true;
5943
+ }
5944
+ /**
5945
+ * This function is only designed to be called for `[class]` bindings when
5946
+ * `[ngClass]` (or something that uses `class` as an input) is present. Once
5947
+ * directive host bindings fully work for `[class]` and `[style]` inputs
5948
+ * then this can be deleted.
5949
+ */
5950
+ function getInitialClassNameValue(context) {
5951
+ var className = context[6 /* CachedClassValueOrInitialClassString */];
5952
+ if (className == null) {
5953
+ className = '';
5954
+ var initialClassValues = context[3 /* InitialClassValuesPosition */];
5955
+ for (var i = 1 /* KeyValueStartPosition */; i < initialClassValues.length; i += 2 /* Size */) {
5956
+ var isPresent = initialClassValues[i + 1];
5957
+ if (isPresent) {
5958
+ className += (className.length ? ' ' : '') + initialClassValues[i];
5959
+ }
5960
+ }
5961
+ context[6 /* CachedClassValueOrInitialClassString */] = className;
5962
+ }
5963
+ return className;
5964
+ }
5515
5965
 
5516
5966
  /**
5517
5967
  * @license
@@ -5531,29 +5981,23 @@
5531
5981
  * bindings, refreshes child components.
5532
5982
  * Note: view hooks are triggered later when leaving the view.
5533
5983
  */
5534
- function refreshDescendantViews(lView, rf) {
5984
+ function refreshDescendantViews(lView) {
5535
5985
  var tView = lView[TVIEW];
5536
5986
  // This needs to be set before children are processed to support recursive components
5537
5987
  tView.firstTemplatePass = false;
5538
5988
  setFirstTemplatePass(false);
5539
- // Dynamically created views must run first only in creation mode. If this is a
5540
- // creation-only pass, we should not call lifecycle hooks or evaluate bindings.
5541
- // This will be done in the update-only pass.
5542
- if (rf !== 1 /* Create */) {
5543
- var creationMode = getCreationMode();
5989
+ // If this is a creation pass, we should not call lifecycle hooks or evaluate bindings.
5990
+ // This will be done in the update pass.
5991
+ if (!isCreationMode(lView)) {
5544
5992
  var checkNoChangesMode = getCheckNoChangesMode();
5545
- if (!checkNoChangesMode) {
5546
- executeInitHooks(lView, tView, creationMode);
5547
- }
5993
+ executeInitHooks(lView, tView, checkNoChangesMode);
5548
5994
  refreshDynamicEmbeddedViews(lView);
5549
5995
  // Content query results must be refreshed before content hooks are called.
5550
5996
  refreshContentQueries(tView);
5551
- if (!checkNoChangesMode) {
5552
- executeHooks(lView, tView.contentHooks, tView.contentCheckHooks, creationMode);
5553
- }
5997
+ executeHooks(lView, tView.contentHooks, tView.contentCheckHooks, checkNoChangesMode);
5554
5998
  setHostBindings(tView, lView);
5555
5999
  }
5556
- refreshChildComponents(tView.components, rf);
6000
+ refreshChildComponents(tView.components);
5557
6001
  }
5558
6002
  /** Sets the host bindings for the current view. */
5559
6003
  function setHostBindings(tView, viewData) {
@@ -5604,16 +6048,17 @@
5604
6048
  }
5605
6049
  }
5606
6050
  /** Refreshes child components in the current view. */
5607
- function refreshChildComponents(components, rf) {
6051
+ function refreshChildComponents(components) {
5608
6052
  if (components != null) {
5609
6053
  for (var i = 0; i < components.length; i++) {
5610
- componentRefresh(components[i], rf);
6054
+ componentRefresh(components[i]);
5611
6055
  }
5612
6056
  }
5613
6057
  }
5614
6058
  function createLView(parentLView, tView, context, flags, rendererFactory, renderer, sanitizer, injector) {
5615
6059
  var lView = tView.blueprint.slice();
5616
- lView[FLAGS] = flags | 1 /* CreationMode */ | 8 /* Attached */ | 16 /* RunInit */;
6060
+ lView[FLAGS] = flags | 1 /* CreationMode */ | 16 /* Attached */ | 32 /* RunInit */ |
6061
+ 2 /* FirstLViewPass */;
5617
6062
  lView[PARENT] = lView[DECLARATION_VIEW] = parentLView;
5618
6063
  lView[CONTEXT] = context;
5619
6064
  lView[RENDERER_FACTORY] = (rendererFactory || parentLView && parentLView[RENDERER_FACTORY]);
@@ -5690,7 +6135,7 @@
5690
6135
  var _previousOrParentTNode = getPreviousOrParentTNode();
5691
6136
  setIsParent(true);
5692
6137
  setPreviousOrParentTNode(null);
5693
- var lView = createLView(declarationView, tView, context, 2 /* CheckAlways */);
6138
+ var lView = createLView(declarationView, tView, context, 4 /* CheckAlways */);
5694
6139
  lView[DECLARATION_VIEW] = declarationView;
5695
6140
  if (queries) {
5696
6141
  lView[QUERIES] = queries.createView();
@@ -5713,13 +6158,13 @@
5713
6158
  * can't store TViews in the template function itself (as we do for comps). Instead, we store the
5714
6159
  * TView for dynamically created views on their host TNode, which only has one instance.
5715
6160
  */
5716
- function renderEmbeddedTemplate(viewToRender, tView, context, rf) {
6161
+ function renderEmbeddedTemplate(viewToRender, tView, context) {
5717
6162
  var _isParent = getIsParent();
5718
6163
  var _previousOrParentTNode = getPreviousOrParentTNode();
5719
6164
  setIsParent(true);
5720
6165
  setPreviousOrParentTNode(null);
5721
6166
  var oldView;
5722
- if (viewToRender[FLAGS] & 64 /* IsRoot */) {
6167
+ if (viewToRender[FLAGS] & 128 /* IsRoot */) {
5723
6168
  // This is a root view inside the view tree
5724
6169
  tickRootContext(getRootContext(viewToRender));
5725
6170
  }
@@ -5729,24 +6174,17 @@
5729
6174
  setPreviousOrParentTNode(null);
5730
6175
  oldView = enterView(viewToRender, viewToRender[HOST_NODE]);
5731
6176
  namespaceHTML();
5732
- tView.template(rf, context);
5733
- if (rf & 2 /* Update */) {
5734
- refreshDescendantViews(viewToRender, null);
5735
- }
5736
- else {
5737
- // This must be set to false immediately after the first creation run because in an
5738
- // ngFor loop, all the views will be created together before update mode runs and turns
5739
- // off firstTemplatePass. If we don't set it here, instances will perform directive
5740
- // matching, etc again and again.
5741
- viewToRender[TVIEW].firstTemplatePass = false;
5742
- setFirstTemplatePass(false);
5743
- }
6177
+ tView.template(getRenderFlags(viewToRender), context);
6178
+ // This must be set to false immediately after the first creation run because in an
6179
+ // ngFor loop, all the views will be created together before update mode runs and turns
6180
+ // off firstTemplatePass. If we don't set it here, instances will perform directive
6181
+ // matching, etc again and again.
6182
+ viewToRender[TVIEW].firstTemplatePass = false;
6183
+ setFirstTemplatePass(false);
6184
+ refreshDescendantViews(viewToRender);
5744
6185
  }
5745
6186
  finally {
5746
- // renderEmbeddedTemplate() is called twice, once for creation only and then once for
5747
- // update. When for creation only, leaveView() must not trigger view hooks, nor clean flags.
5748
- var isCreationOnly = (rf & 1 /* Create */) === 1 /* Create */;
5749
- leaveView(oldView, isCreationOnly);
6187
+ leaveView(oldView);
5750
6188
  setIsParent(_isParent);
5751
6189
  setPreviousOrParentTNode(_previousOrParentTNode);
5752
6190
  }
@@ -5766,21 +6204,29 @@
5766
6204
  if (level === void 0) { level = 1; }
5767
6205
  return nextContextImpl(level);
5768
6206
  }
5769
- function renderComponentOrTemplate(hostView, componentOrContext, rf, templateFn) {
6207
+ function renderComponentOrTemplate(hostView, context, templateFn) {
5770
6208
  var rendererFactory = hostView[RENDERER_FACTORY];
5771
6209
  var oldView = enterView(hostView, hostView[HOST_NODE]);
6210
+ var normalExecutionPath = !getCheckNoChangesMode();
5772
6211
  try {
5773
- if (rendererFactory.begin) {
6212
+ if (normalExecutionPath && rendererFactory.begin) {
5774
6213
  rendererFactory.begin();
5775
6214
  }
5776
- if (templateFn) {
5777
- namespaceHTML();
5778
- templateFn(rf || getRenderFlags(hostView), componentOrContext);
6215
+ if (isCreationMode(hostView)) {
6216
+ // creation mode pass
6217
+ if (templateFn) {
6218
+ namespaceHTML();
6219
+ templateFn(1 /* Create */, context);
6220
+ }
6221
+ refreshDescendantViews(hostView);
6222
+ hostView[FLAGS] &= ~1 /* CreationMode */;
5779
6223
  }
5780
- refreshDescendantViews(hostView, rf);
6224
+ // update mode pass
6225
+ templateFn && templateFn(2 /* Update */, context);
6226
+ refreshDescendantViews(hostView);
5781
6227
  }
5782
6228
  finally {
5783
- if (rendererFactory.end) {
6229
+ if (normalExecutionPath && rendererFactory.end) {
5784
6230
  rendererFactory.end();
5785
6231
  }
5786
6232
  leaveView(oldView);
@@ -5788,16 +6234,11 @@
5788
6234
  }
5789
6235
  /**
5790
6236
  * This function returns the default configuration of rendering flags depending on when the
5791
- * template is in creation mode or update mode. By default, the update block is run with the
5792
- * creation block when the view is in creation mode. Otherwise, the update block is run
5793
- * alone.
5794
- *
5795
- * Dynamically created views do NOT use this configuration (update block and create block are
5796
- * always run separately).
6237
+ * template is in creation mode or update mode. Update block and create block are
6238
+ * always run separately.
5797
6239
  */
5798
6240
  function getRenderFlags(view) {
5799
- return view[FLAGS] & 1 /* CreationMode */ ? 1 /* Create */ | 2 /* Update */ :
5800
- 2 /* Update */;
6241
+ return isCreationMode(view) ? 1 /* Create */ : 2 /* Update */;
5801
6242
  }
5802
6243
  //////////////////////////
5803
6244
  //// Namespace
@@ -5820,7 +6261,8 @@
5820
6261
  *
5821
6262
  * @param index Index of the element in the data array
5822
6263
  * @param name Name of the DOM Node
5823
- * @param attrs Statically bound set of attributes to be written into the DOM element on creation.
6264
+ * @param attrs Statically bound set of attributes, classes, and styles to be written into the DOM
6265
+ * element on creation. Use [AttributeMarker] to denote the meaning of this array.
5824
6266
  * @param localRefs A set of local reference bindings on the element.
5825
6267
  */
5826
6268
  function element(index, name, attrs, localRefs) {
@@ -5878,7 +6320,8 @@
5878
6320
  *
5879
6321
  * @param index Index of the element in the LView array
5880
6322
  * @param name Name of the DOM Node
5881
- * @param attrs Statically bound set of attributes to be written into the DOM element on creation.
6323
+ * @param attrs Statically bound set of attributes, classes, and styles to be written into the DOM
6324
+ * element on creation. Use [AttributeMarker] to denote the meaning of this array.
5882
6325
  * @param localRefs A set of local reference bindings on the element.
5883
6326
  *
5884
6327
  * Attributes and localRefs are passed as an array of strings where elements with an even index
@@ -5894,6 +6337,14 @@
5894
6337
  ngDevMode && assertDataInRange(lView, index - 1);
5895
6338
  var tNode = createNodeAtIndex(index, 3 /* Element */, native, name, attrs || null);
5896
6339
  if (attrs) {
6340
+ // it's important to only prepare styling-related datastructures once for a given
6341
+ // tNode and not each time an element is created. Also, the styling code is designed
6342
+ // to be patched and constructed at various points, but only up until the first element
6343
+ // is created. Then the styling context is locked and can only be instantiated for each
6344
+ // successive element that is created.
6345
+ if (tView.firstTemplatePass && !tNode.stylingTemplate && hasStyling(attrs)) {
6346
+ tNode.stylingTemplate = initializeStaticContext(attrs);
6347
+ }
5897
6348
  setUpAttributes(native, attrs);
5898
6349
  }
5899
6350
  appendChild(native, tNode, lView);
@@ -5905,6 +6356,21 @@
5905
6356
  attachPatchData(native, lView);
5906
6357
  }
5907
6358
  increaseElementDepthCount();
6359
+ // if a directive contains a host binding for "class" then all class-based data will
6360
+ // flow through that (except for `[class.prop]` bindings). This also includes initial
6361
+ // static class values as well. (Note that this will be fixed once map-based `[style]`
6362
+ // and `[class]` bindings work for multiple directives.)
6363
+ if (tView.firstTemplatePass) {
6364
+ var inputData = initializeTNodeInputs(tNode);
6365
+ if (inputData && inputData.hasOwnProperty('class')) {
6366
+ tNode.flags |= 8 /* hasClassInput */;
6367
+ }
6368
+ }
6369
+ // There is no point in rendering styles when a class directive is present since
6370
+ // it will take that over for us (this will be removed once #FW-882 is in).
6371
+ if (tNode.stylingTemplate && (tNode.flags & 8 /* hasClassInput */) === 0) {
6372
+ renderInitialStylesAndClasses(native, tNode.stylingTemplate, lView[RENDERER]);
6373
+ }
5908
6374
  }
5909
6375
  /**
5910
6376
  * Creates a native element from a tag name, using a renderer.
@@ -6044,28 +6510,30 @@
6044
6510
  var isProc = isProceduralRenderer(renderer);
6045
6511
  var i = 0;
6046
6512
  while (i < attrs.length) {
6047
- var attrName = attrs[i];
6048
- if (attrName === 1 /* SelectOnly */)
6049
- break;
6050
- if (attrName === NG_PROJECT_AS_ATTR_NAME) {
6051
- i += 2;
6052
- }
6053
- else {
6054
- ngDevMode && ngDevMode.rendererSetAttribute++;
6513
+ var attrName = attrs[i++];
6514
+ if (typeof attrName == 'number') {
6055
6515
  if (attrName === 0 /* NamespaceURI */) {
6056
6516
  // Namespaced attributes
6057
- var namespaceURI = attrs[i + 1];
6058
- var attrName_1 = attrs[i + 2];
6059
- var attrVal = attrs[i + 3];
6517
+ var namespaceURI = attrs[i++];
6518
+ var attrName_1 = attrs[i++];
6519
+ var attrVal = attrs[i++];
6520
+ ngDevMode && ngDevMode.rendererSetAttribute++;
6060
6521
  isProc ?
6061
6522
  renderer
6062
6523
  .setAttribute(native, attrName_1, attrVal, namespaceURI) :
6063
6524
  native.setAttributeNS(namespaceURI, attrName_1, attrVal);
6064
- i += 4;
6065
6525
  }
6066
6526
  else {
6527
+ // All other `AttributeMarker`s are ignored here.
6528
+ break;
6529
+ }
6530
+ }
6531
+ else {
6532
+ /// attrName is string;
6533
+ var attrVal = attrs[i++];
6534
+ if (attrName !== NG_PROJECT_AS_ATTR_NAME) {
6067
6535
  // Standard attributes
6068
- var attrVal = attrs[i + 1];
6536
+ ngDevMode && ngDevMode.rendererSetAttribute++;
6069
6537
  if (isAnimationProp(attrName)) {
6070
6538
  if (isProc) {
6071
6539
  renderer.setProperty(native, attrName, attrVal);
@@ -6077,7 +6545,6 @@
6077
6545
  .setAttribute(native, attrName, attrVal) :
6078
6546
  native.setAttribute(attrName, attrVal);
6079
6547
  }
6080
- i += 2;
6081
6548
  }
6082
6549
  }
6083
6550
  }
@@ -6216,6 +6683,13 @@
6216
6683
  }
6217
6684
  queueLifecycleHooks(getLView()[TVIEW], previousOrParentTNode);
6218
6685
  decreaseElementDepthCount();
6686
+ // this is fired at the end of elementEnd because ALL of the stylingBindings code
6687
+ // (for directives and the template) have now executed which means the styling
6688
+ // context can be instantiated properly.
6689
+ if (hasClassInput(previousOrParentTNode)) {
6690
+ var stylingContext = getStylingContext(previousOrParentTNode.index, lView);
6691
+ setInputsForProperty(lView, previousOrParentTNode.inputs['class'], getInitialClassNameValue(stylingContext));
6692
+ }
6219
6693
  }
6220
6694
  /**
6221
6695
  * Updates the value of removes an attribute on an Element.
@@ -6260,6 +6734,37 @@
6260
6734
  * (this is necessary for host property bindings)
6261
6735
  */
6262
6736
  function elementProperty(index, propName, value, sanitizer, nativeOnly) {
6737
+ elementPropertyInternal(index, propName, value, sanitizer, nativeOnly);
6738
+ }
6739
+ /**
6740
+ * Updates a synthetic host binding (e.g. `[@foo]`) on a component.
6741
+ *
6742
+ * This instruction is for compatibility purposes and is designed to ensure that a
6743
+ * synthetic host binding (e.g. `@HostBinding('@foo')`) properly gets rendered in
6744
+ * the component's renderer. Normally all host bindings are evaluated with the parent
6745
+ * component's renderer, but, in the case of animation @triggers, they need to be
6746
+ * evaluated with the sub components renderer (because that's where the animation
6747
+ * triggers are defined).
6748
+ *
6749
+ * Do not use this instruction as a replacement for `elementProperty`. This instruction
6750
+ * only exists to ensure compatibility with the ViewEngine's host binding behavior.
6751
+ *
6752
+ * @param index The index of the element to update in the data array
6753
+ * @param propName Name of property. Because it is going to DOM, this is not subject to
6754
+ * renaming as part of minification.
6755
+ * @param value New value to write.
6756
+ * @param sanitizer An optional function used to sanitize the value.
6757
+ * @param nativeOnly Whether or not we should only set native properties and skip input check
6758
+ * (this is necessary for host property bindings)
6759
+ */
6760
+ function componentHostSyntheticProperty(index, propName, value, sanitizer, nativeOnly) {
6761
+ elementPropertyInternal(index, propName, value, sanitizer, nativeOnly, loadComponentRenderer);
6762
+ }
6763
+ function loadComponentRenderer(tNode, lView) {
6764
+ var componentLView = lView[tNode.index];
6765
+ return componentLView[RENDERER];
6766
+ }
6767
+ function elementPropertyInternal(index, propName, value, sanitizer, nativeOnly, loadRendererFn) {
6263
6768
  if (value === NO_CHANGE)
6264
6769
  return;
6265
6770
  var lView = getLView();
@@ -6279,7 +6784,7 @@
6279
6784
  }
6280
6785
  }
6281
6786
  else if (tNode.type === 3 /* Element */) {
6282
- var renderer = lView[RENDERER];
6787
+ var renderer = loadRendererFn ? loadRendererFn(tNode, lView) : lView[RENDERER];
6283
6788
  // It is assumed that the sanitizer is only added when the compiler determines that the property
6284
6789
  // is risky, so sanitization can be done without further checks.
6285
6790
  value = sanitizer != null ? sanitizer(value) : value;
@@ -6398,127 +6903,105 @@
6398
6903
  return propStore;
6399
6904
  }
6400
6905
  /**
6401
- * Add or remove a class in a `classList` on a DOM element.
6906
+ * Assign any inline style values to the element during creation mode.
6402
6907
  *
6403
- * This instruction is meant to handle the [class.foo]="exp" case
6908
+ * This instruction is meant to be called during creation mode to register all
6909
+ * dynamic style and class bindings on the element. Note for static values (no binding)
6910
+ * see `elementStart` and `elementHostAttrs`.
6911
+ *
6912
+ * @param classBindingNames An array containing bindable class names.
6913
+ * The `elementClassProp` refers to the class name by index in this array.
6914
+ * (i.e. `['foo', 'bar']` means `foo=0` and `bar=1`).
6915
+ * @param styleBindingNames An array containing bindable style properties.
6916
+ * The `elementStyleProp` refers to the class name by index in this array.
6917
+ * (i.e. `['width', 'height']` means `width=0` and `height=1`).
6918
+ * @param styleSanitizer An optional sanitizer function that will be used to sanitize any CSS
6919
+ * property values that are applied to the element (during rendering).
6920
+ * Note that the sanitizer instance itself is tied to the `directive` (if provided).
6921
+ * @param directive A directive instance the styling is associated with. If not provided
6922
+ * current view's controller instance is assumed.
6404
6923
  *
6405
- * @param index The index of the element to update in the data array
6406
- * @param classIndex Index of class to toggle. Because it is going to DOM, this is not subject to
6407
- * renaming as part of minification.
6408
- * @param value A value indicating if a given class should be added or removed.
6409
- * @param directive the ref to the directive that is attempting to change styling.
6924
+ * @publicApi
6410
6925
  */
6411
- function elementClassProp(index, classIndex, value, directive) {
6412
- if (directive != undefined) {
6413
- return hackImplementationOfElementClassProp(index, classIndex, value, directive); // proper supported in next PR
6926
+ function elementStyling(classBindingNames, styleBindingNames, styleSanitizer, directive) {
6927
+ var tNode = getPreviousOrParentTNode();
6928
+ if (!tNode.stylingTemplate) {
6929
+ tNode.stylingTemplate = createEmptyStylingContext();
6414
6930
  }
6415
- var val = (value instanceof BoundPlayerFactory) ? value : (!!value);
6416
- updateClassProp(getStylingContext(index + HEADER_OFFSET, getLView()), classIndex, val);
6931
+ updateContextWithBindings(tNode.stylingTemplate, directive || null, classBindingNames, styleBindingNames, styleSanitizer, hasClassInput(tNode));
6417
6932
  }
6418
6933
  /**
6419
- * Assign any inline style values to the element during creation mode.
6934
+ * Assign static styling values to a host element.
6420
6935
  *
6421
- * This instruction is meant to be called during creation mode to apply all styling
6422
- * (e.g. `style="..."`) values to the element. This is also where the provided index
6423
- * value is allocated for the styling details for its corresponding element (the element
6424
- * index is the previous index value from this one).
6425
- *
6426
- * (Note this function calls `elementStylingApply` immediately when called.)
6427
- *
6428
- *
6429
- * @param index Index value which will be allocated to store styling data for the element.
6430
- * (Note that this is not the element index, but rather an index value allocated
6431
- * specifically for element styling--the index must be the next index after the element
6432
- * index.)
6433
- * @param classDeclarations A key/value array of CSS classes that will be registered on the element.
6434
- * Each individual style will be used on the element as long as it is not overridden
6435
- * by any classes placed on the element by multiple (`[class]`) or singular (`[class.named]`)
6436
- * bindings. If a class binding changes its value to a falsy value then the matching initial
6437
- * class value that are passed in here will be applied to the element (if matched).
6438
- * @param styleDeclarations A key/value array of CSS styles that will be registered on the element.
6439
- * Each individual style will be used on the element as long as it is not overridden
6440
- * by any styles placed on the element by multiple (`[style]`) or singular (`[style.prop]`)
6441
- * bindings. If a style binding changes its value to null then the initial styling
6442
- * values that are passed in here will be applied to the element (if matched).
6443
- * @param styleSanitizer An optional sanitizer function that will be used (if provided)
6444
- * to sanitize the any CSS property values that are applied to the element (during rendering).
6445
- * @param directive the ref to the directive that is attempting to change styling.
6446
- */
6447
- function elementStyling(classDeclarations, styleDeclarations, styleSanitizer, directive) {
6448
- if (directive != undefined) {
6449
- getCreationMode() &&
6450
- hackImplementationOfElementStyling(classDeclarations || null, styleDeclarations || null, styleSanitizer || null, directive); // supported in next PR
6451
- return;
6452
- }
6936
+ * NOTE: This instruction is meant to used from `hostBindings` function only.
6937
+ *
6938
+ * @param directive A directive instance the styling is associated with.
6939
+ * @param attrs An array containing class and styling information. The values must be marked with
6940
+ * `AttributeMarker`.
6941
+ *
6942
+ * ```
6943
+ * var attrs = [AttributeMarker.Classes, 'foo', 'bar',
6944
+ * AttributeMarker.Styles, 'width', '100px', 'height, '200px']
6945
+ * elementHostAttrs(directive, attrs);
6946
+ * ```
6947
+ *
6948
+ * @publicApi
6949
+ */
6950
+ function elementHostAttrs(directive, attrs) {
6453
6951
  var tNode = getPreviousOrParentTNode();
6454
- var inputData = initializeTNodeInputs(tNode);
6455
6952
  if (!tNode.stylingTemplate) {
6456
- var hasClassInput = inputData && inputData.hasOwnProperty('class') ? true : false;
6457
- if (hasClassInput) {
6458
- tNode.flags |= 8 /* hasClassInput */;
6459
- }
6460
- // initialize the styling template.
6461
- tNode.stylingTemplate = createStylingContextTemplate(classDeclarations, styleDeclarations, styleSanitizer, hasClassInput);
6462
- }
6463
- if (styleDeclarations && styleDeclarations.length ||
6464
- classDeclarations && classDeclarations.length) {
6465
- var index = tNode.index;
6466
- if (delegateToClassInput(tNode)) {
6467
- var lView = getLView();
6468
- var stylingContext = getStylingContext(index, lView);
6469
- var initialClasses = stylingContext[6 /* PreviousOrCachedMultiClassValue */];
6470
- setInputsForProperty(lView, tNode.inputs['class'], initialClasses);
6471
- }
6472
- elementStylingApply(index - HEADER_OFFSET);
6953
+ tNode.stylingTemplate = initializeStaticContext(attrs);
6473
6954
  }
6955
+ patchContextWithStaticAttrs(tNode.stylingTemplate, attrs, directive);
6474
6956
  }
6475
6957
  /**
6476
- * Apply all styling values to the element which have been queued by any styling instructions.
6958
+ * Apply styling binding to the element.
6477
6959
  *
6478
- * This instruction is meant to be run once one or more `elementStyle` and/or `elementStyleProp`
6479
- * have been issued against the element. This function will also determine if any styles have
6480
- * changed and will then skip the operation if there is nothing new to render.
6960
+ * This instruction is meant to be run after `elementStyle` and/or `elementStyleProp`.
6961
+ * if any styling bindings have changed then the changes are flushed to the element.
6481
6962
  *
6482
- * Once called then all queued styles will be flushed.
6483
6963
  *
6484
- * @param index Index of the element's styling storage that will be rendered.
6485
- * (Note that this is not the element index, but rather an index value allocated
6486
- * specifically for element styling--the index must be the next index after the element
6487
- * index.)
6488
- * @param directive the ref to the directive that is attempting to change styling.
6964
+ * @param index Index of the element's with which styling is associated.
6965
+ * @param directive Directive instance that is attempting to change styling. (Defaults to the
6966
+ * component of the current view).
6967
+ components
6968
+ *
6969
+ * @publicApi
6489
6970
  */
6490
6971
  function elementStylingApply(index, directive) {
6491
- if (directive != undefined) {
6492
- return hackImplementationOfElementStylingApply(index, directive); // supported in next PR
6493
- }
6494
6972
  var lView = getLView();
6495
- var isFirstRender = (lView[FLAGS] & 1 /* CreationMode */) !== 0;
6496
- var totalPlayersQueued = renderStyleAndClassBindings(getStylingContext(index + HEADER_OFFSET, lView), lView[RENDERER], lView, isFirstRender);
6973
+ var isFirstRender = (lView[FLAGS] & 2 /* FirstLViewPass */) !== 0;
6974
+ var totalPlayersQueued = renderStyling(getStylingContext(index + HEADER_OFFSET, lView), lView[RENDERER], lView, isFirstRender, null, null, directive);
6497
6975
  if (totalPlayersQueued > 0) {
6498
6976
  var rootContext = getRootContext(lView);
6499
6977
  scheduleTick(rootContext, 2 /* FlushPlayers */);
6500
6978
  }
6501
6979
  }
6502
6980
  /**
6503
- * Queue a given style to be rendered on an Element.
6981
+ * Update a style bindings value on an element.
6504
6982
  *
6505
6983
  * If the style value is `null` then it will be removed from the element
6506
6984
  * (or assigned a different value depending if there are any styles placed
6507
6985
  * on the element with `elementStyle` or any styles that are present
6508
6986
  * from when the element was created (with `elementStyling`).
6509
6987
  *
6510
- * (Note that the styling instruction will not be applied until `elementStylingApply` is called.)
6988
+ * (Note that the styling element is updated as part of `elementStylingApply`.)
6511
6989
  *
6512
- * @param index Index of the element's styling storage to change in the data array.
6513
- * (Note that this is not the element index, but rather an index value allocated
6514
- * specifically for element styling--the index must be the next index after the element
6515
- * index.)
6516
- * @param styleIndex Index of the style property on this element. (Monotonically increasing.)
6517
- * @param value New value to write (null to remove).
6990
+ * @param index Index of the element's with which styling is associated.
6991
+ * @param styleIndex Index of style to update. This index value refers to the
6992
+ * index of the style in the style bindings array that was passed into
6993
+ * `elementStlyingBindings`.
6994
+ * @param value New value to write (null to remove). Note that if a directive also
6995
+ * attempts to write to the same binding value then it will only be able to
6996
+ * do so if the template binding value is `null` (or doesn't exist at all).
6518
6997
  * @param suffix Optional suffix. Used with scalar values to add unit such as `px`.
6519
6998
  * Note that when a suffix is provided then the underlying sanitizer will
6520
6999
  * be ignored.
6521
- * @param directive the ref to the directive that is attempting to change styling.
7000
+ * @param directive Directive instance that is attempting to change styling. (Defaults to the
7001
+ * component of the current view).
7002
+ components
7003
+ *
7004
+ * @publicApi
6522
7005
  */
6523
7006
  function elementStyleProp(index, styleIndex, value, suffix, directive) {
6524
7007
  var valueToAdd = null;
@@ -6536,34 +7019,52 @@
6536
7019
  valueToAdd = value;
6537
7020
  }
6538
7021
  }
6539
- if (directive != undefined) {
6540
- hackImplementationOfElementStyleProp(index, styleIndex, valueToAdd, suffix, directive);
6541
- }
6542
- else {
6543
- updateStyleProp(getStylingContext(index + HEADER_OFFSET, getLView()), styleIndex, valueToAdd);
6544
- }
7022
+ updateStyleProp(getStylingContext(index + HEADER_OFFSET, getLView()), styleIndex, valueToAdd, directive);
7023
+ }
7024
+ /**
7025
+ * Add or remove a class via a class binding on a DOM element.
7026
+ *
7027
+ * This instruction is meant to handle the [class.foo]="exp" case and, therefore,
7028
+ * the class itself must already be applied using `elementStyling` within
7029
+ * the creation block.
7030
+ *
7031
+ * @param index Index of the element's with which styling is associated.
7032
+ * @param classIndex Index of class to toggle. This index value refers to the
7033
+ * index of the class in the class bindings array that was passed into
7034
+ * `elementStlyingBindings` (which is meant to be called before this
7035
+ * function is).
7036
+ * @param value A true/false value which will turn the class on or off.
7037
+ * @param directive Directive instance that is attempting to change styling. (Defaults to the
7038
+ * component of the current view).
7039
+ components
7040
+ *
7041
+ * @publicApi
7042
+ */
7043
+ function elementClassProp(index, classIndex, value, directive) {
7044
+ var onOrOffClassValue = (value instanceof BoundPlayerFactory) ? value : (!!value);
7045
+ updateClassProp(getStylingContext(index + HEADER_OFFSET, getLView()), classIndex, onOrOffClassValue, directive);
6545
7046
  }
6546
7047
  /**
6547
- * Queue a key/value map of styles to be rendered on an Element.
7048
+ * Update style and/or class bindings using object literal.
6548
7049
  *
6549
- * This instruction is meant to handle the `[style]="exp"` usage. When styles are applied to
6550
- * the Element they will then be placed with respect to any styles set with `elementStyleProp`.
6551
- * If any styles are set to `null` then they will be removed from the element (unless the same
6552
- * style properties have been assigned to the element during creation using `elementStyling`).
7050
+ * This instruction is meant apply styling via the `[style]="exp"` and `[class]="exp"` template
7051
+ * bindings. When styles are applied to the Element they will then be placed with respect to
7052
+ * any styles set with `elementStyleProp`. If any styles are set to `null` then they will be
7053
+ * removed from the element.
6553
7054
  *
6554
7055
  * (Note that the styling instruction will not be applied until `elementStylingApply` is called.)
6555
7056
  *
6556
- * @param index Index of the element's styling storage to change in the data array.
6557
- * (Note that this is not the element index, but rather an index value allocated
6558
- * specifically for element styling--the index must be the next index after the element
6559
- * index.)
7057
+ * @param index Index of the element's with which styling is associated.
6560
7058
  * @param classes A key/value style map of CSS classes that will be added to the given element.
6561
7059
  * Any missing classes (that have already been applied to the element beforehand) will be
6562
7060
  * removed (unset) from the element's list of CSS classes.
6563
7061
  * @param styles A key/value style map of the styles that will be applied to the given element.
6564
7062
  * Any missing styles (that have already been applied to the element beforehand) will be
6565
7063
  * removed (unset) from the element's styling.
6566
- * @param directive the ref to the directive that is attempting to change styling.
7064
+ * @param directive Directive instance that is attempting to change styling. (Defaults to the
7065
+ * component of the current view).
7066
+ *
7067
+ * @publicApi
6567
7068
  */
6568
7069
  function elementStylingMap(index, classes, styles, directive) {
6569
7070
  if (directive != undefined)
@@ -6571,77 +7072,16 @@
6571
7072
  var lView = getLView();
6572
7073
  var tNode = getTNode(index, lView);
6573
7074
  var stylingContext = getStylingContext(index + HEADER_OFFSET, lView);
6574
- if (delegateToClassInput(tNode) && classes !== NO_CHANGE) {
6575
- var initialClasses = stylingContext[6 /* PreviousOrCachedMultiClassValue */];
7075
+ if (hasClassInput(tNode) && classes !== NO_CHANGE) {
7076
+ var initialClasses = getInitialClassNameValue(stylingContext);
6576
7077
  var classInputVal = (initialClasses.length ? (initialClasses + ' ') : '') + classes;
6577
7078
  setInputsForProperty(lView, tNode.inputs['class'], classInputVal);
6578
7079
  }
6579
- updateStylingMap(stylingContext, classes, styles);
6580
- }
6581
- function hackImplementationOfElementStyling(classDeclarations, styleDeclarations, styleSanitizer, directive) {
6582
- var node = getNativeByTNode(getPreviousOrParentTNode(), getLView());
6583
- ngDevMode && assertDefined(node, 'expecting parent DOM node');
6584
- var hostStylingHackMap = (node.hostStylingHack || (node.hostStylingHack = new Map()));
6585
- var squashedClassDeclarations = hackSquashDeclaration(classDeclarations);
6586
- hostStylingHackMap.set(directive, {
6587
- classDeclarations: squashedClassDeclarations,
6588
- styleDeclarations: hackSquashDeclaration(styleDeclarations), styleSanitizer: styleSanitizer
6589
- });
6590
- hackSetStaticClasses(node, squashedClassDeclarations);
6591
- }
6592
- function hackSetStaticClasses(node, classDeclarations) {
6593
- // Static classes need to be set here because static classes don't generate
6594
- // elementClassProp instructions.
6595
- var lView = getLView();
6596
- var staticClassStartIndex = classDeclarations.indexOf(1 /* VALUES_MODE */) + 1;
6597
- var renderer = lView[RENDERER];
6598
- for (var i = staticClassStartIndex; i < classDeclarations.length; i += 2) {
6599
- var className = classDeclarations[i];
6600
- var value = classDeclarations[i + 1];
6601
- // if value is true, then this is a static class and we should set it now.
6602
- // class bindings are set separately in elementClassProp.
6603
- if (value === true) {
6604
- if (isProceduralRenderer(renderer)) {
6605
- renderer.addClass(node, className);
6606
- }
6607
- else {
6608
- var classList = node.classList;
6609
- classList.add(className);
6610
- }
6611
- }
6612
- }
6613
- }
6614
- function hackSquashDeclaration(declarations) {
6615
- // assume the array is correct. This should be fine for View Engine compatibility.
6616
- return declarations || [];
6617
- }
6618
- function hackImplementationOfElementClassProp(index, classIndex, value, directive) {
6619
- var lView = getLView();
6620
- var node = getNativeByIndex(index, lView);
6621
- ngDevMode && assertDefined(node, 'could not locate node');
6622
- var hostStylingHack = node.hostStylingHack.get(directive);
6623
- var className = hostStylingHack.classDeclarations[classIndex];
6624
- var renderer = lView[RENDERER];
6625
- if (isProceduralRenderer(renderer)) {
6626
- value ? renderer.addClass(node, className) : renderer.removeClass(node, className);
6627
- }
6628
7080
  else {
6629
- var classList = node.classList;
6630
- value ? classList.add(className) : classList.remove(className);
7081
+ updateStylingMap(stylingContext, classes, styles);
6631
7082
  }
6632
7083
  }
6633
- function hackImplementationOfElementStylingApply(index, directive) {
6634
- // Do nothing because the hack implementation is eager.
6635
- }
6636
- function hackImplementationOfElementStyleProp(index, styleIndex, value, suffix, directive) {
6637
- var lView = getLView();
6638
- var node = getNativeByIndex(index, lView);
6639
- ngDevMode && assertDefined(node, 'could not locate node');
6640
- var hostStylingHack = node.hostStylingHack.get(directive);
6641
- var styleName = hostStylingHack.styleDeclarations[styleIndex];
6642
- var renderer = lView[RENDERER];
6643
- setStyle(node, styleName, value, renderer, null);
6644
- }
7084
+ /* START OF HACK BLOCK */
6645
7085
  function hackImplementationOfElementStylingMap(index, classes, styles, directive) {
6646
7086
  throw new Error('unimplemented. Should not be needed by ViewEngine compatibility');
6647
7087
  }
@@ -6953,7 +7393,7 @@
6953
7393
  // Only component views should be added to the view tree directly. Embedded views are
6954
7394
  // accessed through their containers because they may be removed / re-added later.
6955
7395
  var rendererFactory = lView[RENDERER_FACTORY];
6956
- var componentView = addToViewTree(lView, previousOrParentTNode.index, createLView(lView, tView, null, def.onPush ? 4 /* Dirty */ : 2 /* CheckAlways */, rendererFactory, lView[RENDERER_FACTORY].createRenderer(native, def)));
7396
+ var componentView = addToViewTree(lView, previousOrParentTNode.index, createLView(lView, tView, null, def.onPush ? 8 /* Dirty */ : 4 /* CheckAlways */, rendererFactory, lView[RENDERER_FACTORY].createRenderer(native, def)));
6957
7397
  componentView[HOST_NODE] = previousOrParentTNode;
6958
7398
  // Component view will always be created before any injected LContainers,
6959
7399
  // so this is a regular element, wrap it with the component view
@@ -7005,7 +7445,7 @@
7005
7445
  var i = 0;
7006
7446
  while (i < attrs.length) {
7007
7447
  var attrName = attrs[i];
7008
- if (attrName === 1 /* SelectOnly */)
7448
+ if (attrName === 3 /* SelectOnly */)
7009
7449
  break;
7010
7450
  if (attrName === 0 /* NamespaceURI */) {
7011
7451
  // We do not allow inputs on namespaced attributes.
@@ -7131,11 +7571,9 @@
7131
7571
  ngDevMode && assertNodeType(previousOrParentTNode, 0 /* Container */);
7132
7572
  setIsParent(true);
7133
7573
  lView[index + HEADER_OFFSET][ACTIVE_INDEX] = 0;
7134
- if (!getCheckNoChangesMode()) {
7135
- // We need to execute init hooks here so ngOnInit hooks are called in top level views
7136
- // before they are called in embedded views (for backwards compatibility).
7137
- executeInitHooks(lView, tView, getCreationMode());
7138
- }
7574
+ // We need to execute init hooks here so ngOnInit hooks are called in top level views
7575
+ // before they are called in embedded views (for backwards compatibility).
7576
+ executeInitHooks(lView, tView, getCheckNoChangesMode());
7139
7577
  }
7140
7578
  /**
7141
7579
  * Marks the end of the LContainer.
@@ -7176,7 +7614,7 @@
7176
7614
  var dynamicViewData = container_1[VIEWS][i];
7177
7615
  // The directives and pipes are not needed here as an existing view is only being refreshed.
7178
7616
  ngDevMode && assertDefined(dynamicViewData[TVIEW], 'TView must be allocated');
7179
- renderEmbeddedTemplate(dynamicViewData, dynamicViewData[TVIEW], dynamicViewData[CONTEXT], 2 /* Update */);
7617
+ renderEmbeddedTemplate(dynamicViewData, dynamicViewData[TVIEW], dynamicViewData[CONTEXT]);
7180
7618
  }
7181
7619
  }
7182
7620
  }
@@ -7233,7 +7671,7 @@
7233
7671
  }
7234
7672
  else {
7235
7673
  // When we create a new LView, we always reset the state of the instructions.
7236
- viewToRender = createLView(lView, getOrCreateEmbeddedTView(viewBlockId, consts, vars, containerTNode), null, 2 /* CheckAlways */);
7674
+ viewToRender = createLView(lView, getOrCreateEmbeddedTView(viewBlockId, consts, vars, containerTNode), null, 4 /* CheckAlways */);
7237
7675
  if (lContainer[QUERIES]) {
7238
7676
  viewToRender[QUERIES] = lContainer[QUERIES].createView();
7239
7677
  }
@@ -7241,13 +7679,14 @@
7241
7679
  enterView(viewToRender, viewToRender[TVIEW].node);
7242
7680
  }
7243
7681
  if (lContainer) {
7244
- if (getCreationMode()) {
7682
+ if (isCreationMode(viewToRender)) {
7245
7683
  // it is a new view, insert it into collection of views for a given container
7246
7684
  insertView(viewToRender, lContainer, lView, lContainer[ACTIVE_INDEX], -1);
7247
7685
  }
7248
7686
  lContainer[ACTIVE_INDEX]++;
7249
7687
  }
7250
- return getRenderFlags(viewToRender);
7688
+ return isCreationMode(viewToRender) ? 1 /* Create */ | 2 /* Update */ :
7689
+ 2 /* Update */;
7251
7690
  }
7252
7691
  /**
7253
7692
  * Initialize the TView (e.g. static data) for the active embedded view.
@@ -7277,7 +7716,11 @@
7277
7716
  function embeddedViewEnd() {
7278
7717
  var lView = getLView();
7279
7718
  var viewHost = lView[HOST_NODE];
7280
- refreshDescendantViews(lView, null);
7719
+ if (isCreationMode(lView)) {
7720
+ refreshDescendantViews(lView); // creation mode pass
7721
+ lView[FLAGS] &= ~1 /* CreationMode */;
7722
+ }
7723
+ refreshDescendantViews(lView); // update mode pass
7281
7724
  leaveView(lView[PARENT]);
7282
7725
  setPreviousOrParentTNode(viewHost);
7283
7726
  setIsParent(false);
@@ -7287,17 +7730,16 @@
7287
7730
  * Refreshes components by entering the component view and processing its bindings, queries, etc.
7288
7731
  *
7289
7732
  * @param adjustedElementIndex Element index in LView[] (adjusted for HEADER_OFFSET)
7290
- * @param rf The render flags that should be used to process this template
7291
7733
  */
7292
- function componentRefresh(adjustedElementIndex, rf) {
7734
+ function componentRefresh(adjustedElementIndex) {
7293
7735
  var lView = getLView();
7294
7736
  ngDevMode && assertDataInRange(lView, adjustedElementIndex);
7295
7737
  var hostView = getComponentViewByIndex(adjustedElementIndex, lView);
7296
7738
  ngDevMode && assertNodeType(lView[TVIEW].data[adjustedElementIndex], 3 /* Element */);
7297
7739
  // Only attached CheckAlways components or attached, dirty OnPush components should be checked
7298
- if (viewAttached(hostView) && hostView[FLAGS] & (2 /* CheckAlways */ | 4 /* Dirty */)) {
7740
+ if (viewAttached(hostView) && hostView[FLAGS] & (4 /* CheckAlways */ | 8 /* Dirty */)) {
7299
7741
  syncViewWithBlueprint(hostView);
7300
- detectChangesInternal(hostView, hostView[CONTEXT], rf);
7742
+ checkView(hostView, hostView[CONTEXT]);
7301
7743
  }
7302
7744
  }
7303
7745
  /**
@@ -7334,7 +7776,7 @@
7334
7776
  }
7335
7777
  /** Returns a boolean for whether the view is attached */
7336
7778
  function viewAttached(view) {
7337
- return (view[FLAGS] & 8 /* Attached */) === 8 /* Attached */;
7779
+ return (view[FLAGS] & 16 /* Attached */) === 16 /* Attached */;
7338
7780
  }
7339
7781
  /**
7340
7782
  * Instruction to distribute projectable nodes among <ng-content> occurrences in a given template.
@@ -7470,8 +7912,8 @@
7470
7912
  /** If node is an OnPush component, marks its LView dirty. */
7471
7913
  function markDirtyIfOnPush(lView, viewIndex) {
7472
7914
  var childComponentLView = getComponentViewByIndex(viewIndex, lView);
7473
- if (!(childComponentLView[FLAGS] & 2 /* CheckAlways */)) {
7474
- childComponentLView[FLAGS] |= 4 /* Dirty */;
7915
+ if (!(childComponentLView[FLAGS] & 4 /* CheckAlways */)) {
7916
+ childComponentLView[FLAGS] |= 8 /* Dirty */;
7475
7917
  }
7476
7918
  }
7477
7919
  /** Wraps an event listener with preventDefault behavior. */
@@ -7486,11 +7928,11 @@
7486
7928
  }
7487
7929
  /** Marks current view and all ancestors dirty */
7488
7930
  function markViewDirty(lView) {
7489
- while (lView && !(lView[FLAGS] & 64 /* IsRoot */)) {
7490
- lView[FLAGS] |= 4 /* Dirty */;
7931
+ while (lView && !(lView[FLAGS] & 128 /* IsRoot */)) {
7932
+ lView[FLAGS] |= 8 /* Dirty */;
7491
7933
  lView = lView[PARENT];
7492
7934
  }
7493
- lView[FLAGS] |= 4 /* Dirty */;
7935
+ lView[FLAGS] |= 8 /* Dirty */;
7494
7936
  ngDevMode && assertDefined(lView[CONTEXT], 'rootContext should be defined');
7495
7937
  var rootContext = lView[CONTEXT];
7496
7938
  scheduleTick(rootContext, 1 /* DetectChanges */);
@@ -7532,7 +7974,7 @@
7532
7974
  function tickRootContext(rootContext) {
7533
7975
  for (var i = 0; i < rootContext.components.length; i++) {
7534
7976
  var rootComponent = rootContext.components[i];
7535
- renderComponentOrTemplate(readPatchedLView(rootComponent), rootComponent, 2 /* Update */);
7977
+ renderComponentOrTemplate(readPatchedLView(rootComponent), rootComponent);
7536
7978
  }
7537
7979
  }
7538
7980
  /**
@@ -7549,7 +7991,19 @@
7549
7991
  * @param component The component which the change detection should be performed on.
7550
7992
  */
7551
7993
  function detectChanges(component) {
7552
- detectChangesInternal(getComponentViewByInstance(component), component, null);
7994
+ var view = getComponentViewByInstance(component);
7995
+ detectChangesInternal(view, component);
7996
+ }
7997
+ function detectChangesInternal(view, context) {
7998
+ var rendererFactory = view[RENDERER_FACTORY];
7999
+ if (rendererFactory.begin)
8000
+ rendererFactory.begin();
8001
+ if (isCreationMode(view)) {
8002
+ checkView(view, context); // creation mode pass
8003
+ }
8004
+ checkView(view, context); // update mode pass
8005
+ if (rendererFactory.end)
8006
+ rendererFactory.end();
7553
8007
  }
7554
8008
  /**
7555
8009
  * Synchronously perform change detection on a root view and its components.
@@ -7593,30 +8047,29 @@
7593
8047
  }
7594
8048
  }
7595
8049
  /** Checks the view of the component provided. Does not gate on dirty checks or execute doCheck. */
7596
- function detectChangesInternal(hostView, component, rf) {
8050
+ function checkView(hostView, component) {
7597
8051
  var hostTView = hostView[TVIEW];
7598
8052
  var oldView = enterView(hostView, hostView[HOST_NODE]);
7599
8053
  var templateFn = hostTView.template;
7600
8054
  var viewQuery = hostTView.viewQuery;
7601
8055
  try {
7602
8056
  namespaceHTML();
7603
- createViewQuery(viewQuery, rf, hostView[FLAGS], component);
7604
- templateFn(rf || getRenderFlags(hostView), component);
7605
- refreshDescendantViews(hostView, rf);
7606
- updateViewQuery(viewQuery, hostView[FLAGS], component);
8057
+ createViewQuery(viewQuery, hostView, component);
8058
+ templateFn(getRenderFlags(hostView), component);
8059
+ refreshDescendantViews(hostView);
8060
+ updateViewQuery(viewQuery, hostView, component);
7607
8061
  }
7608
8062
  finally {
7609
- leaveView(oldView, rf === 1 /* Create */);
8063
+ leaveView(oldView);
7610
8064
  }
7611
8065
  }
7612
- function createViewQuery(viewQuery, renderFlags, viewFlags, component) {
7613
- if (viewQuery && (renderFlags === 1 /* Create */ ||
7614
- (renderFlags === null && (viewFlags & 1 /* CreationMode */)))) {
8066
+ function createViewQuery(viewQuery, view, component) {
8067
+ if (viewQuery && isCreationMode(view)) {
7615
8068
  viewQuery(1 /* Create */, component);
7616
8069
  }
7617
8070
  }
7618
- function updateViewQuery(viewQuery, flags, component) {
7619
- if (viewQuery && flags & 2 /* Update */) {
8071
+ function updateViewQuery(viewQuery, view, component) {
8072
+ if (viewQuery && !isCreationMode(view)) {
7620
8073
  viewQuery(2 /* Update */, component);
7621
8074
  }
7622
8075
  }
@@ -7859,9 +8312,6 @@
7859
8312
  }
7860
8313
  return null;
7861
8314
  }
7862
- function delegateToClassInput(tNode) {
7863
- return tNode.flags & 8 /* hasClassInput */;
7864
- }
7865
8315
  /**
7866
8316
  * Returns the current OpaqueViewState instance.
7867
8317
  *
@@ -8035,8 +8485,8 @@
8035
8485
  // The first index of the first selector is the tag name.
8036
8486
  var componentTag = componentDef.selectors[0][0];
8037
8487
  var hostRNode = locateHostElement(rendererFactory, opts.host || componentTag);
8038
- var rootFlags = componentDef.onPush ? 4 /* Dirty */ | 64 /* IsRoot */ :
8039
- 2 /* CheckAlways */ | 64 /* IsRoot */;
8488
+ var rootFlags = componentDef.onPush ? 8 /* Dirty */ | 128 /* IsRoot */ :
8489
+ 4 /* CheckAlways */ | 128 /* IsRoot */;
8040
8490
  var rootContext = createRootContext(opts.scheduler, opts.playerHandler);
8041
8491
  var renderer = rendererFactory.createRenderer(hostRNode, componentDef);
8042
8492
  var rootView = createLView(null, createTView(-1, null, 1, 0, null, null, null), rootContext, rootFlags, rendererFactory, renderer, undefined, opts.injector || null);
@@ -8047,7 +8497,9 @@
8047
8497
  rendererFactory.begin();
8048
8498
  var componentView = createRootComponentView(hostRNode, componentDef, rootView, rendererFactory, renderer, sanitizer);
8049
8499
  component = createRootComponent(componentView, componentDef, rootView, rootContext, opts.hostFeatures || null);
8050
- refreshDescendantViews(rootView, null);
8500
+ refreshDescendantViews(rootView); // creation mode pass
8501
+ rootView[FLAGS] &= ~1 /* CreationMode */;
8502
+ refreshDescendantViews(rootView); // update mode pass
8051
8503
  }
8052
8504
  finally {
8053
8505
  leaveView(oldView);
@@ -8070,7 +8522,7 @@
8070
8522
  function createRootComponentView(rNode, def, rootView, rendererFactory, renderer, sanitizer) {
8071
8523
  resetComponentState();
8072
8524
  var tView = rootView[TVIEW];
8073
- var componentView = createLView(rootView, getOrCreateTView(def.template, def.consts, def.vars, def.directiveDefs, def.pipeDefs, def.viewQuery), null, def.onPush ? 4 /* Dirty */ : 2 /* CheckAlways */, rendererFactory, renderer, sanitizer);
8525
+ var componentView = createLView(rootView, getOrCreateTView(def.template, def.consts, def.vars, def.directiveDefs, def.pipeDefs, def.viewQuery), null, def.onPush ? 8 /* Dirty */ : 4 /* CheckAlways */, rendererFactory, renderer, sanitizer);
8074
8526
  var tNode = createNodeAtIndex(0, 3 /* Element */, rNode, null, null);
8075
8527
  if (tView.firstTemplatePass) {
8076
8528
  diPublicInInjector(getOrCreateNodeInjectorForNode(tNode, rootView), rootView, def.type);
@@ -8335,7 +8787,7 @@
8335
8787
  }
8336
8788
  }
8337
8789
  function maybeUnwrapEmpty(value) {
8338
- if (value === EMPTY) {
8790
+ if (value === EMPTY_OBJ) {
8339
8791
  return {};
8340
8792
  }
8341
8793
  else if (value === EMPTY_ARRAY) {
@@ -8559,7 +9011,7 @@
8559
9011
  var IDENT = function (value) {
8560
9012
  return value;
8561
9013
  };
8562
- var EMPTY$1 = [];
9014
+ var EMPTY = [];
8563
9015
  var CIRCULAR = IDENT;
8564
9016
  var MULTI_PROVIDER_FN = function () {
8565
9017
  return Array.prototype.slice.call(arguments);
@@ -8577,8 +9029,8 @@
8577
9029
  this.parent = parent;
8578
9030
  this.source = source;
8579
9031
  var records = this._records = new Map();
8580
- records.set(Injector, { token: Injector, fn: IDENT, deps: EMPTY$1, value: this, useNew: false });
8581
- records.set(INJECTOR$1, { token: INJECTOR$1, fn: IDENT, deps: EMPTY$1, value: this, useNew: false });
9032
+ records.set(Injector, { token: Injector, fn: IDENT, deps: EMPTY, value: this, useNew: false });
9033
+ records.set(INJECTOR$1, { token: INJECTOR$1, fn: IDENT, deps: EMPTY, value: this, useNew: false });
8582
9034
  recursivelyProcessProviders(records, providers);
8583
9035
  }
8584
9036
  StaticInjector.prototype.get = function (token, notFoundValue, flags) {
@@ -8608,7 +9060,7 @@
8608
9060
  function resolveProvider(provider) {
8609
9061
  var deps = computeDeps(provider);
8610
9062
  var fn = IDENT;
8611
- var value = EMPTY$1;
9063
+ var value = EMPTY;
8612
9064
  var useNew = false;
8613
9065
  var provide = resolveForwardRef(provider.provide);
8614
9066
  if (USE_VALUE in provider) {
@@ -8668,7 +9120,7 @@
8668
9120
  deps: [],
8669
9121
  useNew: false,
8670
9122
  fn: MULTI_PROVIDER_FN,
8671
- value: EMPTY$1
9123
+ value: EMPTY
8672
9124
  });
8673
9125
  }
8674
9126
  // Treat the provider as the token.
@@ -8699,7 +9151,7 @@
8699
9151
  path.unshift(token);
8700
9152
  if (record && record.value == CIRCULAR) {
8701
9153
  // Reset the Circular flag.
8702
- record.value = EMPTY$1;
9154
+ record.value = EMPTY;
8703
9155
  }
8704
9156
  throw e;
8705
9157
  }
@@ -8714,13 +9166,13 @@
8714
9166
  if (value == CIRCULAR) {
8715
9167
  throw Error(NO_NEW_LINE + 'Circular dependency');
8716
9168
  }
8717
- else if (value === EMPTY$1) {
9169
+ else if (value === EMPTY) {
8718
9170
  record.value = CIRCULAR;
8719
9171
  var obj = undefined;
8720
9172
  var useNew = record.useNew;
8721
9173
  var fn = record.fn;
8722
9174
  var depRecords = record.deps;
8723
- var deps = EMPTY$1;
9175
+ var deps = EMPTY;
8724
9176
  if (depRecords.length) {
8725
9177
  deps = [];
8726
9178
  for (var i = 0; i < depRecords.length; i++) {
@@ -8749,7 +9201,7 @@
8749
9201
  return value;
8750
9202
  }
8751
9203
  function computeDeps(provider) {
8752
- var deps = EMPTY$1;
9204
+ var deps = EMPTY;
8753
9205
  var providerDeps = provider.deps;
8754
9206
  if (providerDeps && providerDeps.length) {
8755
9207
  deps = [];
@@ -9609,7 +10061,7 @@
9609
10061
  });
9610
10062
  Object.defineProperty(ViewRef.prototype, "destroyed", {
9611
10063
  get: function () {
9612
- return (this._lView[FLAGS] & 32 /* Destroyed */) === 32 /* Destroyed */;
10064
+ return (this._lView[FLAGS] & 64 /* Destroyed */) === 64 /* Destroyed */;
9613
10065
  },
9614
10066
  enumerable: true,
9615
10067
  configurable: true
@@ -9716,7 +10168,7 @@
9716
10168
  * }
9717
10169
  * ```
9718
10170
  */
9719
- ViewRef.prototype.detach = function () { this._lView[FLAGS] &= ~8 /* Attached */; };
10171
+ ViewRef.prototype.detach = function () { this._lView[FLAGS] &= ~16 /* Attached */; };
9720
10172
  /**
9721
10173
  * Re-attaches a view to the change detection tree.
9722
10174
  *
@@ -9773,7 +10225,7 @@
9773
10225
  * }
9774
10226
  * ```
9775
10227
  */
9776
- ViewRef.prototype.reattach = function () { this._lView[FLAGS] |= 8 /* Attached */; };
10228
+ ViewRef.prototype.reattach = function () { this._lView[FLAGS] |= 16 /* Attached */; };
9777
10229
  /**
9778
10230
  * Checks the view and its children.
9779
10231
  *
@@ -9795,16 +10247,7 @@
9795
10247
  *
9796
10248
  * See {@link ChangeDetectorRef#detach detach} for more information.
9797
10249
  */
9798
- ViewRef.prototype.detectChanges = function () {
9799
- var rendererFactory = this._lView[RENDERER_FACTORY];
9800
- if (rendererFactory.begin) {
9801
- rendererFactory.begin();
9802
- }
9803
- detectChangesInternal(this._lView, this.context, null);
9804
- if (rendererFactory.end) {
9805
- rendererFactory.end();
9806
- }
9807
- };
10250
+ ViewRef.prototype.detectChanges = function () { detectChangesInternal(this._lView, this.context); };
9808
10251
  /**
9809
10252
  * Checks the change detector and its children, and throws if any changes are detected.
9810
10253
  *
@@ -9934,7 +10377,7 @@
9934
10377
  if (container$$1) {
9935
10378
  insertView(lView, container$$1, hostView, index, hostTNode.index);
9936
10379
  }
9937
- renderEmbeddedTemplate(lView, this._tView, context, 1 /* Create */);
10380
+ renderEmbeddedTemplate(lView, this._tView, context);
9938
10381
  var viewRef = new ViewRef(lView, context, -1);
9939
10382
  viewRef._tViewNode = lView[HOST_NODE];
9940
10383
  return viewRef;
@@ -10003,7 +10446,7 @@
10003
10446
  var parentView = getParentInjectorView(parentLocation, this._hostView);
10004
10447
  var parentTNode = getParentInjectorTNode(parentLocation, this._hostView, this._hostTNode);
10005
10448
  return !hasParentInjector(parentLocation) || parentTNode == null ?
10006
- new NullInjector() :
10449
+ new NodeInjector(null, this._hostView) :
10007
10450
  new NodeInjector(parentTNode, parentView);
10008
10451
  },
10009
10452
  enumerable: true,
@@ -10344,7 +10787,7 @@
10344
10787
  /**
10345
10788
  * @publicApi
10346
10789
  */
10347
- var VERSION = new Version('7.2.0-rc.0');
10790
+ var VERSION = new Version('7.2.0');
10348
10791
 
10349
10792
  /**
10350
10793
  * @license
@@ -10451,8 +10894,8 @@
10451
10894
  var hostRNode = isInternalRootView ?
10452
10895
  elementCreate(this.selector, rendererFactory.createRenderer(null, this.componentDef)) :
10453
10896
  locateHostElement(rendererFactory, rootSelectorOrNode);
10454
- var rootFlags = this.componentDef.onPush ? 4 /* Dirty */ | 64 /* IsRoot */ :
10455
- 2 /* CheckAlways */ | 64 /* IsRoot */;
10897
+ var rootFlags = this.componentDef.onPush ? 8 /* Dirty */ | 128 /* IsRoot */ :
10898
+ 4 /* CheckAlways */ | 128 /* IsRoot */;
10456
10899
  var rootContext = !isInternalRootView ? rootViewInjector.get(ROOT_CONTEXT) : createRootContext();
10457
10900
  var renderer = rendererFactory.createRenderer(hostRNode, this.componentDef);
10458
10901
  if (rootSelectorOrNode && hostRNode) {
@@ -10505,10 +10948,10 @@
10505
10948
  // Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
10506
10949
  component = createRootComponent(componentView, this.componentDef, rootLView, rootContext, [LifecycleHooksFeature]);
10507
10950
  addToViewTree(rootLView, HEADER_OFFSET, componentView);
10508
- refreshDescendantViews(rootLView, 1 /* Create */);
10951
+ refreshDescendantViews(rootLView);
10509
10952
  }
10510
10953
  finally {
10511
- leaveView(oldLView, true);
10954
+ leaveView(oldLView);
10512
10955
  if (rendererFactory.end)
10513
10956
  rendererFactory.end();
10514
10957
  }
@@ -10669,7 +11112,7 @@
10669
11112
  try {
10670
11113
  html = encodeURI(html);
10671
11114
  }
10672
- catch (e) {
11115
+ catch (_a) {
10673
11116
  return null;
10674
11117
  }
10675
11118
  var xhr = new XMLHttpRequest();
@@ -10698,7 +11141,7 @@
10698
11141
  body.removeChild(body.firstChild);
10699
11142
  return body;
10700
11143
  }
10701
- catch (e) {
11144
+ catch (_a) {
10702
11145
  return null;
10703
11146
  }
10704
11147
  };
@@ -10761,7 +11204,7 @@
10761
11204
  try {
10762
11205
  return !!window.DOMParser;
10763
11206
  }
10764
- catch (e) {
11207
+ catch (_a) {
10765
11208
  return false;
10766
11209
  }
10767
11210
  }
@@ -11108,11 +11551,11 @@
11108
11551
  * found in the LICENSE file at https://angular.io/license
11109
11552
  */
11110
11553
  var MARKER = "\uFFFD";
11111
- var ICU_BLOCK_REGEX = /^\s*(�\d+�)\s*,\s*(select|plural)\s*,/;
11554
+ var ICU_BLOCK_REGEX = /^\s*(�\d+:?\d*�)\s*,\s*(select|plural)\s*,/;
11112
11555
  var SUBTEMPLATE_REGEXP = /�\/?\*(\d+:\d+)�/gi;
11113
11556
  var PH_REGEXP = /�(\/?[#*]\d+):?\d*�/gi;
11114
11557
  var BINDING_REGEXP = /�(\d+):?\d*�/gi;
11115
- var ICU_REGEXP = /({\s*�\d+�\s*,\s*\S{6}\s*,[\s\S]*})/gi;
11558
+ var ICU_REGEXP = /({\s*�\d+:?\d*�\s*,\s*\S{6}\s*,[\s\S]*})/gi;
11116
11559
  // i18nPostproocess regexps
11117
11560
  var PP_PLACEHOLDERS = /\[(�.+?�?)\]/g;
11118
11561
  var PP_ICU_VARS = /({\s*)(VAR_(PLURAL|SELECT)(_\d+)?)(\s*,)/g;
@@ -12645,7 +13088,7 @@
12645
13088
  // TODO(kara): use bindingRoot instead of bindingStartIndex when implementing host bindings
12646
13089
  var bindingIndex = getBindingRoot() + slotOffset;
12647
13090
  var lView = getLView();
12648
- return getCreationMode() ?
13091
+ return isCreationMode() ?
12649
13092
  updateBinding(lView, bindingIndex, thisArg ? pureFn.call(thisArg) : pureFn()) :
12650
13093
  getBinding(lView, bindingIndex);
12651
13094
  }
@@ -12899,7 +13342,7 @@
12899
13342
  */
12900
13343
  function getPipeDef$1(name, registry) {
12901
13344
  if (registry) {
12902
- for (var i = 0; i < registry.length; i++) {
13345
+ for (var i = registry.length - 1; i >= 0; i--) {
12903
13346
  var pipeDef = registry[i];
12904
13347
  if (name === pipeDef.name) {
12905
13348
  return pipeDef;
@@ -13326,7 +13769,7 @@
13326
13769
  return factoryFn();
13327
13770
  }
13328
13771
  else {
13329
- var matchingIdx = locateDirectiveOrProvider(tNode, currentView, read, false);
13772
+ var matchingIdx = locateDirectiveOrProvider(tNode, currentView, read, false, false);
13330
13773
  if (matchingIdx !== null) {
13331
13774
  return getNodeInjectable(currentView[TVIEW].data, currentView, matchingIdx, tNode);
13332
13775
  }
@@ -13371,7 +13814,7 @@
13371
13814
  result = queryByTemplateRef(type, tNode, currentView, predicate.read);
13372
13815
  }
13373
13816
  else {
13374
- var matchingIdx = locateDirectiveOrProvider(tNode, currentView, type, false);
13817
+ var matchingIdx = locateDirectiveOrProvider(tNode, currentView, type, false, false);
13375
13818
  if (matchingIdx !== null) {
13376
13819
  result = queryRead(tNode, currentView, predicate.read, matchingIdx);
13377
13820
  }
@@ -13935,6 +14378,7 @@
13935
14378
  'ɵload': load,
13936
14379
  'ɵprojection': projection,
13937
14380
  'ɵelementProperty': elementProperty,
14381
+ 'ɵcomponentHostSyntheticProperty': componentHostSyntheticProperty,
13938
14382
  'ɵpipeBind1': pipeBind1,
13939
14383
  'ɵpipeBind2': pipeBind2,
13940
14384
  'ɵpipeBind3': pipeBind3,
@@ -13947,6 +14391,7 @@
13947
14391
  'ɵregisterContentQuery': registerContentQuery,
13948
14392
  'ɵreference': reference,
13949
14393
  'ɵelementStyling': elementStyling,
14394
+ 'ɵelementHostAttrs': elementHostAttrs,
13950
14395
  'ɵelementStylingMap': elementStylingMap,
13951
14396
  'ɵelementStyleProp': elementStyleProp,
13952
14397
  'ɵelementStylingApply': elementStylingApply,
@@ -14444,10 +14889,12 @@
14444
14889
  if (ngModuleDef === null) {
14445
14890
  ngModuleDef = getCompilerFacade().compileNgModule(angularCoreEnv, "ng://" + moduleType.name + "/ngModuleDef.js", {
14446
14891
  type: moduleType,
14447
- bootstrap: flatten$1(ngModule.bootstrap || EMPTY_ARRAY$2),
14448
- declarations: declarations,
14449
- imports: flatten$1(ngModule.imports || EMPTY_ARRAY$2).map(expandModuleWithProviders),
14450
- exports: flatten$1(ngModule.exports || EMPTY_ARRAY$2).map(expandModuleWithProviders),
14892
+ bootstrap: flatten$1(ngModule.bootstrap || EMPTY_ARRAY$2, resolveForwardRef),
14893
+ declarations: declarations.map(resolveForwardRef),
14894
+ imports: flatten$1(ngModule.imports || EMPTY_ARRAY$2, resolveForwardRef)
14895
+ .map(expandModuleWithProviders),
14896
+ exports: flatten$1(ngModule.exports || EMPTY_ARRAY$2, resolveForwardRef)
14897
+ .map(expandModuleWithProviders),
14451
14898
  emitInline: true,
14452
14899
  });
14453
14900
  }
@@ -14468,8 +14915,8 @@
14468
14915
  deps: reflectDependencies(moduleType),
14469
14916
  providers: ngModule.providers || EMPTY_ARRAY$2,
14470
14917
  imports: [
14471
- ngModule.imports || EMPTY_ARRAY$2,
14472
- ngModule.exports || EMPTY_ARRAY$2,
14918
+ (ngModule.imports || EMPTY_ARRAY$2).map(resolveForwardRef),
14919
+ (ngModule.exports || EMPTY_ARRAY$2).map(resolveForwardRef),
14473
14920
  ],
14474
14921
  };
14475
14922
  ngInjectorDef = getCompilerFacade().compileInjector(angularCoreEnv, "ng://" + moduleType.name + "/ngInjectorDef.js", meta);
@@ -14488,7 +14935,7 @@
14488
14935
  var ngModuleDef = getNgModuleDef(moduleType, true);
14489
14936
  var errors = [];
14490
14937
  ngModuleDef.declarations.forEach(verifyDeclarationsHaveDefinitions);
14491
- var combinedDeclarations = __spread(ngModuleDef.declarations, flatten$1(ngModuleDef.imports.map(computeCombinedExports)));
14938
+ var combinedDeclarations = __spread(ngModuleDef.declarations.map(resolveForwardRef), flatten$1(ngModuleDef.imports.map(computeCombinedExports), resolveForwardRef));
14492
14939
  ngModuleDef.exports.forEach(verifyExportsAreDeclaredOrReExported);
14493
14940
  ngModuleDef.declarations.forEach(verifyDeclarationIsUnique);
14494
14941
  ngModuleDef.declarations.forEach(verifyComponentEntryComponentsIsPartOfNgModule);
@@ -14777,9 +15224,9 @@
14777
15224
  var compiler = getCompilerFacade();
14778
15225
  if (ngComponentDef === null) {
14779
15226
  if (componentNeedsResolution(metadata)) {
14780
- var error = ["Component '" + stringify(type) + "' is not resolved:"];
15227
+ var error = ["Component '" + stringify$1(type) + "' is not resolved:"];
14781
15228
  if (metadata.templateUrl) {
14782
- error.push(" - templateUrl: " + stringify(metadata.templateUrl));
15229
+ error.push(" - templateUrl: " + stringify$1(metadata.templateUrl));
14783
15230
  }
14784
15231
  if (metadata.styleUrls && metadata.styleUrls.length) {
14785
15232
  error.push(" - styleUrls: " + JSON.stringify(metadata.styleUrls));
@@ -14787,8 +15234,8 @@
14787
15234
  error.push("Did you run and wait for 'resolveComponentResources()'?");
14788
15235
  throw new Error(error.join('\n'));
14789
15236
  }
14790
- var meta = __assign({}, directiveMetadata(type, metadata), { template: metadata.template || '', preserveWhitespaces: metadata.preserveWhitespaces || false, styles: metadata.styles || EMPTY_ARRAY, animations: metadata.animations, viewQueries: extractQueriesMetadata(type, getReflect().propMetadata(type), isViewQuery), directives: [], pipes: new Map(), encapsulation: metadata.encapsulation || exports.ViewEncapsulation.Emulated, interpolation: metadata.interpolation, viewProviders: metadata.viewProviders || null });
14791
- ngComponentDef = compiler.compileComponent(angularCoreEnv, "ng://" + stringify(type) + "/template.html", meta);
15237
+ var meta = __assign({}, directiveMetadata(type, metadata), { template: metadata.template || '', preserveWhitespaces: metadata.preserveWhitespaces || false, styles: metadata.styles || EMPTY_ARRAY, animations: metadata.animations, viewQueries: extractQueriesMetadata(type, getReflect().propMetadata(type), isViewQuery), directives: [], changeDetection: metadata.changeDetection, pipes: new Map(), encapsulation: metadata.encapsulation || exports.ViewEncapsulation.Emulated, interpolation: metadata.interpolation, viewProviders: metadata.viewProviders || null });
15238
+ ngComponentDef = compiler.compileComponent(angularCoreEnv, "ng://" + stringify$1(type) + "/template.html", meta);
14792
15239
  // When NgModule decorator executed, we enqueued the module definition such that
14793
15240
  // it would only dequeue and add itself as module scope to all of its declarations,
14794
15241
  // but only if if all of its declarations had resolved. This call runs the check
@@ -14850,7 +15297,7 @@
14850
15297
  typeArgumentCount: 0,
14851
15298
  selector: metadata.selector,
14852
15299
  deps: reflectDependencies(type),
14853
- host: metadata.host || EMPTY_OBJ$1,
15300
+ host: metadata.host || EMPTY_OBJ,
14854
15301
  propMetadata: propMetadata,
14855
15302
  inputs: metadata.inputs || EMPTY_ARRAY,
14856
15303
  outputs: metadata.outputs || EMPTY_ARRAY,
@@ -14864,9 +15311,8 @@
14864
15311
  providers: metadata.providers || null,
14865
15312
  };
14866
15313
  }
14867
- var EMPTY_OBJ$1 = {};
14868
15314
  function convertToR3QueryPredicate(selector) {
14869
- return typeof selector === 'string' ? splitByComma(selector) : selector;
15315
+ return typeof selector === 'string' ? splitByComma(selector) : resolveForwardRef(selector);
14870
15316
  }
14871
15317
  function convertToR3QueryMetadata(propertyName, ann) {
14872
15318
  return {
@@ -14885,7 +15331,7 @@
14885
15331
  if (isQueryAnn(ann)) {
14886
15332
  if (!ann.selector) {
14887
15333
  throw new Error("Can't construct a query for the property \"" + field + "\" of " +
14888
- ("\"" + stringify(type) + "\" since the query selector wasn't defined."));
15334
+ ("\"" + stringify$1(type) + "\" since the query selector wasn't defined."));
14889
15335
  }
14890
15336
  queriesMeta.push(convertToR3QueryMetadata(field, ann));
14891
15337
  }
@@ -18349,8 +18795,8 @@
18349
18795
  var lNode = lContext.lView[lContext.nodeIndex];
18350
18796
  var stylingContext = getStylingContext(lContext.nodeIndex, lContext.lView);
18351
18797
  if (stylingContext) {
18352
- for (var i = 8 /* SingleStylesStartPosition */; i < lNode.length; i += 4 /* Size */) {
18353
- if (isClassBased(lNode, i)) {
18798
+ for (var i = 9 /* SingleStylesStartPosition */; i < lNode.length; i += 4 /* Size */) {
18799
+ if (isClassBasedValue(lNode, i)) {
18354
18800
  var className = getProp(lNode, i);
18355
18801
  var value = getValue(lNode, i);
18356
18802
  if (typeof value == 'boolean') {
@@ -18382,8 +18828,8 @@
18382
18828
  var lNode = lContext.lView[lContext.nodeIndex];
18383
18829
  var stylingContext = getStylingContext(lContext.nodeIndex, lContext.lView);
18384
18830
  if (stylingContext) {
18385
- for (var i = 8 /* SingleStylesStartPosition */; i < lNode.length; i += 4 /* Size */) {
18386
- if (!isClassBased(lNode, i)) {
18831
+ for (var i = 9 /* SingleStylesStartPosition */; i < lNode.length; i += 4 /* Size */) {
18832
+ if (!isClassBasedValue(lNode, i)) {
18387
18833
  var styleName = getProp(lNode, i);
18388
18834
  var value = getValue(lNode, i);
18389
18835
  if (value !== null) {
@@ -24202,6 +24648,7 @@
24202
24648
  exports.ɵloadQueryList = loadQueryList;
24203
24649
  exports.ɵelementEnd = elementEnd;
24204
24650
  exports.ɵelementProperty = elementProperty;
24651
+ exports.ɵcomponentHostSyntheticProperty = componentHostSyntheticProperty;
24205
24652
  exports.ɵprojectionDef = projectionDef;
24206
24653
  exports.ɵreference = reference;
24207
24654
  exports.ɵenableBindings = enableBindings;
@@ -24211,6 +24658,7 @@
24211
24658
  exports.ɵelementContainerStart = elementContainerStart;
24212
24659
  exports.ɵelementContainerEnd = elementContainerEnd;
24213
24660
  exports.ɵelementStyling = elementStyling;
24661
+ exports.ɵelementHostAttrs = elementHostAttrs;
24214
24662
  exports.ɵelementStylingMap = elementStylingMap;
24215
24663
  exports.ɵelementStyleProp = elementStyleProp;
24216
24664
  exports.ɵelementStylingApply = elementStylingApply;