@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
@@ -11,136 +11,221 @@ import { PlayerContext } from './player';
11
11
  /**
12
12
  * The styling context acts as a styling manifest (shaped as an array) for determining which
13
13
  * styling properties have been assigned via the provided `updateStylingMap`, `updateStyleProp`
14
- * and `updateClassProp` functions. There are also two initialization functions
15
- * `allocStylingContext` and `createStylingContextTemplate` which are used to initialize
16
- * and/or clone the context.
14
+ * and `updateClassProp` functions. It also stores the static style/class values that were
15
+ * extracted from the template by the compiler.
17
16
  *
18
- * The context is an array where the first two cells are used for static data (initial styling)
19
- * and dirty flags / index offsets). The remaining set of cells is used for multi (map) and single
20
- * (prop) style values.
17
+ * A context is created by Angular when:
18
+ * 1. An element contains static styling values (like style="..." or class="...")
19
+ * 2. An element contains single property binding values (like [style.prop]="x" or
20
+ * [class.prop]="y")
21
+ * 3. An element contains multi property binding values (like [style]="x" or [class]="y")
22
+ * 4. A directive contains host bindings for static, single or multi styling properties/bindings.
23
+ * 5. An animation player is added to an element via `addPlayer`
21
24
  *
22
- * each value from here onwards is mapped as so:
23
- * [i] = mutation/type flag for the style/class value
24
- * [i + 1] = prop string (or null incase it has been removed)
25
- * [i + 2] = value string (or null incase it has been removed)
25
+ * Note that even if an element contains static styling then this context will be created and
26
+ * attached to it. The reason why this happens (instead of treating styles/classes as regular
27
+ * HTML attributes) is because the style/class bindings must be able to default themselves back
28
+ * to their respective static values when they are set to null.
26
29
  *
27
- * There are three types of styling types stored in this context:
28
- * initial: any styles that are passed in once the context is created
29
- * (these are stored in the first cell of the array and the first
30
- * value of this array is always `null` even if no initial styling exists.
31
- * the `null` value is there so that any new styles have a parent to point
32
- * to. This way we can always assume that there is a parent.)
30
+ * Say for example we have this:
31
+ * ```
32
+ * <!-- when myWidthExp=null then a width of "100px"
33
+ * will be used a default value for width -->
34
+ * <div style="width:100px" [style.width]="myWidthExp"></div>
35
+ * ```
36
+ *
37
+ * Even in the situation where there are no bindings, the static styling is still placed into the
38
+ * context because there may be another directive on the same element that has styling.
39
+ *
40
+ * When Angular initializes styling data for an element then it will first register the static
41
+ * styling values on the element using one of these two instructions:
33
42
  *
34
- * single: any styles that are updated using `updateStyleProp` or `updateClassProp` (fixed set)
43
+ * 1. elementStart or element (within the template function of a component)
44
+ * 2. elementHostAttrs (for directive host bindings)
35
45
  *
36
- * multi: any styles that are updated using `updateStylingMap` (dynamic set)
46
+ * In either case, a styling context will be created and stored within an element's LViewData. Once
47
+ * the styling context is created then single and multi properties can stored within it. For this to
48
+ * happen, the following function needs to be called:
37
49
  *
38
- * Note that context is only used to collect style information. Only when `renderStyling`
39
- * is called is when the styling payload will be rendered (or built as a key/value map).
50
+ * `elementStyling` (called with style properties, class properties and a sanitizer + a directive
51
+ * instance).
40
52
  *
41
- * When the context is created, depending on what initial styling values are passed in, the
42
- * context itself will be pre-filled with slots based on the initial style properties. Say
43
- * for example we have a series of initial styles that look like so:
53
+ * When this instruction is called it will populate the styling context with the provided style
54
+ * and class names into the context.
44
55
  *
45
- * style="width:100px; height:200px;"
46
- * class="foo"
56
+ * The context itself looks like this:
57
+ *
58
+ * context = [
59
+ * // 0-8: header values (about 8 entries of configuration data)
60
+ * // 9+: this is where each entry is stored:
61
+ * ]
47
62
  *
48
- * Then the initial state of the context (once initialized) will look like so:
63
+ * Let's say we have the following template code:
49
64
  *
50
65
  * ```
66
+ * <div class="foo bar"
67
+ * style="width:200px; color:red"
68
+ * [style.width]="myWidthExp"
69
+ * [style.height]="myHeightExp"
70
+ * [class.baz]="myBazExp">
71
+ * ```
72
+ *
73
+ * The context generated from these values will look like this (note that
74
+ * for each binding name (the class and style bindings) the values will
75
+ * be inserted twice into the array (once for single property entries) and
76
+ * another for multi property entries).
77
+ *
78
+ * context = [
79
+ * // 0-8: header values (about 8 entries of configuration data)
80
+ * // 9+: this is where each entry is stored:
81
+ *
82
+ * // SINGLE PROPERTIES
83
+ * configForWidth,
84
+ * 'width'
85
+ * myWidthExp, // the binding value not the binding itself
86
+ * 0, // the directive owner
87
+ *
88
+ * configForHeight,
89
+ * 'height'
90
+ * myHeightExp, // the binding value not the binding itself
91
+ * 0, // the directive owner
92
+ *
93
+ * configForBazClass,
94
+ * 'baz
95
+ * myBazClassExp, // the binding value not the binding itself
96
+ * 0, // the directive owner
97
+ *
98
+ * // MULTI PROPERTIES
99
+ * configForWidth,
100
+ * 'width'
101
+ * myWidthExp, // the binding value not the binding itself
102
+ * 0, // the directive owner
103
+ *
104
+ * configForHeight,
105
+ * 'height'
106
+ * myHeightExp, // the binding value not the binding itself
107
+ * 0, // the directive owner
108
+ *
109
+ * configForBazClass,
110
+ * 'baz
111
+ * myBazClassExp, // the binding value not the binding itself
112
+ * 0, // the directive owner
113
+ * ]
114
+ *
115
+ * The configuration values are left out of the example above because
116
+ * the ordering of them could change between code patches. Please read the
117
+ * documentation below to get a better understand of what the configuration
118
+ * values are and how they work.
119
+ *
120
+ * Each time a binding property is updated (whether it be through a single
121
+ * property instruction like `elementStyleProp`, `elementClassProp` or
122
+ * `elementStylingMap`) then the values in the context will be updated as
123
+ * well.
124
+ *
125
+ * If for example `[style.width]` updates to `555px` then its value will be reflected
126
+ * in the context as so:
127
+ *
51
128
  * context = [
52
- * element,
53
- * playerContext | null,
54
- * styleSanitizer | null,
55
- * [null, '100px', '200px', true], // property names are not needed since they have already been
56
- * written to DOM.
57
- *
58
- * configMasterVal,
59
- * 1, // this instructs how many `style` values there are so that class index values can be
60
- * offsetted
61
- * { classOne: true, classTwo: false } | 'classOne classTwo' | null // last class value provided
62
- * into updateStylingMap
63
- * { styleOne: '100px', styleTwo: 0 } | null // last style value provided into updateStylingMap
64
- *
65
- * // 8
66
- * 'width',
67
- * pointers(1, 15); // Point to static `width`: `100px` and multi `width`.
68
- * null,
69
- *
70
- * // 11
71
- * 'height',
72
- * pointers(2, 18); // Point to static `height`: `200px` and multi `height`.
73
- * null,
74
- *
75
- * // 14
76
- * 'foo',
77
- * pointers(1, 21); // Point to static `foo`: `true` and multi `foo`.
78
- * null,
79
- *
80
- * // 17
81
- * 'width',
82
- * pointers(1, 6); // Point to static `width`: `100px` and single `width`.
83
- * null,
84
- *
85
- * // 21
86
- * 'height',
87
- * pointers(2, 9); // Point to static `height`: `200px` and single `height`.
88
- * null,
89
- *
90
- * // 24
91
- * 'foo',
92
- * pointers(3, 12); // Point to static `foo`: `true` and single `foo`.
93
- * null,
129
+ * // ...
130
+ * configForWidth, // this will be marked DIRTY
131
+ * 'width'
132
+ * '555px',
133
+ * 0,
134
+ * //..
94
135
  * ]
95
136
  *
96
- * function pointers(staticIndex: number, dynamicIndex: number) {
97
- * // combine the two indices into a single word.
98
- * return (staticIndex << StylingFlags.BitCountSize) |
99
- * (dynamicIndex << (StylingIndex.BitCountSize + StylingFlags.BitCountSize));
137
+ * The context and directive data will also be marked dirty.
138
+ *
139
+ * Despite the context being updated, nothing has been rendered on screen (not styles or
140
+ * classes have been set on the element). To kick off rendering for an element the following
141
+ * function needs to be run `elementStylingApply`.
142
+ *
143
+ * `elementStylingApply` will run through the context and find each dirty value and render them onto
144
+ * the element. Once complete, all styles/classes will be set to clean. Because of this, the render
145
+ * function will now know not to rerun itself again if called again unless new style/class values
146
+ * have changed.
147
+ *
148
+ * ## Directives
149
+ * Directives style values (which are provided through host bindings) are also supported and
150
+ * housed within the same styling context as are template-level style/class properties/bindings.
151
+ * Both directive-level and template-level styling bindings share the same context.
152
+ *
153
+ * Each of the following instructions supports accepting a directive instance as an input parameter:
154
+ *
155
+ * - `elementHostAttrs`
156
+ * - `elementStyling`
157
+ * - `elementStyleProp`
158
+ * - `elementClassProp`
159
+ * - `elementStylingMap`
160
+ * - `elementStylingApply`
161
+ *
162
+ * Each time a directiveRef is passed in, it will be converted into an index by examining the
163
+ * directive registry (which lives in the context configuration area). The index is then used
164
+ * to help single style properties figure out where a value is located in the context.
165
+ *
166
+ * If two directives or a directive + a template binding both write to the same style/class
167
+ * binding then the styling context code will decide which one wins based on the following
168
+ * rule:
169
+ *
170
+ * 1. If the template binding has a value then it always wins
171
+ * 2. If not then whichever first-registered directive that has that value first will win
172
+ *
173
+ * The code example helps make this clear:
174
+ *
175
+ * ```
176
+ * <div [style.width]="myWidth" [my-width-directive]="'600px">
177
+ * @Directive({ selector: '[my-width-directive' ]})
178
+ * class MyWidthDirective {
179
+ * @Input('my-width-directive')
180
+ * @HostBinding('style.width')
181
+ * public width = null;
100
182
  * }
101
183
  * ```
102
184
  *
103
- * The values are duplicated so that space is set aside for both multi ([style] and [class])
104
- * and single ([style.prop] or [class.named]) values. The respective config values
105
- * (configValA, configValB, etc...) are a combination of the StylingFlags with two index
106
- * values: the `initialIndex` (which points to the index location of the style value in
107
- * the initial styles array in slot 0) and the `dynamicIndex` (which points to the
108
- * matching single/multi index position in the context array for the same prop).
109
- *
110
- * This means that every time `updateStyleProp` or `updateClassProp` are called then they
111
- * must be called using an index value (not a property string) which references the index
112
- * value of the initial style prop/class when the context was created. This also means that
113
- * `updateStyleProp` or `updateClassProp` cannot be called with a new property (only
114
- * `updateStylingMap` can include new CSS properties that will be added to the context).
185
+ * Since there is a style binding for width present on the element (`[style.width]`) then
186
+ * it will always win over the width binding that is present as a host binding within
187
+ * the `MyWidthDirective`. However, if `[style.width]` renders as `null` (so `myWidth=null`)
188
+ * then the `MyWidthDirective` will be able to write to the `width` style within the context.
189
+ * Simply put, whichever directive writes to a value ends up having ownership of it.
190
+ *
191
+ * The way in which the ownership is facilitated is through index value. The earliest directives
192
+ * get the smallest index values (with 0 being reserved for the template element bindings). Each
193
+ * time a value is written from a directive or the template bindings, the value itself gets
194
+ * assigned the directive index value in its data. If another directive writes a value again then
195
+ * its directive index gets compared against the directive index that exists on the element. Only
196
+ * when the new value's directive index is less than the existing directive index then the new
197
+ * value will be written to the context.
198
+ *
199
+ * Each directive also has its own sanitizer and dirty flags. These values are consumed within the
200
+ * rendering function.
115
201
  */
116
- export interface StylingContext extends Array<InitialStyles | {
202
+ export interface StylingContext extends Array<{
117
203
  [key: string]: any;
118
204
  } | number | string | boolean | RElement | StyleSanitizeFn | PlayerContext | null> {
119
205
  /**
120
- * Location of animation context (which contains the active players) for this element styling
121
- * context.
206
+ * A numeric value representing the configuration status (whether the context is dirty or not)
207
+ * mixed together (using bit shifting) with a index value which tells the starting index value
208
+ * of where the multi style entries begin.
122
209
  */
123
- [StylingIndex.PlayerContext]: PlayerContext | null;
210
+ [StylingIndex.MasterFlagPosition]: number;
124
211
  /**
125
- * The style sanitizer that is used within this context
212
+ * Location of the collection of directives for this context
126
213
  */
127
- [StylingIndex.StyleSanitizerPosition]: StyleSanitizeFn | null;
214
+ [StylingIndex.DirectiveRegistryPosition]: DirectiveRegistryValues;
128
215
  /**
129
- * Location of initial data shared by all instances of this style.
216
+ * Location of all static styles values
130
217
  */
131
- [StylingIndex.InitialStylesPosition]: InitialStyles;
218
+ [StylingIndex.InitialStyleValuesPosition]: InitialStylingValues;
132
219
  /**
133
- * A numeric value representing the configuration status (whether the context is dirty or not)
134
- * mixed together (using bit shifting) with a index value which tells the starting index value
135
- * of where the multi style entries begin.
220
+ * Location of all static class values
136
221
  */
137
- [StylingIndex.MasterFlagPosition]: number;
222
+ [StylingIndex.InitialClassValuesPosition]: InitialStylingValues;
138
223
  /**
139
224
  * A numeric value representing the class index offset value. Whenever a single class is
140
225
  * applied (using `elementClassProp`) it should have an styling index value that doesn't
141
226
  * need to take into account any style values that exist in the context.
142
227
  */
143
- [StylingIndex.ClassOffsetPosition]: number;
228
+ [StylingIndex.SinglePropOffsetPositions]: SinglePropOffsetValues;
144
229
  /**
145
230
  * Location of element that is used as a target for this context.
146
231
  */
@@ -149,28 +234,204 @@ export interface StylingContext extends Array<InitialStyles | {
149
234
  * The last class value that was interpreted by elementStylingMap. This is cached
150
235
  * So that the algorithm can exit early incase the value has not changed.
151
236
  */
152
- [StylingIndex.PreviousOrCachedMultiClassValue]: {
237
+ [StylingIndex.CachedClassValueOrInitialClassString]: {
153
238
  [key: string]: any;
154
- } | string | null;
239
+ } | string | (string)[] | null;
155
240
  /**
156
241
  * The last style value that was interpreted by elementStylingMap. This is cached
157
242
  * So that the algorithm can exit early incase the value has not changed.
158
243
  */
159
- [StylingIndex.PreviousMultiStyleValue]: {
244
+ [StylingIndex.CachedStyleValue]: {
160
245
  [key: string]: any;
161
- } | null;
246
+ } | (string)[] | null;
247
+ /**
248
+ * Location of animation context (which contains the active players) for this element styling
249
+ * context.
250
+ */
251
+ [StylingIndex.PlayerContext]: PlayerContext | null;
162
252
  }
163
253
  /**
164
- * The initial styles is populated whether or not there are any initial styles passed into
165
- * the context during allocation. The 0th value must be null so that index values of `0` within
166
- * the context flags can always point to a null value safely when nothing is set.
254
+ * Used as a styling array to house static class and style values that were extracted
255
+ * by the compiler and placed in the animation context via `elementStart` and
256
+ * `elementHostAttrs`.
167
257
  *
168
- * All other entries in this array are of `string` value and correspond to the values that
169
- * were extracted from the `style=""` attribute in the HTML code for the provided template.
258
+ * See [InitialStylingValuesIndex] for a breakdown of how all this works.
170
259
  */
171
- export interface InitialStyles extends Array<string | null | boolean> {
260
+ export interface InitialStylingValues extends Array<string | boolean | null> {
172
261
  [0]: null;
173
262
  }
263
+ /**
264
+ * Used as an offset/position index to figure out where initial styling
265
+ * values are located.
266
+ *
267
+ * Used as a reference point to provide markers to all static styling
268
+ * values (the initial style and class values on an element) within an
269
+ * array within the StylingContext. This array contains key/value pairs
270
+ * where the key is the style property name or className and the value is
271
+ * the style value or whether or not a class is present on the elment.
272
+ *
273
+ * The first value is also always null so that a initial index value of
274
+ * `0` will always point to a null value.
275
+ *
276
+ * If a <div> elements contains a list of static styling values like so:
277
+ *
278
+ * <div class="foo bar baz" style="width:100px; height:200px;">
279
+ *
280
+ * Then the initial styles for that will look like so:
281
+ *
282
+ * Styles:
283
+ * StylingContext[InitialStylesIndex] = [
284
+ * null, 'width', '100px', height, '200px'
285
+ * ]
286
+ *
287
+ * Classes:
288
+ * StylingContext[InitialStylesIndex] = [
289
+ * null, 'foo', true, 'bar', true, 'baz', true
290
+ * ]
291
+ *
292
+ * Initial style and class entries have their own arrays. This is because
293
+ * it's easier to add to the end of one array and not then have to update
294
+ * every context entries' pointer index to the newly offseted values.
295
+ *
296
+ * When property bindinds are added to a context then initial style/class
297
+ * values will also be inserted into the array. This is to create a space
298
+ * in the situation when a follow-up directive inserts static styling into
299
+ * the array. By default style values are `null` and class values are
300
+ * `false` when inserted by property bindings.
301
+ *
302
+ * For example:
303
+ * <div class="foo bar baz"
304
+ * [class.car]="myCarExp"
305
+ * style="width:100px; height:200px;"
306
+ * [style.opacity]="myOpacityExp">
307
+ *
308
+ * Will construct initial styling values that look like:
309
+ *
310
+ * Styles:
311
+ * StylingContext[InitialStylesIndex] = [
312
+ * null, 'width', '100px', height, '200px', 'opacity', null
313
+ * ]
314
+ *
315
+ * Classes:
316
+ * StylingContext[InitialStylesIndex] = [
317
+ * null, 'foo', true, 'bar', true, 'baz', true, 'car', false
318
+ * ]
319
+ *
320
+ * Now if a directive comes along and introduces `car` as a static
321
+ * class value or `opacity` then those values will be filled into
322
+ * the initial styles array.
323
+ *
324
+ * For example:
325
+ *
326
+ * @Directive({
327
+ * selector: 'opacity-car-directive',
328
+ * host: {
329
+ * 'style': 'opacity:0.5',
330
+ * 'class': 'car'
331
+ * }
332
+ * })
333
+ * class OpacityCarDirective {}
334
+ *
335
+ * This will render itself as:
336
+ *
337
+ * Styles:
338
+ * StylingContext[InitialStylesIndex] = [
339
+ * null, 'width', '100px', height, '200px', 'opacity', null
340
+ * ]
341
+ *
342
+ * Classes:
343
+ * StylingContext[InitialStylesIndex] = [
344
+ * null, 'foo', true, 'bar', true, 'baz', true, 'car', false
345
+ * ]
346
+ */
347
+ export declare const enum InitialStylingValuesIndex {
348
+ KeyValueStartPosition = 1,
349
+ PropOffset = 0,
350
+ ValueOffset = 1,
351
+ Size = 2
352
+ }
353
+ /**
354
+ * An array located in the StylingContext that houses all directive instances and additional
355
+ * data about them.
356
+ *
357
+ * Each entry in this array represents a source of where style/class binding values could
358
+ * come from. By default, there is always at least one directive here with a null value and
359
+ * that represents bindings that live directly on an element (not host bindings).
360
+ *
361
+ * Each successive entry in the array is an actual instance of an array as well as some
362
+ * additional info.
363
+ *
364
+ * An entry within this array has the following values:
365
+ * [0] = The instance of the directive (or null when it is not a directive, but a template binding
366
+ * source)
367
+ * [1] = The pointer that tells where the single styling (stuff like [class.foo] and [style.prop])
368
+ * offset values are located. This value will allow for a binding instruction to find exactly
369
+ * where a style is located.
370
+ * [2] = Whether or not the directive has any styling values that are dirty. This is used as
371
+ * reference within the renderClassAndStyleBindings function to decide whether to skip
372
+ * iterating through the context when rendering is executed.
373
+ * [3] = The styleSanitizer instance that is assigned to the directive. Although it's unlikely,
374
+ * a directive could introduce its own special style sanitizer and for this reach each
375
+ * directive will get its own space for it (if null then the very first sanitizer is used).
376
+ *
377
+ * Each time a new directive is added it will insert these four values at the end of the array.
378
+ * When this array is examined (using indexOf) then the resulting directiveIndex will be resolved
379
+ * by dividing the index value by the size of the array entries (so if DirA is at spot 8 then its
380
+ * index will be 2).
381
+ */
382
+ export interface DirectiveRegistryValues extends Array<null | {} | boolean | number | StyleSanitizeFn> {
383
+ [DirectiveRegistryValuesIndex.DirectiveValueOffset]: null;
384
+ [DirectiveRegistryValuesIndex.SinglePropValuesIndexOffset]: number;
385
+ [DirectiveRegistryValuesIndex.DirtyFlagOffset]: boolean;
386
+ [DirectiveRegistryValuesIndex.StyleSanitizerOffset]: StyleSanitizeFn | null;
387
+ }
388
+ /**
389
+ * An enum that outlines the offset/position values for each directive entry and its data
390
+ * that are housed inside of [DirectiveRegistryValues].
391
+ */
392
+ export declare const enum DirectiveRegistryValuesIndex {
393
+ DirectiveValueOffset = 0,
394
+ SinglePropValuesIndexOffset = 1,
395
+ DirtyFlagOffset = 2,
396
+ StyleSanitizerOffset = 3,
397
+ Size = 4
398
+ }
399
+ /**
400
+ * An array that contains the index pointer values for every single styling property
401
+ * that exists in the context and for every directive. It also contains the total
402
+ * single styles and single classes that exists in the context as the first two values.
403
+ *
404
+ * Let's say we have the following template code:
405
+ *
406
+ * <div [style.width]="myWidth"
407
+ * [style.height]="myHeight"
408
+ * [class.flipped]="flipClass"
409
+ * directive-with-opacity>
410
+ * directive-with-foo-bar-classes>
411
+ *
412
+ * We have two directive and template-binding sources,
413
+ * 2 + 1 styles and 1 + 1 classes. When the bindings are
414
+ * registered the SinglePropOffsets array will look like so:
415
+ *
416
+ * s_0/c_0 = template directive value
417
+ * s_1/c_1 = directive one (directive-with-opacity)
418
+ * s_2/c_2 = directive two (directive-with-foo-bar-classes)
419
+ *
420
+ * [3, 2, 2, 1, s_00, s01, c_01, 1, 0, s_10, 0, 1, c_20
421
+ */
422
+ export interface SinglePropOffsetValues extends Array<number> {
423
+ [SinglePropOffsetValuesIndex.StylesCountPosition]: number;
424
+ [SinglePropOffsetValuesIndex.ClassesCountPosition]: number;
425
+ }
426
+ /**
427
+ * An enum that outlines the offset/position values for each single prop/class entry
428
+ * that are housed inside of [SinglePropOffsetValues].
429
+ */
430
+ export declare const enum SinglePropOffsetValuesIndex {
431
+ StylesCountPosition = 0,
432
+ ClassesCountPosition = 1,
433
+ ValueStartPosition = 2
434
+ }
174
435
  /**
175
436
  * Used to set the context to be dirty or not both on the master flag (position 1)
176
437
  * or for each single/multi property that exists in the context.
@@ -182,20 +443,22 @@ export declare const enum StylingFlags {
182
443
  Sanitize = 4,
183
444
  PlayerBuildersDirty = 8,
184
445
  OnlyProcessSingleClasses = 16,
185
- BitCountSize = 5,
186
- BitMask = 31
446
+ BindingAllocationLocked = 32,
447
+ BitCountSize = 6,
448
+ BitMask = 63
187
449
  }
188
450
  /** Used as numeric pointer values to determine what cells to update in the `StylingContext` */
189
451
  export declare const enum StylingIndex {
190
- PlayerContext = 0,
191
- StyleSanitizerPosition = 1,
192
- InitialStylesPosition = 2,
193
- MasterFlagPosition = 3,
194
- ClassOffsetPosition = 4,
452
+ MasterFlagPosition = 0,
453
+ DirectiveRegistryPosition = 1,
454
+ InitialStyleValuesPosition = 2,
455
+ InitialClassValuesPosition = 3,
456
+ SinglePropOffsetPositions = 4,
195
457
  ElementPosition = 5,
196
- PreviousOrCachedMultiClassValue = 6,
197
- PreviousMultiStyleValue = 7,
198
- SingleStylesStartPosition = 8,
458
+ CachedClassValueOrInitialClassString = 6,
459
+ CachedStyleValue = 7,
460
+ PlayerContext = 8,
461
+ SingleStylesStartPosition = 9,
199
462
  FlagsOffset = 0,
200
463
  PropertyOffset = 1,
201
464
  ValueOffset = 2,
@@ -204,3 +467,15 @@ export declare const enum StylingIndex {
204
467
  BitCountSize = 14,
205
468
  BitMask = 16383
206
469
  }
470
+ /**
471
+ * An enum that outlines the bit flag data for directive owner and player index
472
+ * values that exist within en entry that lives in the StylingContext.
473
+ *
474
+ * The values here split a number value into two sets of bits:
475
+ * - The first 16 bits are used to store the directiveIndex that owns this style value
476
+ * - The other 16 bits are used to store the playerBuilderIndex that is attached to this style
477
+ */
478
+ export declare const enum DirectiveOwnerAndPlayerBuilderIndex {
479
+ BitCountSize = 16,
480
+ BitMask = 65535
481
+ }
@@ -190,12 +190,20 @@ export declare const enum LViewFlags {
190
190
  * improperly reported as false.
191
191
  */
192
192
  CreationMode = 1,
193
+ /**
194
+ * Whether or not this LView instance is on its first processing pass.
195
+ *
196
+ * An LView instance is considered to be on its "first pass" until it
197
+ * has completed one creation mode run and one update mode run. At this
198
+ * time, the flag is turned off.
199
+ */
200
+ FirstLViewPass = 2,
193
201
  /** Whether this view has default change detection strategy (checks always) or onPush */
194
- CheckAlways = 2,
202
+ CheckAlways = 4,
195
203
  /** Whether or not this view is currently dirty (needing check) */
196
- Dirty = 4,
204
+ Dirty = 8,
197
205
  /** Whether or not this view is currently attached to change detection tree. */
198
- Attached = 8,
206
+ Attached = 16,
199
207
  /**
200
208
  * Whether or not the init hooks have run.
201
209
  *
@@ -203,11 +211,11 @@ export declare const enum LViewFlags {
203
211
  * runs OR the first cR() instruction that runs (so inits are run for the top level view before
204
212
  * any embedded views).
205
213
  */
206
- RunInit = 16,
214
+ RunInit = 32,
207
215
  /** Whether or not this view is destroyed. */
208
- Destroyed = 32,
216
+ Destroyed = 64,
209
217
  /** Whether or not this view is the root view */
210
- IsRoot = 64
218
+ IsRoot = 128
211
219
  }
212
220
  /**
213
221
  * The static data for an LView (shared between all templates of a
@@ -124,8 +124,10 @@ export interface R3ComponentMetadataFacade extends R3DirectiveMetadataFacade {
124
124
  encapsulation: ViewEncapsulation;
125
125
  viewProviders: Provider[] | null;
126
126
  interpolation?: [string, string];
127
+ changeDetection?: ChangeDetectionStrategy;
127
128
  }
128
129
  export declare type ViewEncapsulation = number;
130
+ export declare type ChangeDetectionStrategy = number;
129
131
  export interface R3QueryMetadataFacade {
130
132
  propertyName: string;
131
133
  first: boolean;
@@ -22,13 +22,6 @@ export declare function getLContainer(tNode: TViewNode, embeddedView: LView): LC
22
22
  * Might be null if a view is not yet attached to any container.
23
23
  */
24
24
  export declare function getContainerRenderParent(tViewNode: TViewNode, view: LView): RElement | null;
25
- /**
26
- * Given a current view, finds the nearest component's host (LElement).
27
- *
28
- * @param lView LView for which we want a host element node
29
- * @returns The host node
30
- */
31
- export declare function findComponentView(lView: LView): LView;
32
25
  export declare function createTextNode(value: any, renderer: Renderer3): RText;
33
26
  /**
34
27
  * Adds or removes all DOM elements associated with a view.