@angular/core 2.2.0-rc.0 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/bundles/core-testing.umd.js +44 -11
  2. package/bundles/core.umd.js +560 -513
  3. package/bundles/core.umd.min.js +8 -8
  4. package/package.json +1 -1
  5. package/src/animation/animation_group_player.d.ts +3 -1
  6. package/src/animation/animation_group_player.js +18 -7
  7. package/src/animation/animation_group_player.js.map +1 -1
  8. package/src/animation/animation_player.d.ts +1 -1
  9. package/src/animation/animation_player.js +1 -1
  10. package/src/animation/animation_player.js.map +1 -1
  11. package/src/animation/animation_queue.js +8 -0
  12. package/src/animation/animation_queue.js.map +1 -1
  13. package/src/animation/animation_sequence_player.d.ts +3 -1
  14. package/src/animation/animation_sequence_player.js +20 -8
  15. package/src/animation/animation_sequence_player.js.map +1 -1
  16. package/src/animation/animation_style_util.js +1 -0
  17. package/src/animation/animation_style_util.js.map +1 -1
  18. package/src/animation/animation_style_util.metadata.json +1 -1
  19. package/src/animation/metadata.js.map +1 -1
  20. package/src/animation/view_animation_map.js.map +1 -1
  21. package/src/change_detection/constants.d.ts +1 -1
  22. package/src/change_detection/constants.js +1 -1
  23. package/src/change_detection/constants.js.map +1 -1
  24. package/src/change_detection/differs/default_iterable_differ.js +2 -2
  25. package/src/change_detection/differs/default_iterable_differ.js.map +1 -1
  26. package/src/change_detection/differs/default_keyvalue_differ.js.map +1 -1
  27. package/src/change_detection/differs/iterable_differs.js.map +1 -1
  28. package/src/change_detection/differs/keyvalue_differs.js.map +1 -1
  29. package/src/core_private_export.d.ts +8 -3
  30. package/src/core_private_export.js +6 -2
  31. package/src/core_private_export.js.map +1 -1
  32. package/src/core_private_export.metadata.json +1 -1
  33. package/src/debug/debug_node.js +12 -24
  34. package/src/debug/debug_node.js.map +1 -1
  35. package/src/debug/debug_node.metadata.json +1 -1
  36. package/src/debug/debug_renderer.d.ts +2 -2
  37. package/src/debug/debug_renderer.js +7 -5
  38. package/src/debug/debug_renderer.js.map +1 -1
  39. package/src/di/reflective_errors.js.map +1 -1
  40. package/src/di/reflective_injector.js.map +1 -1
  41. package/src/di/reflective_key.js.map +1 -1
  42. package/src/di/reflective_provider.js +13 -14
  43. package/src/di/reflective_provider.js.map +1 -1
  44. package/src/facade/collection.d.ts +2 -10
  45. package/src/facade/collection.js +8 -73
  46. package/src/facade/collection.js.map +1 -1
  47. package/src/facade/lang.d.ts +0 -1
  48. package/src/facade/lang.js +5 -24
  49. package/src/facade/lang.js.map +1 -1
  50. package/src/facade/lang.metadata.json +1 -1
  51. package/src/linker/animation_view_context.d.ts +1 -1
  52. package/src/linker/animation_view_context.js +16 -5
  53. package/src/linker/animation_view_context.js.map +1 -1
  54. package/src/linker/component_factory.d.ts +8 -6
  55. package/src/linker/component_factory.js +17 -23
  56. package/src/linker/component_factory.js.map +1 -1
  57. package/src/linker/component_factory_resolver.js.map +1 -1
  58. package/src/linker/debug_context.js +6 -9
  59. package/src/linker/debug_context.js.map +1 -1
  60. package/src/linker/element_injector.js +1 -8
  61. package/src/linker/element_injector.js.map +1 -1
  62. package/src/linker/ng_module_factory.js.map +1 -1
  63. package/src/linker/ng_module_factory_loader.js.map +1 -1
  64. package/src/linker/system_js_ng_module_factory_loader.js +2 -1
  65. package/src/linker/system_js_ng_module_factory_loader.js.map +1 -1
  66. package/src/linker/template_ref.d.ts +5 -4
  67. package/src/linker/template_ref.js +8 -6
  68. package/src/linker/template_ref.js.map +1 -1
  69. package/src/linker/view.d.ts +29 -17
  70. package/src/linker/view.js +143 -51
  71. package/src/linker/view.js.map +1 -1
  72. package/src/linker/{element.d.ts → view_container.d.ts} +4 -7
  73. package/src/linker/{element.js → view_container.js} +45 -50
  74. package/src/linker/view_container.js.map +1 -0
  75. package/src/linker/view_container_ref.d.ts +2 -2
  76. package/src/linker/view_container_ref.js.map +1 -1
  77. package/src/linker/view_utils.d.ts +6 -10
  78. package/src/linker/view_utils.js +17 -14
  79. package/src/linker/view_utils.js.map +1 -1
  80. package/src/linker/view_utils.metadata.json +1 -1
  81. package/src/profile/wtf_impl.js.map +1 -1
  82. package/src/reflection/reflection_capabilities.js +5 -2
  83. package/src/reflection/reflection_capabilities.js.map +1 -1
  84. package/src/render/api.d.ts +8 -1
  85. package/src/render/api.js.map +1 -1
  86. package/src/testability/testability.js +2 -3
  87. package/src/testability/testability.js.map +1 -1
  88. package/src/util/decorators.js.map +1 -1
  89. package/testing/async.js.map +1 -1
  90. package/testing/facade/lang.d.ts +0 -1
  91. package/testing/facade/lang.js +5 -24
  92. package/testing/facade/lang.js.map +1 -1
  93. package/testing/facade/lang.metadata.json +1 -1
  94. package/testing/fake_async.js.map +1 -1
  95. package/testing/mock_animation_player.d.ts +16 -1
  96. package/testing/mock_animation_player.js +43 -14
  97. package/testing/mock_animation_player.js.map +1 -1
  98. package/testing/test_bed.js.map +1 -1
  99. package/testing/testing.js.map +1 -1
  100. package/src/linker/element.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v0.0.0-PLACEHOLDER
2
+ * @license Angular v2.2.3
3
3
  * (c) 2010-2016 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -54,7 +54,7 @@
54
54
  if (typeof token === 'string') {
55
55
  return token;
56
56
  }
57
- if (token === undefined || token === null) {
57
+ if (token == null) {
58
58
  return '' + token;
59
59
  }
60
60
  if (token.overriddenName) {
@@ -640,7 +640,7 @@
640
640
  var ChangeDetectorStatus;
641
641
  (function (ChangeDetectorStatus) {
642
642
  /**
643
- * `CheckedOnce` means that after calling detectChanges the mode of the change detector
643
+ * `CheckOnce` means that after calling detectChanges the mode of the change detector
644
644
  * will become `Checked`.
645
645
  */
646
646
  ChangeDetectorStatus[ChangeDetectorStatus["CheckOnce"] = 0] = "CheckOnce";
@@ -1539,177 +1539,6 @@
1539
1539
  }());
1540
1540
  var _globalKeyRegistry = new KeyRegistry();
1541
1541
 
1542
- // Safari doesn't implement MapIterator.next(), which is used is Traceur's polyfill of Array.from
1543
- // TODO(mlaval): remove the work around once we have a working polyfill of Array.from
1544
- var _arrayFromMap = (function () {
1545
- try {
1546
- if ((new Map()).values().next) {
1547
- return function createArrayFromMap(m, getValues) {
1548
- return getValues ? Array.from(m.values()) : Array.from(m.keys());
1549
- };
1550
- }
1551
- }
1552
- catch (e) {
1553
- }
1554
- return function createArrayFromMapWithForeach(m, getValues) {
1555
- var res = new Array(m.size), i = 0;
1556
- m.forEach(function (v, k) {
1557
- res[i] = getValues ? v : k;
1558
- i++;
1559
- });
1560
- return res;
1561
- };
1562
- })();
1563
- var MapWrapper = (function () {
1564
- function MapWrapper() {
1565
- }
1566
- MapWrapper.createFromStringMap = function (stringMap) {
1567
- var result = new Map();
1568
- for (var prop in stringMap) {
1569
- result.set(prop, stringMap[prop]);
1570
- }
1571
- return result;
1572
- };
1573
- MapWrapper.keys = function (m) { return _arrayFromMap(m, false); };
1574
- MapWrapper.values = function (m) { return _arrayFromMap(m, true); };
1575
- return MapWrapper;
1576
- }());
1577
- /**
1578
- * Wraps Javascript Objects
1579
- */
1580
- var StringMapWrapper = (function () {
1581
- function StringMapWrapper() {
1582
- }
1583
- StringMapWrapper.merge = function (m1, m2) {
1584
- var m = {};
1585
- for (var _i = 0, _a = Object.keys(m1); _i < _a.length; _i++) {
1586
- var k = _a[_i];
1587
- m[k] = m1[k];
1588
- }
1589
- for (var _b = 0, _c = Object.keys(m2); _b < _c.length; _b++) {
1590
- var k = _c[_b];
1591
- m[k] = m2[k];
1592
- }
1593
- return m;
1594
- };
1595
- StringMapWrapper.equals = function (m1, m2) {
1596
- var k1 = Object.keys(m1);
1597
- var k2 = Object.keys(m2);
1598
- if (k1.length != k2.length) {
1599
- return false;
1600
- }
1601
- for (var i = 0; i < k1.length; i++) {
1602
- var key = k1[i];
1603
- if (m1[key] !== m2[key]) {
1604
- return false;
1605
- }
1606
- }
1607
- return true;
1608
- };
1609
- return StringMapWrapper;
1610
- }());
1611
- var ListWrapper = (function () {
1612
- function ListWrapper() {
1613
- }
1614
- ListWrapper.removeAll = function (list, items) {
1615
- for (var i = 0; i < items.length; ++i) {
1616
- var index = list.indexOf(items[i]);
1617
- list.splice(index, 1);
1618
- }
1619
- };
1620
- ListWrapper.remove = function (list, el) {
1621
- var index = list.indexOf(el);
1622
- if (index > -1) {
1623
- list.splice(index, 1);
1624
- return true;
1625
- }
1626
- return false;
1627
- };
1628
- ListWrapper.equals = function (a, b) {
1629
- if (a.length != b.length)
1630
- return false;
1631
- for (var i = 0; i < a.length; ++i) {
1632
- if (a[i] !== b[i])
1633
- return false;
1634
- }
1635
- return true;
1636
- };
1637
- ListWrapper.maximum = function (list, predicate) {
1638
- if (list.length == 0) {
1639
- return null;
1640
- }
1641
- var solution = null;
1642
- var maxValue = -Infinity;
1643
- for (var index = 0; index < list.length; index++) {
1644
- var candidate = list[index];
1645
- if (candidate == null) {
1646
- continue;
1647
- }
1648
- var candidateValue = predicate(candidate);
1649
- if (candidateValue > maxValue) {
1650
- solution = candidate;
1651
- maxValue = candidateValue;
1652
- }
1653
- }
1654
- return solution;
1655
- };
1656
- ListWrapper.flatten = function (list) {
1657
- var target = [];
1658
- _flattenArray(list, target);
1659
- return target;
1660
- };
1661
- return ListWrapper;
1662
- }());
1663
- function _flattenArray(source, target) {
1664
- if (isPresent(source)) {
1665
- for (var i = 0; i < source.length; i++) {
1666
- var item = source[i];
1667
- if (Array.isArray(item)) {
1668
- _flattenArray(item, target);
1669
- }
1670
- else {
1671
- target.push(item);
1672
- }
1673
- }
1674
- }
1675
- return target;
1676
- }
1677
- function isListLikeIterable(obj) {
1678
- if (!isJsObject(obj))
1679
- return false;
1680
- return Array.isArray(obj) ||
1681
- (!(obj instanceof Map) &&
1682
- getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
1683
- }
1684
- function areIterablesEqual(a, b, comparator) {
1685
- var iterator1 = a[getSymbolIterator()]();
1686
- var iterator2 = b[getSymbolIterator()]();
1687
- while (true) {
1688
- var item1 = iterator1.next();
1689
- var item2 = iterator2.next();
1690
- if (item1.done && item2.done)
1691
- return true;
1692
- if (item1.done || item2.done)
1693
- return false;
1694
- if (!comparator(item1.value, item2.value))
1695
- return false;
1696
- }
1697
- }
1698
- function iterateListLike(obj, fn) {
1699
- if (Array.isArray(obj)) {
1700
- for (var i = 0; i < obj.length; i++) {
1701
- fn(obj[i]);
1702
- }
1703
- }
1704
- else {
1705
- var iterator = obj[getSymbolIterator()]();
1706
- var item = void 0;
1707
- while (!((item = iterator.next()).done)) {
1708
- fn(item.value);
1709
- }
1710
- }
1711
- }
1712
-
1713
1542
  /**
1714
1543
  * @license
1715
1544
  * Copyright Google Inc. All Rights Reserved.
@@ -1775,8 +1604,11 @@
1775
1604
  return type.parameters;
1776
1605
  }
1777
1606
  // API of tsickle for lowering decorators to properties on the class.
1778
- if (type.ctorParameters) {
1779
- var ctorParameters = type.ctorParameters;
1607
+ var tsickleCtorParams = type.ctorParameters;
1608
+ if (tsickleCtorParams) {
1609
+ // Newer tsickle uses a function closure
1610
+ // Retain the non-function case for compatibility with older tsickle
1611
+ var ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
1780
1612
  var paramTypes = ctorParameters.map(function (ctorParam) { return ctorParam && ctorParam.type; });
1781
1613
  var paramAnnotations = ctorParameters.map(function (ctorParam) {
1782
1614
  return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators);
@@ -2006,16 +1838,16 @@
2006
1838
  function resolveReflectiveFactory(provider) {
2007
1839
  var factoryFn;
2008
1840
  var resolvedDeps;
2009
- if (isPresent(provider.useClass)) {
1841
+ if (provider.useClass) {
2010
1842
  var useClass = resolveForwardRef(provider.useClass);
2011
1843
  factoryFn = reflector.factory(useClass);
2012
1844
  resolvedDeps = _dependenciesFor(useClass);
2013
1845
  }
2014
- else if (isPresent(provider.useExisting)) {
1846
+ else if (provider.useExisting) {
2015
1847
  factoryFn = function (aliasInstance) { return aliasInstance; };
2016
1848
  resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
2017
1849
  }
2018
- else if (isPresent(provider.useFactory)) {
1850
+ else if (provider.useFactory) {
2019
1851
  factoryFn = provider.useFactory;
2020
1852
  resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
2021
1853
  }
@@ -2040,7 +1872,8 @@
2040
1872
  function resolveReflectiveProviders(providers) {
2041
1873
  var normalized = _normalizeProviders(providers, []);
2042
1874
  var resolved = normalized.map(resolveReflectiveProvider);
2043
- return MapWrapper.values(mergeResolvedReflectiveProviders(resolved, new Map()));
1875
+ var resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
1876
+ return Array.from(resolvedProviderMap.values());
2044
1877
  }
2045
1878
  /**
2046
1879
  * Merges a list of ResolvedProviders into a list where
@@ -2051,7 +1884,7 @@
2051
1884
  for (var i = 0; i < providers.length; i++) {
2052
1885
  var provider = providers[i];
2053
1886
  var existing = normalizedProvidersMap.get(provider.key.id);
2054
- if (isPresent(existing)) {
1887
+ if (existing) {
2055
1888
  if (provider.multiProvider !== existing.multiProvider) {
2056
1889
  throw new MixingMultiProvidersWithRegularProvidersError(existing, provider);
2057
1890
  }
@@ -2065,7 +1898,7 @@
2065
1898
  }
2066
1899
  }
2067
1900
  else {
2068
- var resolvedProvider;
1901
+ var resolvedProvider = void 0;
2069
1902
  if (provider.multiProvider) {
2070
1903
  resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
2071
1904
  }
@@ -2099,20 +1932,20 @@
2099
1932
  return _dependenciesFor(typeOrFunc);
2100
1933
  }
2101
1934
  else {
2102
- var params = dependencies.map(function (t) { return [t]; });
2103
- return dependencies.map(function (t) { return _extractToken(typeOrFunc, t, params); });
1935
+ var params_1 = dependencies.map(function (t) { return [t]; });
1936
+ return dependencies.map(function (t) { return _extractToken(typeOrFunc, t, params_1); });
2104
1937
  }
2105
1938
  }
2106
1939
  function _dependenciesFor(typeOrFunc) {
2107
1940
  var params = reflector.parameters(typeOrFunc);
2108
1941
  if (!params)
2109
1942
  return [];
2110
- if (params.some(isBlank)) {
1943
+ if (params.some(function (p) { return p == null; })) {
2111
1944
  throw new NoAnnotationError(typeOrFunc, params);
2112
1945
  }
2113
1946
  return params.map(function (p) { return _extractToken(typeOrFunc, p, params); });
2114
1947
  }
2115
- function _extractToken(typeOrFunc /** TODO #9100 */, metadata /** TODO #9100 */ /*any[] | any*/, params) {
1948
+ function _extractToken(typeOrFunc, metadata, params) {
2116
1949
  var depProps = [];
2117
1950
  var token = null;
2118
1951
  var optional = false;
@@ -2148,14 +1981,14 @@
2148
1981
  }
2149
1982
  }
2150
1983
  token = resolveForwardRef(token);
2151
- if (isPresent(token)) {
1984
+ if (token != null) {
2152
1985
  return _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps);
2153
1986
  }
2154
1987
  else {
2155
1988
  throw new NoAnnotationError(typeOrFunc, params);
2156
1989
  }
2157
1990
  }
2158
- function _createDependency(token /** TODO #9100 */, optional /** TODO #9100 */, lowerBoundVisibility /** TODO #9100 */, upperBoundVisibility /** TODO #9100 */, depProps /** TODO #9100 */) {
1991
+ function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps) {
2159
1992
  return new ReflectiveDependency(ReflectiveKey.get(token), optional, lowerBoundVisibility, upperBoundVisibility, depProps);
2160
1993
  }
2161
1994
 
@@ -3055,6 +2888,112 @@
3055
2888
  return ErrorHandler;
3056
2889
  }());
3057
2890
 
2891
+ /**
2892
+ * Wraps Javascript Objects
2893
+ */
2894
+ var StringMapWrapper = (function () {
2895
+ function StringMapWrapper() {
2896
+ }
2897
+ StringMapWrapper.merge = function (m1, m2) {
2898
+ var m = {};
2899
+ for (var _i = 0, _a = Object.keys(m1); _i < _a.length; _i++) {
2900
+ var k = _a[_i];
2901
+ m[k] = m1[k];
2902
+ }
2903
+ for (var _b = 0, _c = Object.keys(m2); _b < _c.length; _b++) {
2904
+ var k = _c[_b];
2905
+ m[k] = m2[k];
2906
+ }
2907
+ return m;
2908
+ };
2909
+ StringMapWrapper.equals = function (m1, m2) {
2910
+ var k1 = Object.keys(m1);
2911
+ var k2 = Object.keys(m2);
2912
+ if (k1.length != k2.length) {
2913
+ return false;
2914
+ }
2915
+ for (var i = 0; i < k1.length; i++) {
2916
+ var key = k1[i];
2917
+ if (m1[key] !== m2[key]) {
2918
+ return false;
2919
+ }
2920
+ }
2921
+ return true;
2922
+ };
2923
+ return StringMapWrapper;
2924
+ }());
2925
+ var ListWrapper = (function () {
2926
+ function ListWrapper() {
2927
+ }
2928
+ ListWrapper.removeAll = function (list, items) {
2929
+ for (var i = 0; i < items.length; ++i) {
2930
+ var index = list.indexOf(items[i]);
2931
+ if (index > -1) {
2932
+ list.splice(index, 1);
2933
+ }
2934
+ }
2935
+ };
2936
+ ListWrapper.remove = function (list, el) {
2937
+ var index = list.indexOf(el);
2938
+ if (index > -1) {
2939
+ list.splice(index, 1);
2940
+ return true;
2941
+ }
2942
+ return false;
2943
+ };
2944
+ ListWrapper.equals = function (a, b) {
2945
+ if (a.length != b.length)
2946
+ return false;
2947
+ for (var i = 0; i < a.length; ++i) {
2948
+ if (a[i] !== b[i])
2949
+ return false;
2950
+ }
2951
+ return true;
2952
+ };
2953
+ ListWrapper.flatten = function (list) {
2954
+ return list.reduce(function (flat, item) {
2955
+ var flatItem = Array.isArray(item) ? ListWrapper.flatten(item) : item;
2956
+ return flat.concat(flatItem);
2957
+ }, []);
2958
+ };
2959
+ return ListWrapper;
2960
+ }());
2961
+ function isListLikeIterable(obj) {
2962
+ if (!isJsObject(obj))
2963
+ return false;
2964
+ return Array.isArray(obj) ||
2965
+ (!(obj instanceof Map) &&
2966
+ getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
2967
+ }
2968
+ function areIterablesEqual(a, b, comparator) {
2969
+ var iterator1 = a[getSymbolIterator()]();
2970
+ var iterator2 = b[getSymbolIterator()]();
2971
+ while (true) {
2972
+ var item1 = iterator1.next();
2973
+ var item2 = iterator2.next();
2974
+ if (item1.done && item2.done)
2975
+ return true;
2976
+ if (item1.done || item2.done)
2977
+ return false;
2978
+ if (!comparator(item1.value, item2.value))
2979
+ return false;
2980
+ }
2981
+ }
2982
+ function iterateListLike(obj, fn) {
2983
+ if (Array.isArray(obj)) {
2984
+ for (var i = 0; i < obj.length; i++) {
2985
+ fn(obj[i]);
2986
+ }
2987
+ }
2988
+ else {
2989
+ var iterator = obj[getSymbolIterator()]();
2990
+ var item = void 0;
2991
+ while (!((item = iterator.next()).done)) {
2992
+ fn(item.value);
2993
+ }
2994
+ }
2995
+ }
2996
+
3058
2997
  /**
3059
2998
  * @license
3060
2999
  * Copyright Google Inc. All Rights Reserved.
@@ -3278,6 +3217,35 @@
3278
3217
  return CompilerFactory;
3279
3218
  }());
3280
3219
 
3220
+ /**
3221
+ * @license
3222
+ * Copyright Google Inc. All Rights Reserved.
3223
+ *
3224
+ * Use of this source code is governed by an MIT-style license that can be
3225
+ * found in the LICENSE file at https://angular.io/license
3226
+ */
3227
+ /**
3228
+ * A wrapper around a native element inside of a View.
3229
+ *
3230
+ * An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM
3231
+ * element.
3232
+ *
3233
+ * @security Permitting direct access to the DOM can make your application more vulnerable to
3234
+ * XSS attacks. Carefully review any use of `ElementRef` in your code. For more detail, see the
3235
+ * [Security Guide](http://g.co/ng/security).
3236
+ *
3237
+ * @stable
3238
+ */
3239
+ // Note: We don't expose things like `Injector`, `ViewContainer`, ... here,
3240
+ // i.e. users have to ask for what they need. With that, we can build better analysis tools
3241
+ // and could do better codegen in the future.
3242
+ var ElementRef = (function () {
3243
+ function ElementRef(nativeElement) {
3244
+ this.nativeElement = nativeElement;
3245
+ }
3246
+ return ElementRef;
3247
+ }());
3248
+
3281
3249
  var DefaultIterableDifferFactory = (function () {
3282
3250
  function DefaultIterableDifferFactory() {
3283
3251
  }
@@ -3499,8 +3467,8 @@
3499
3467
  */
3500
3468
  DefaultIterableDiffer.prototype._reset = function () {
3501
3469
  if (this.isDirty) {
3502
- var record;
3503
- var nextRecord;
3470
+ var record = void 0;
3471
+ var nextRecord = void 0;
3504
3472
  for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
3505
3473
  record._nextPrevious = record._next;
3506
3474
  }
@@ -4713,19 +4681,11 @@
4713
4681
  }(BaseError));
4714
4682
 
4715
4683
  var ViewUtils = (function () {
4716
- function ViewUtils(_renderer, _appId, sanitizer) {
4684
+ function ViewUtils(_renderer, sanitizer) {
4717
4685
  this._renderer = _renderer;
4718
- this._appId = _appId;
4719
4686
  this._nextCompTypeId = 0;
4720
4687
  this.sanitizer = sanitizer;
4721
4688
  }
4722
- /**
4723
- * Used by the generated code
4724
- */
4725
- // TODO (matsko): add typing for the animation function
4726
- ViewUtils.prototype.createRenderComponentType = function (templateUrl, slotCount, encapsulation, styles, animations) {
4727
- return new RenderComponentType(this._appId + "-" + this._nextCompTypeId++, templateUrl, slotCount, encapsulation, styles, animations);
4728
- };
4729
4689
  /** @internal */
4730
4690
  ViewUtils.prototype.renderComponent = function (renderComponentType) {
4731
4691
  return this._renderer.renderComponent(renderComponentType);
@@ -4736,16 +4696,25 @@
4736
4696
  /** @nocollapse */
4737
4697
  ViewUtils.ctorParameters = [
4738
4698
  { type: RootRenderer, },
4739
- { type: undefined, decorators: [{ type: Inject, args: [APP_ID,] },] },
4740
4699
  { type: Sanitizer, },
4741
4700
  ];
4742
4701
  return ViewUtils;
4743
4702
  }());
4703
+ var nextRenderComponentTypeId = 0;
4704
+ function createRenderComponentType(templateUrl, slotCount, encapsulation, styles, animations) {
4705
+ return new RenderComponentType("" + nextRenderComponentTypeId++, templateUrl, slotCount, encapsulation, styles, animations);
4706
+ }
4744
4707
  function addToArray(e, array) {
4745
4708
  array.push(e);
4746
4709
  }
4747
- var MAX_INTERPOLATION_VALUES = 9;
4748
- function interpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
4710
+ function interpolate(valueCount, constAndInterp) {
4711
+ var result = '';
4712
+ for (var i = 0; i < valueCount * 2; i = i + 2) {
4713
+ result = result + constAndInterp[i] + _toStringWithNull(constAndInterp[i + 1]);
4714
+ }
4715
+ return result + constAndInterp[valueCount * 2];
4716
+ }
4717
+ function inlineInterpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
4749
4718
  switch (valueCount) {
4750
4719
  case 1:
4751
4720
  return c0 + _toStringWithNull(a1) + c1;
@@ -5009,6 +4978,9 @@
5009
4978
  var hostElement;
5010
4979
  if (isPresent(rootSelectorOrNode)) {
5011
4980
  hostElement = renderer.selectRootElement(rootSelectorOrNode, debugInfo);
4981
+ for (var i = 0; i < attrs.length; i += 2) {
4982
+ renderer.setElementAttribute(hostElement, attrs.get(i), attrs.get(i + 1));
4983
+ }
5012
4984
  }
5013
4985
  else {
5014
4986
  hostElement = createRenderElement(renderer, null, elementName, attrs, debugInfo);
@@ -5328,9 +5300,10 @@
5328
5300
 
5329
5301
  var view_utils = Object.freeze({
5330
5302
  ViewUtils: ViewUtils,
5303
+ createRenderComponentType: createRenderComponentType,
5331
5304
  addToArray: addToArray,
5332
- MAX_INTERPOLATION_VALUES: MAX_INTERPOLATION_VALUES,
5333
5305
  interpolate: interpolate,
5306
+ inlineInterpolate: inlineInterpolate,
5334
5307
  checkBinding: checkBinding,
5335
5308
  castByValue: castByValue,
5336
5309
  EMPTY_ARRAY: EMPTY_ARRAY,
@@ -5436,59 +5409,57 @@
5436
5409
  }());
5437
5410
  var ComponentRef_ = (function (_super) {
5438
5411
  __extends$5(ComponentRef_, _super);
5439
- function ComponentRef_(_hostElement, _componentType) {
5412
+ function ComponentRef_(_index, _parentView, _nativeElement, _component) {
5440
5413
  _super.call(this);
5441
- this._hostElement = _hostElement;
5442
- this._componentType = _componentType;
5414
+ this._index = _index;
5415
+ this._parentView = _parentView;
5416
+ this._nativeElement = _nativeElement;
5417
+ this._component = _component;
5443
5418
  }
5444
5419
  Object.defineProperty(ComponentRef_.prototype, "location", {
5445
- get: function () { return this._hostElement.elementRef; },
5420
+ get: function () { return new ElementRef(this._nativeElement); },
5446
5421
  enumerable: true,
5447
5422
  configurable: true
5448
5423
  });
5449
5424
  Object.defineProperty(ComponentRef_.prototype, "injector", {
5450
- get: function () { return this._hostElement.injector; },
5425
+ get: function () { return this._parentView.injector(this._index); },
5451
5426
  enumerable: true,
5452
5427
  configurable: true
5453
5428
  });
5454
5429
  Object.defineProperty(ComponentRef_.prototype, "instance", {
5455
- get: function () { return this._hostElement.component; },
5430
+ get: function () { return this._component; },
5456
5431
  enumerable: true,
5457
5432
  configurable: true
5458
5433
  });
5459
5434
  ;
5460
5435
  Object.defineProperty(ComponentRef_.prototype, "hostView", {
5461
- get: function () { return this._hostElement.parentView.ref; },
5436
+ get: function () { return this._parentView.ref; },
5462
5437
  enumerable: true,
5463
5438
  configurable: true
5464
5439
  });
5465
5440
  ;
5466
5441
  Object.defineProperty(ComponentRef_.prototype, "changeDetectorRef", {
5467
- get: function () { return this._hostElement.parentView.ref; },
5442
+ get: function () { return this._parentView.ref; },
5468
5443
  enumerable: true,
5469
5444
  configurable: true
5470
5445
  });
5471
5446
  ;
5472
5447
  Object.defineProperty(ComponentRef_.prototype, "componentType", {
5473
- get: function () { return this._componentType; },
5448
+ get: function () { return this._component.constructor; },
5474
5449
  enumerable: true,
5475
5450
  configurable: true
5476
5451
  });
5477
- ComponentRef_.prototype.destroy = function () { this._hostElement.parentView.detachAndDestroy(); };
5452
+ ComponentRef_.prototype.destroy = function () { this._parentView.detachAndDestroy(); };
5478
5453
  ComponentRef_.prototype.onDestroy = function (callback) { this.hostView.onDestroy(callback); };
5479
5454
  return ComponentRef_;
5480
5455
  }(ComponentRef));
5481
- /**
5482
- * @experimental
5483
- */
5484
- var EMPTY_CONTEXT = new Object();
5485
5456
  /**
5486
5457
  * @stable
5487
5458
  */
5488
5459
  var ComponentFactory = (function () {
5489
- function ComponentFactory(selector, _viewFactory, _componentType) {
5460
+ function ComponentFactory(selector, _viewClass, _componentType) {
5490
5461
  this.selector = selector;
5491
- this._viewFactory = _viewFactory;
5462
+ this._viewClass = _viewClass;
5492
5463
  this._componentType = _componentType;
5493
5464
  }
5494
5465
  Object.defineProperty(ComponentFactory.prototype, "componentType", {
@@ -5506,17 +5477,8 @@
5506
5477
  if (!projectableNodes) {
5507
5478
  projectableNodes = [];
5508
5479
  }
5509
- // Note: Host views don't need a declarationAppElement!
5510
- var hostView = this._viewFactory(vu, injector, null);
5511
- hostView.visitProjectableNodesInternal =
5512
- function (nodeIndex, ngContentIndex, cb, ctx) {
5513
- var nodes = projectableNodes[ngContentIndex] || [];
5514
- for (var i = 0; i < nodes.length; i++) {
5515
- cb(nodes[i], ctx);
5516
- }
5517
- };
5518
- var hostElement = hostView.create(EMPTY_CONTEXT, rootSelectorOrNode);
5519
- return new ComponentRef_(hostElement, this._componentType);
5480
+ var hostView = new this._viewClass(vu, null, null, null);
5481
+ return hostView.createHostView(rootSelectorOrNode, injector, projectableNodes);
5520
5482
  };
5521
5483
  return ComponentFactory;
5522
5484
  }());
@@ -6171,8 +6133,8 @@
6171
6133
  this._applications.set(token, testability);
6172
6134
  };
6173
6135
  TestabilityRegistry.prototype.getTestability = function (elem) { return this._applications.get(elem); };
6174
- TestabilityRegistry.prototype.getAllTestabilities = function () { return MapWrapper.values(this._applications); };
6175
- TestabilityRegistry.prototype.getAllRootElements = function () { return MapWrapper.keys(this._applications); };
6136
+ TestabilityRegistry.prototype.getAllTestabilities = function () { return Array.from(this._applications.values()); };
6137
+ TestabilityRegistry.prototype.getAllRootElements = function () { return Array.from(this._applications.keys()); };
6176
6138
  TestabilityRegistry.prototype.findTestabilityInTree = function (elem, findInAncestors) {
6177
6139
  if (findInAncestors === void 0) { findInAncestors = true; }
6178
6140
  return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
@@ -6666,35 +6628,6 @@
6666
6628
  return ApplicationRef_;
6667
6629
  }(ApplicationRef));
6668
6630
 
6669
- /**
6670
- * @license
6671
- * Copyright Google Inc. All Rights Reserved.
6672
- *
6673
- * Use of this source code is governed by an MIT-style license that can be
6674
- * found in the LICENSE file at https://angular.io/license
6675
- */
6676
- /**
6677
- * A wrapper around a native element inside of a View.
6678
- *
6679
- * An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM
6680
- * element.
6681
- *
6682
- * @security Permitting direct access to the DOM can make your application more vulnerable to
6683
- * XSS attacks. Carefully review any use of `ElementRef` in your code. For more detail, see the
6684
- * [Security Guide](http://g.co/ng/security).
6685
- *
6686
- * @stable
6687
- */
6688
- // Note: We don't expose things like `Injector`, `ViewContainer`, ... here,
6689
- // i.e. users have to ask for what they need. With that, we can build better analysis tools
6690
- // and could do better codegen in the future.
6691
- var ElementRef = (function () {
6692
- function ElementRef(nativeElement) {
6693
- this.nativeElement = nativeElement;
6694
- }
6695
- return ElementRef;
6696
- }());
6697
-
6698
6631
  /**
6699
6632
  * @license
6700
6633
  * Copyright Google Inc. All Rights Reserved.
@@ -6987,8 +6920,9 @@
6987
6920
  SystemJsNgModuleLoader.prototype.loadAndCompile = function (path) {
6988
6921
  var _this = this;
6989
6922
  var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
6990
- if (exportName === undefined)
6923
+ if (exportName === undefined) {
6991
6924
  exportName = 'default';
6925
+ }
6992
6926
  return System.import(module)
6993
6927
  .then(function (module) { return module[exportName]; })
6994
6928
  .then(function (type) { return checkNotEmpty(type, module, exportName); })
@@ -7071,18 +7005,19 @@
7071
7005
  }());
7072
7006
  var TemplateRef_ = (function (_super) {
7073
7007
  __extends$10(TemplateRef_, _super);
7074
- function TemplateRef_(_appElement, _viewFactory) {
7008
+ function TemplateRef_(_parentView, _nodeIndex, _nativeElement) {
7075
7009
  _super.call(this);
7076
- this._appElement = _appElement;
7077
- this._viewFactory = _viewFactory;
7010
+ this._parentView = _parentView;
7011
+ this._nodeIndex = _nodeIndex;
7012
+ this._nativeElement = _nativeElement;
7078
7013
  }
7079
7014
  TemplateRef_.prototype.createEmbeddedView = function (context) {
7080
- var view = this._viewFactory(this._appElement.parentView.viewUtils, this._appElement.parentInjector, this._appElement);
7081
- view.create(context || {}, null);
7015
+ var view = this._parentView.createEmbeddedViewInternal(this._nodeIndex);
7016
+ view.create(context || {});
7082
7017
  return view.ref;
7083
7018
  };
7084
7019
  Object.defineProperty(TemplateRef_.prototype, "elementRef", {
7085
- get: function () { return this._appElement.elementRef; },
7020
+ get: function () { return new ElementRef(this._nativeElement); },
7086
7021
  enumerable: true,
7087
7022
  configurable: true
7088
7023
  });
@@ -7258,6 +7193,14 @@
7258
7193
  }
7259
7194
  /** @internal */
7260
7195
  function triggerQueuedAnimations() {
7196
+ // this code is wrapped into a single promise such that the
7197
+ // onStart and onDone player callbacks are triggered outside
7198
+ // of the digest cycle of animations
7199
+ if (_queuedAnimations.length) {
7200
+ Promise.resolve(null).then(_triggerAnimations);
7201
+ }
7202
+ }
7203
+ function _triggerAnimations() {
7261
7204
  for (var i = 0; i < _queuedAnimations.length; i++) {
7262
7205
  var player = _queuedAnimations[i];
7263
7206
  player.play();
@@ -7436,7 +7379,7 @@
7436
7379
  function DebugNode(nativeNode, parent, _debugInfo) {
7437
7380
  this._debugInfo = _debugInfo;
7438
7381
  this.nativeNode = nativeNode;
7439
- if (isPresent(parent) && parent instanceof DebugElement) {
7382
+ if (parent && parent instanceof DebugElement) {
7440
7383
  parent.addChild(this);
7441
7384
  }
7442
7385
  else {
@@ -7445,38 +7388,34 @@
7445
7388
  this.listeners = [];
7446
7389
  }
7447
7390
  Object.defineProperty(DebugNode.prototype, "injector", {
7448
- get: function () { return isPresent(this._debugInfo) ? this._debugInfo.injector : null; },
7391
+ get: function () { return this._debugInfo ? this._debugInfo.injector : null; },
7449
7392
  enumerable: true,
7450
7393
  configurable: true
7451
7394
  });
7452
7395
  Object.defineProperty(DebugNode.prototype, "componentInstance", {
7453
- get: function () {
7454
- return isPresent(this._debugInfo) ? this._debugInfo.component : null;
7455
- },
7396
+ get: function () { return this._debugInfo ? this._debugInfo.component : null; },
7456
7397
  enumerable: true,
7457
7398
  configurable: true
7458
7399
  });
7459
7400
  Object.defineProperty(DebugNode.prototype, "context", {
7460
- get: function () { return isPresent(this._debugInfo) ? this._debugInfo.context : null; },
7401
+ get: function () { return this._debugInfo ? this._debugInfo.context : null; },
7461
7402
  enumerable: true,
7462
7403
  configurable: true
7463
7404
  });
7464
7405
  Object.defineProperty(DebugNode.prototype, "references", {
7465
7406
  get: function () {
7466
- return isPresent(this._debugInfo) ? this._debugInfo.references : null;
7407
+ return this._debugInfo ? this._debugInfo.references : null;
7467
7408
  },
7468
7409
  enumerable: true,
7469
7410
  configurable: true
7470
7411
  });
7471
7412
  Object.defineProperty(DebugNode.prototype, "providerTokens", {
7472
- get: function () {
7473
- return isPresent(this._debugInfo) ? this._debugInfo.providerTokens : null;
7474
- },
7413
+ get: function () { return this._debugInfo ? this._debugInfo.providerTokens : null; },
7475
7414
  enumerable: true,
7476
7415
  configurable: true
7477
7416
  });
7478
7417
  Object.defineProperty(DebugNode.prototype, "source", {
7479
- get: function () { return isPresent(this._debugInfo) ? this._debugInfo.source : null; },
7418
+ get: function () { return this._debugInfo ? this._debugInfo.source : null; },
7480
7419
  enumerable: true,
7481
7420
  configurable: true
7482
7421
  });
@@ -7497,7 +7436,7 @@
7497
7436
  this.nativeElement = nativeNode;
7498
7437
  }
7499
7438
  DebugElement.prototype.addChild = function (child) {
7500
- if (isPresent(child)) {
7439
+ if (child) {
7501
7440
  this.childNodes.push(child);
7502
7441
  child.parent = this;
7503
7442
  }
@@ -7517,7 +7456,7 @@
7517
7456
  this.childNodes = previousChildren.concat(newChildren, nextChildren);
7518
7457
  for (var i = 0; i < newChildren.length; ++i) {
7519
7458
  var newChild = newChildren[i];
7520
- if (isPresent(newChild.parent)) {
7459
+ if (newChild.parent) {
7521
7460
  newChild.parent.removeChild(newChild);
7522
7461
  }
7523
7462
  newChild.parent = this;
@@ -7526,7 +7465,7 @@
7526
7465
  };
7527
7466
  DebugElement.prototype.query = function (predicate) {
7528
7467
  var results = this.queryAll(predicate);
7529
- return results.length > 0 ? results[0] : null;
7468
+ return results[0] || null;
7530
7469
  };
7531
7470
  DebugElement.prototype.queryAll = function (predicate) {
7532
7471
  var matches = [];
@@ -7540,13 +7479,7 @@
7540
7479
  };
7541
7480
  Object.defineProperty(DebugElement.prototype, "children", {
7542
7481
  get: function () {
7543
- var children = [];
7544
- this.childNodes.forEach(function (node) {
7545
- if (node instanceof DebugElement) {
7546
- children.push(node);
7547
- }
7548
- });
7549
- return children;
7482
+ return this.childNodes.filter(function (node) { return node instanceof DebugElement; });
7550
7483
  },
7551
7484
  enumerable: true,
7552
7485
  configurable: true
@@ -7689,6 +7622,7 @@
7689
7622
  this._onStartFns = [];
7690
7623
  this._finished = false;
7691
7624
  this._started = false;
7625
+ this._destroyed = false;
7692
7626
  this.parentPlayer = null;
7693
7627
  var count = 0;
7694
7628
  var total = this._players.length;
@@ -7709,9 +7643,6 @@
7709
7643
  AnimationGroupPlayer.prototype._onFinish = function () {
7710
7644
  if (!this._finished) {
7711
7645
  this._finished = true;
7712
- if (!isPresent(this.parentPlayer)) {
7713
- this.destroy();
7714
- }
7715
7646
  this._onDoneFns.forEach(function (fn) { return fn(); });
7716
7647
  this._onDoneFns = [];
7717
7648
  }
@@ -7738,11 +7669,19 @@
7738
7669
  this._players.forEach(function (player) { return player.finish(); });
7739
7670
  };
7740
7671
  AnimationGroupPlayer.prototype.destroy = function () {
7741
- this._onFinish();
7742
- this._players.forEach(function (player) { return player.destroy(); });
7672
+ if (!this._destroyed) {
7673
+ this._onFinish();
7674
+ this._players.forEach(function (player) { return player.destroy(); });
7675
+ this._destroyed = true;
7676
+ }
7677
+ };
7678
+ AnimationGroupPlayer.prototype.reset = function () {
7679
+ this._players.forEach(function (player) { return player.reset(); });
7680
+ this._destroyed = false;
7681
+ this._finished = false;
7682
+ this._started = false;
7743
7683
  };
7744
- AnimationGroupPlayer.prototype.reset = function () { this._players.forEach(function (player) { return player.reset(); }); };
7745
- AnimationGroupPlayer.prototype.setPosition = function (p /** TODO #9100 */) {
7684
+ AnimationGroupPlayer.prototype.setPosition = function (p) {
7746
7685
  this._players.forEach(function (player) { player.setPosition(p); });
7747
7686
  };
7748
7687
  AnimationGroupPlayer.prototype.getPosition = function () {
@@ -7753,6 +7692,11 @@
7753
7692
  });
7754
7693
  return min;
7755
7694
  };
7695
+ Object.defineProperty(AnimationGroupPlayer.prototype, "players", {
7696
+ get: function () { return this._players; },
7697
+ enumerable: true,
7698
+ configurable: true
7699
+ });
7756
7700
  return AnimationGroupPlayer;
7757
7701
  }());
7758
7702
 
@@ -7815,7 +7759,7 @@
7815
7759
  NoOpAnimationPlayer.prototype.finish = function () { this._onFinish(); };
7816
7760
  NoOpAnimationPlayer.prototype.destroy = function () { };
7817
7761
  NoOpAnimationPlayer.prototype.reset = function () { };
7818
- NoOpAnimationPlayer.prototype.setPosition = function (p /** TODO #9100 */) { };
7762
+ NoOpAnimationPlayer.prototype.setPosition = function (p) { };
7819
7763
  NoOpAnimationPlayer.prototype.getPosition = function () { return 0; };
7820
7764
  return NoOpAnimationPlayer;
7821
7765
  }());
@@ -7829,6 +7773,7 @@
7829
7773
  this._onStartFns = [];
7830
7774
  this._finished = false;
7831
7775
  this._started = false;
7776
+ this._destroyed = false;
7832
7777
  this.parentPlayer = null;
7833
7778
  this._players.forEach(function (player) { player.parentPlayer = _this; });
7834
7779
  this._onNext(false);
@@ -7857,9 +7802,6 @@
7857
7802
  AnimationSequencePlayer.prototype._onFinish = function () {
7858
7803
  if (!this._finished) {
7859
7804
  this._finished = true;
7860
- if (!isPresent(this.parentPlayer)) {
7861
- this.destroy();
7862
- }
7863
7805
  this._onDoneFns.forEach(function (fn) { return fn(); });
7864
7806
  this._onDoneFns = [];
7865
7807
  }
@@ -7881,22 +7823,36 @@
7881
7823
  };
7882
7824
  AnimationSequencePlayer.prototype.pause = function () { this._activePlayer.pause(); };
7883
7825
  AnimationSequencePlayer.prototype.restart = function () {
7826
+ this.reset();
7884
7827
  if (this._players.length > 0) {
7885
- this.reset();
7886
7828
  this._players[0].restart();
7887
7829
  }
7888
7830
  };
7889
- AnimationSequencePlayer.prototype.reset = function () { this._players.forEach(function (player) { return player.reset(); }); };
7831
+ AnimationSequencePlayer.prototype.reset = function () {
7832
+ this._players.forEach(function (player) { return player.reset(); });
7833
+ this._destroyed = false;
7834
+ this._finished = false;
7835
+ this._started = false;
7836
+ };
7890
7837
  AnimationSequencePlayer.prototype.finish = function () {
7891
7838
  this._onFinish();
7892
7839
  this._players.forEach(function (player) { return player.finish(); });
7893
7840
  };
7894
7841
  AnimationSequencePlayer.prototype.destroy = function () {
7895
- this._onFinish();
7896
- this._players.forEach(function (player) { return player.destroy(); });
7842
+ if (!this._destroyed) {
7843
+ this._onFinish();
7844
+ this._players.forEach(function (player) { return player.destroy(); });
7845
+ this._destroyed = true;
7846
+ this._activePlayer = new NoOpAnimationPlayer();
7847
+ }
7897
7848
  };
7898
- AnimationSequencePlayer.prototype.setPosition = function (p /** TODO #9100 */) { this._players[0].setPosition(p); };
7849
+ AnimationSequencePlayer.prototype.setPosition = function (p) { this._players[0].setPosition(p); };
7899
7850
  AnimationSequencePlayer.prototype.getPosition = function () { return this._players[0].getPosition(); };
7851
+ Object.defineProperty(AnimationSequencePlayer.prototype, "players", {
7852
+ get: function () { return this._players; },
7853
+ enumerable: true,
7854
+ configurable: true
7855
+ });
7900
7856
  return AnimationSequencePlayer;
7901
7857
  }());
7902
7858
 
@@ -8627,6 +8583,7 @@
8627
8583
  if (hasExtraFirstStyles) {
8628
8584
  firstKeyframe.styles.styles.push(extraFirstKeyframeStyles);
8629
8585
  }
8586
+ collectAndResolveStyles(collectedStyles, [finalStateStyles]);
8630
8587
  return keyframes;
8631
8588
  }
8632
8589
  function clearStyles(styles) {
@@ -8803,9 +8760,9 @@
8803
8760
  if (isPresent(debugNode)) {
8804
8761
  var debugParent = debugNode.parent;
8805
8762
  if (viewRootNodes.length > 0 && isPresent(debugParent)) {
8806
- var debugViewRootNodes = [];
8807
- viewRootNodes.forEach(function (rootNode) { return debugViewRootNodes.push(getDebugNode(rootNode)); });
8808
- debugParent.insertChildrenAfter(debugNode, debugViewRootNodes);
8763
+ var debugViewRootNodes_1 = [];
8764
+ viewRootNodes.forEach(function (rootNode) { return debugViewRootNodes_1.push(getDebugNode(rootNode)); });
8765
+ debugParent.insertChildrenAfter(debugNode, debugViewRootNodes_1);
8809
8766
  }
8810
8767
  }
8811
8768
  this._delegate.attachViewAfter(node, viewRootNodes);
@@ -8820,6 +8777,7 @@
8820
8777
  this._delegate.detachView(viewRootNodes);
8821
8778
  };
8822
8779
  DebugDomRenderer.prototype.destroyView = function (hostElement, viewAllNodes) {
8780
+ viewAllNodes = viewAllNodes || [];
8823
8781
  viewAllNodes.forEach(function (node) { removeDebugNodeFromIndex(getDebugNode(node)); });
8824
8782
  this._delegate.destroyView(hostElement, viewAllNodes);
8825
8783
  };
@@ -8868,8 +8826,9 @@
8868
8826
  this._delegate.invokeElementMethod(renderElement, methodName, args);
8869
8827
  };
8870
8828
  DebugDomRenderer.prototype.setText = function (renderNode, text) { this._delegate.setText(renderNode, text); };
8871
- DebugDomRenderer.prototype.animate = function (element, startingStyles, keyframes, duration, delay, easing) {
8872
- return this._delegate.animate(element, startingStyles, keyframes, duration, delay, easing);
8829
+ DebugDomRenderer.prototype.animate = function (element, startingStyles, keyframes, duration, delay, easing, previousPlayers) {
8830
+ if (previousPlayers === void 0) { previousPlayers = []; }
8831
+ return this._delegate.animate(element, startingStyles, keyframes, duration, delay, easing, previousPlayers);
8873
8832
  };
8874
8833
  return DebugDomRenderer;
8875
8834
  }());
@@ -8935,13 +8894,10 @@
8935
8894
  Object.defineProperty(DebugContext.prototype, "componentRenderElement", {
8936
8895
  get: function () {
8937
8896
  var componentView = this._view;
8938
- while (isPresent(componentView.declarationAppElement) &&
8939
- componentView.type !== ViewType.COMPONENT) {
8940
- componentView = componentView.declarationAppElement.parentView;
8897
+ while (isPresent(componentView.parentView) && componentView.type !== ViewType.COMPONENT) {
8898
+ componentView = componentView.parentView;
8941
8899
  }
8942
- return isPresent(componentView.declarationAppElement) ?
8943
- componentView.declarationAppElement.nativeElement :
8944
- null;
8900
+ return componentView.parentElement;
8945
8901
  },
8946
8902
  enumerable: true,
8947
8903
  configurable: true
@@ -8984,9 +8940,9 @@
8984
8940
  var varValues = {};
8985
8941
  var staticNodeInfo = this._staticNodeInfo;
8986
8942
  if (isPresent(staticNodeInfo)) {
8987
- var refs = staticNodeInfo.refTokens;
8988
- Object.keys(refs).forEach(function (refName) {
8989
- var refToken = refs[refName];
8943
+ var refs_1 = staticNodeInfo.refTokens;
8944
+ Object.keys(refs_1).forEach(function (refName) {
8945
+ var refToken = refs_1[refName];
8990
8946
  var varValue;
8991
8947
  if (isBlank(refToken)) {
8992
8948
  varValue = _this._view.allNodes ? _this._view.allNodes[_this._nodeIndex] : null;
@@ -9005,134 +8961,6 @@
9005
8961
  return DebugContext;
9006
8962
  }());
9007
8963
 
9008
- /**
9009
- * An AppElement is created for elements that have a ViewContainerRef,
9010
- * a nested component or a <template> element to keep data around
9011
- * that is needed for later instantiations.
9012
- */
9013
- var AppElement = (function () {
9014
- function AppElement(index, parentIndex, parentView, nativeElement) {
9015
- this.index = index;
9016
- this.parentIndex = parentIndex;
9017
- this.parentView = parentView;
9018
- this.nativeElement = nativeElement;
9019
- }
9020
- Object.defineProperty(AppElement.prototype, "elementRef", {
9021
- get: function () { return new ElementRef(this.nativeElement); },
9022
- enumerable: true,
9023
- configurable: true
9024
- });
9025
- Object.defineProperty(AppElement.prototype, "vcRef", {
9026
- get: function () { return new ViewContainerRef_(this); },
9027
- enumerable: true,
9028
- configurable: true
9029
- });
9030
- AppElement.prototype.initComponent = function (component, view) {
9031
- this.component = component;
9032
- this.componentView = view;
9033
- };
9034
- Object.defineProperty(AppElement.prototype, "parentInjector", {
9035
- get: function () { return this.parentView.injector(this.parentIndex); },
9036
- enumerable: true,
9037
- configurable: true
9038
- });
9039
- Object.defineProperty(AppElement.prototype, "injector", {
9040
- get: function () { return this.parentView.injector(this.index); },
9041
- enumerable: true,
9042
- configurable: true
9043
- });
9044
- AppElement.prototype.detectChangesInNestedViews = function (throwOnChange) {
9045
- if (this.nestedViews) {
9046
- for (var i = 0; i < this.nestedViews.length; i++) {
9047
- this.nestedViews[i].detectChanges(throwOnChange);
9048
- }
9049
- }
9050
- };
9051
- AppElement.prototype.destroyNestedViews = function () {
9052
- if (this.nestedViews) {
9053
- for (var i = 0; i < this.nestedViews.length; i++) {
9054
- this.nestedViews[i].destroy();
9055
- }
9056
- }
9057
- };
9058
- AppElement.prototype.visitNestedViewRootNodes = function (cb, c) {
9059
- if (this.nestedViews) {
9060
- for (var i = 0; i < this.nestedViews.length; i++) {
9061
- this.nestedViews[i].visitRootNodesInternal(cb, c);
9062
- }
9063
- }
9064
- };
9065
- AppElement.prototype.mapNestedViews = function (nestedViewClass, callback) {
9066
- var result = [];
9067
- if (isPresent(this.nestedViews)) {
9068
- this.nestedViews.forEach(function (nestedView) {
9069
- if (nestedView.clazz === nestedViewClass) {
9070
- result.push(callback(nestedView));
9071
- }
9072
- });
9073
- }
9074
- return result;
9075
- };
9076
- AppElement.prototype.moveView = function (view, currentIndex) {
9077
- var previousIndex = this.nestedViews.indexOf(view);
9078
- if (view.type === ViewType.COMPONENT) {
9079
- throw new Error("Component views can't be moved!");
9080
- }
9081
- var nestedViews = this.nestedViews;
9082
- if (nestedViews == null) {
9083
- nestedViews = [];
9084
- this.nestedViews = nestedViews;
9085
- }
9086
- nestedViews.splice(previousIndex, 1);
9087
- nestedViews.splice(currentIndex, 0, view);
9088
- var refRenderNode;
9089
- if (currentIndex > 0) {
9090
- var prevView = nestedViews[currentIndex - 1];
9091
- refRenderNode = prevView.lastRootNode;
9092
- }
9093
- else {
9094
- refRenderNode = this.nativeElement;
9095
- }
9096
- if (isPresent(refRenderNode)) {
9097
- view.renderer.attachViewAfter(refRenderNode, view.flatRootNodes);
9098
- }
9099
- view.markContentChildAsMoved(this);
9100
- };
9101
- AppElement.prototype.attachView = function (view, viewIndex) {
9102
- if (view.type === ViewType.COMPONENT) {
9103
- throw new Error("Component views can't be moved!");
9104
- }
9105
- var nestedViews = this.nestedViews;
9106
- if (nestedViews == null) {
9107
- nestedViews = [];
9108
- this.nestedViews = nestedViews;
9109
- }
9110
- nestedViews.splice(viewIndex, 0, view);
9111
- var refRenderNode;
9112
- if (viewIndex > 0) {
9113
- var prevView = nestedViews[viewIndex - 1];
9114
- refRenderNode = prevView.lastRootNode;
9115
- }
9116
- else {
9117
- refRenderNode = this.nativeElement;
9118
- }
9119
- if (isPresent(refRenderNode)) {
9120
- view.renderer.attachViewAfter(refRenderNode, view.flatRootNodes);
9121
- }
9122
- view.addToContentChildren(this);
9123
- };
9124
- AppElement.prototype.detachView = function (viewIndex) {
9125
- var view = this.nestedViews.splice(viewIndex, 1)[0];
9126
- if (view.type === ViewType.COMPONENT) {
9127
- throw new Error("Component views can't be moved!");
9128
- }
9129
- view.detach();
9130
- view.removeFromContentChildren(this);
9131
- return view;
9132
- };
9133
- return AppElement;
9134
- }());
9135
-
9136
8964
  var ViewAnimationMap = (function () {
9137
8965
  function ViewAnimationMap() {
9138
8966
  this._map = new Map();
@@ -9196,20 +9024,30 @@
9196
9024
  queueAnimationGlobally(player);
9197
9025
  this._players.set(element, animationName, player);
9198
9026
  };
9199
- AnimationViewContext.prototype.cancelActiveAnimation = function (element, animationName, removeAllAnimations) {
9027
+ AnimationViewContext.prototype.getAnimationPlayers = function (element, animationName, removeAllAnimations) {
9200
9028
  if (removeAllAnimations === void 0) { removeAllAnimations = false; }
9029
+ var players = [];
9201
9030
  if (removeAllAnimations) {
9202
- this._players.findAllPlayersByElement(element).forEach(function (player) { return player.destroy(); });
9031
+ this._players.findAllPlayersByElement(element).forEach(function (player) { _recursePlayers(player, players); });
9203
9032
  }
9204
9033
  else {
9205
- var player = this._players.find(element, animationName);
9206
- if (player) {
9207
- player.destroy();
9034
+ var currentPlayer = this._players.find(element, animationName);
9035
+ if (currentPlayer) {
9036
+ _recursePlayers(currentPlayer, players);
9208
9037
  }
9209
9038
  }
9039
+ return players;
9210
9040
  };
9211
9041
  return AnimationViewContext;
9212
9042
  }());
9043
+ function _recursePlayers(player, collectedPlayers) {
9044
+ if ((player instanceof AnimationGroupPlayer) || (player instanceof AnimationSequencePlayer)) {
9045
+ player.players.forEach(function (player) { return _recursePlayers(player, collectedPlayers); });
9046
+ }
9047
+ else {
9048
+ collectedPlayers.push(player);
9049
+ }
9050
+ }
9213
9051
 
9214
9052
  /**
9215
9053
  * @license
@@ -9223,7 +9061,6 @@
9223
9061
  function __() { this.constructor = d; }
9224
9062
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9225
9063
  };
9226
- var _UNDEFINED$1 = new Object();
9227
9064
  var ElementInjector = (function (_super) {
9228
9065
  __extends$15(ElementInjector, _super);
9229
9066
  function ElementInjector(_view, _nodeIndex) {
@@ -9233,14 +9070,7 @@
9233
9070
  }
9234
9071
  ElementInjector.prototype.get = function (token, notFoundValue) {
9235
9072
  if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
9236
- var result = _UNDEFINED$1;
9237
- if (result === _UNDEFINED$1) {
9238
- result = this._view.injectorGet(token, this._nodeIndex, _UNDEFINED$1);
9239
- }
9240
- if (result === _UNDEFINED$1) {
9241
- result = this._view.parentInjector.get(token, notFoundValue);
9242
- }
9243
- return result;
9073
+ return this._view.injectorGet(token, this._nodeIndex, notFoundValue);
9244
9074
  };
9245
9075
  return ElementInjector;
9246
9076
  }(Injector));
@@ -9258,28 +9088,37 @@
9258
9088
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9259
9089
  };
9260
9090
  var _scope_check = wtfCreateScope("AppView#check(ascii id)");
9091
+ /**
9092
+ * @experimental
9093
+ */
9094
+ var EMPTY_CONTEXT$1 = new Object();
9095
+ var UNDEFINED$1 = new Object();
9261
9096
  /**
9262
9097
  * Cost of making objects: http://jsperf.com/instantiate-size-of-object
9263
9098
  *
9264
9099
  */
9265
9100
  var AppView = (function () {
9266
- function AppView(clazz, componentType, type, viewUtils, parentInjector, declarationAppElement, cdMode) {
9101
+ function AppView(clazz, componentType, type, viewUtils, parentView, parentIndex, parentElement, cdMode, declaredViewContainer) {
9102
+ if (declaredViewContainer === void 0) { declaredViewContainer = null; }
9267
9103
  this.clazz = clazz;
9268
9104
  this.componentType = componentType;
9269
9105
  this.type = type;
9270
9106
  this.viewUtils = viewUtils;
9271
- this.parentInjector = parentInjector;
9272
- this.declarationAppElement = declarationAppElement;
9107
+ this.parentView = parentView;
9108
+ this.parentIndex = parentIndex;
9109
+ this.parentElement = parentElement;
9273
9110
  this.cdMode = cdMode;
9274
- this.viewContainerElement = null;
9111
+ this.declaredViewContainer = declaredViewContainer;
9112
+ this.viewContainer = null;
9275
9113
  this.numberOfChecks = 0;
9276
9114
  this.ref = new ViewRef_(this);
9277
9115
  if (type === ViewType.COMPONENT || type === ViewType.HOST) {
9278
9116
  this.renderer = viewUtils.renderComponent(componentType);
9279
9117
  }
9280
9118
  else {
9281
- this.renderer = declarationAppElement.parentView.renderer;
9119
+ this.renderer = parentView.renderer;
9282
9120
  }
9121
+ this._directRenderer = this.renderer.directRenderer;
9283
9122
  }
9284
9123
  Object.defineProperty(AppView.prototype, "animationContext", {
9285
9124
  get: function () {
@@ -9296,16 +9135,26 @@
9296
9135
  enumerable: true,
9297
9136
  configurable: true
9298
9137
  });
9299
- AppView.prototype.create = function (context, rootSelectorOrNode) {
9138
+ AppView.prototype.create = function (context) {
9300
9139
  this.context = context;
9140
+ return this.createInternal(null);
9141
+ };
9142
+ AppView.prototype.createHostView = function (rootSelectorOrNode, hostInjector, projectableNodes) {
9143
+ this.context = EMPTY_CONTEXT$1;
9301
9144
  this._hasExternalHostElement = isPresent(rootSelectorOrNode);
9145
+ this._hostInjector = hostInjector;
9146
+ this._hostProjectableNodes = projectableNodes;
9302
9147
  return this.createInternal(rootSelectorOrNode);
9303
9148
  };
9304
9149
  /**
9305
9150
  * Overwritten by implementations.
9306
- * Returns the AppElement for the host element for ViewType.HOST.
9151
+ * Returns the ComponentRef for the host element for ViewType.HOST.
9307
9152
  */
9308
9153
  AppView.prototype.createInternal = function (rootSelectorOrNode) { return null; };
9154
+ /**
9155
+ * Overwritten by implementations.
9156
+ */
9157
+ AppView.prototype.createEmbeddedViewInternal = function (templateNodeIndex) { return null; };
9309
9158
  AppView.prototype.init = function (lastRootNode, allNodes, disposables) {
9310
9159
  this.lastRootNode = lastRootNode;
9311
9160
  this.allNodes = allNodes;
@@ -9314,8 +9163,21 @@
9314
9163
  this.dirtyParentQueriesInternal();
9315
9164
  }
9316
9165
  };
9317
- AppView.prototype.injectorGet = function (token, nodeIndex, notFoundResult) {
9318
- return this.injectorGetInternal(token, nodeIndex, notFoundResult);
9166
+ AppView.prototype.injectorGet = function (token, nodeIndex, notFoundValue) {
9167
+ if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
9168
+ var result = UNDEFINED$1;
9169
+ var view = this;
9170
+ while (result === UNDEFINED$1) {
9171
+ if (isPresent(nodeIndex)) {
9172
+ result = view.injectorGetInternal(token, nodeIndex, UNDEFINED$1);
9173
+ }
9174
+ if (result === UNDEFINED$1 && view.type === ViewType.HOST) {
9175
+ result = view._hostInjector.get(token, notFoundValue);
9176
+ }
9177
+ nodeIndex = view.parentIndex;
9178
+ view = view.parentView;
9179
+ }
9180
+ return result;
9319
9181
  };
9320
9182
  /**
9321
9183
  * Overwritten by implementations
@@ -9323,20 +9185,13 @@
9323
9185
  AppView.prototype.injectorGetInternal = function (token, nodeIndex, notFoundResult) {
9324
9186
  return notFoundResult;
9325
9187
  };
9326
- AppView.prototype.injector = function (nodeIndex) {
9327
- if (isPresent(nodeIndex)) {
9328
- return new ElementInjector(this, nodeIndex);
9329
- }
9330
- else {
9331
- return this.parentInjector;
9332
- }
9333
- };
9188
+ AppView.prototype.injector = function (nodeIndex) { return new ElementInjector(this, nodeIndex); };
9334
9189
  AppView.prototype.detachAndDestroy = function () {
9335
9190
  if (this._hasExternalHostElement) {
9336
- this.renderer.detachView(this.flatRootNodes);
9191
+ this.detach();
9337
9192
  }
9338
- else if (isPresent(this.viewContainerElement)) {
9339
- this.viewContainerElement.detachView(this.viewContainerElement.nestedViews.indexOf(this));
9193
+ else if (isPresent(this.viewContainer)) {
9194
+ this.viewContainer.detachView(this.viewContainer.nestedViews.indexOf(this));
9340
9195
  }
9341
9196
  this.destroy();
9342
9197
  };
@@ -9345,7 +9200,7 @@
9345
9200
  if (this.cdMode === ChangeDetectorStatus.Destroyed) {
9346
9201
  return;
9347
9202
  }
9348
- var hostElement = this.type === ViewType.COMPONENT ? this.declarationAppElement.nativeElement : null;
9203
+ var hostElement = this.type === ViewType.COMPONENT ? this.parentElement : null;
9349
9204
  if (this.disposables) {
9350
9205
  for (var i = 0; i < this.disposables.length; i++) {
9351
9206
  this.disposables[i]();
@@ -9373,24 +9228,71 @@
9373
9228
  var _this = this;
9374
9229
  this.detachInternal();
9375
9230
  if (this._animationContext) {
9376
- this._animationContext.onAllActiveAnimationsDone(function () { return _this.renderer.detachView(_this.flatRootNodes); });
9231
+ this._animationContext.onAllActiveAnimationsDone(function () { return _this._renderDetach(); });
9232
+ }
9233
+ else {
9234
+ this._renderDetach();
9235
+ }
9236
+ if (this.declaredViewContainer && this.declaredViewContainer !== this.viewContainer) {
9237
+ var projectedViews = this.declaredViewContainer.projectedViews;
9238
+ var index = projectedViews.indexOf(this);
9239
+ // perf: pop is faster than splice!
9240
+ if (index >= projectedViews.length - 1) {
9241
+ projectedViews.pop();
9242
+ }
9243
+ else {
9244
+ projectedViews.splice(index, 1);
9245
+ }
9246
+ }
9247
+ this.viewContainer = null;
9248
+ this.dirtyParentQueriesInternal();
9249
+ };
9250
+ AppView.prototype._renderDetach = function () {
9251
+ if (this._directRenderer) {
9252
+ this.visitRootNodesInternal(this._directRenderer.remove, null);
9377
9253
  }
9378
9254
  else {
9379
9255
  this.renderer.detachView(this.flatRootNodes);
9380
9256
  }
9381
9257
  };
9258
+ AppView.prototype.attachAfter = function (viewContainer, prevView) {
9259
+ this._renderAttach(viewContainer, prevView);
9260
+ this.viewContainer = viewContainer;
9261
+ if (this.declaredViewContainer && this.declaredViewContainer !== viewContainer) {
9262
+ if (!this.declaredViewContainer.projectedViews) {
9263
+ this.declaredViewContainer.projectedViews = [];
9264
+ }
9265
+ this.declaredViewContainer.projectedViews.push(this);
9266
+ }
9267
+ this.dirtyParentQueriesInternal();
9268
+ };
9269
+ AppView.prototype.moveAfter = function (viewContainer, prevView) {
9270
+ this._renderAttach(viewContainer, prevView);
9271
+ this.dirtyParentQueriesInternal();
9272
+ };
9273
+ AppView.prototype._renderAttach = function (viewContainer, prevView) {
9274
+ var prevNode = prevView ? prevView.lastRootNode : viewContainer.nativeElement;
9275
+ if (this._directRenderer) {
9276
+ var nextSibling = this._directRenderer.nextSibling(prevNode);
9277
+ if (nextSibling) {
9278
+ this.visitRootNodesInternal(this._directRenderer.insertBefore, nextSibling);
9279
+ }
9280
+ else {
9281
+ var parentElement = this._directRenderer.parentElement(prevNode);
9282
+ if (parentElement) {
9283
+ this.visitRootNodesInternal(this._directRenderer.appendChild, parentElement);
9284
+ }
9285
+ }
9286
+ }
9287
+ else {
9288
+ this.renderer.attachViewAfter(prevNode, this.flatRootNodes);
9289
+ }
9290
+ };
9382
9291
  Object.defineProperty(AppView.prototype, "changeDetectorRef", {
9383
9292
  get: function () { return this.ref; },
9384
9293
  enumerable: true,
9385
9294
  configurable: true
9386
9295
  });
9387
- Object.defineProperty(AppView.prototype, "parent", {
9388
- get: function () {
9389
- return isPresent(this.declarationAppElement) ? this.declarationAppElement.parentView : null;
9390
- },
9391
- enumerable: true,
9392
- configurable: true
9393
- });
9394
9296
  Object.defineProperty(AppView.prototype, "flatRootNodes", {
9395
9297
  get: function () {
9396
9298
  var nodes = [];
@@ -9400,19 +9302,31 @@
9400
9302
  enumerable: true,
9401
9303
  configurable: true
9402
9304
  });
9403
- AppView.prototype.projectedNodes = function (ngContentIndex) {
9404
- var nodes = [];
9405
- this.visitProjectedNodes(ngContentIndex, addToArray, nodes);
9406
- return nodes;
9305
+ AppView.prototype.projectNodes = function (parentElement, ngContentIndex) {
9306
+ if (this._directRenderer) {
9307
+ this.visitProjectedNodes(ngContentIndex, this._directRenderer.appendChild, parentElement);
9308
+ }
9309
+ else {
9310
+ var nodes = [];
9311
+ this.visitProjectedNodes(ngContentIndex, addToArray, nodes);
9312
+ this.renderer.projectNodes(parentElement, nodes);
9313
+ }
9407
9314
  };
9408
9315
  AppView.prototype.visitProjectedNodes = function (ngContentIndex, cb, c) {
9409
- var appEl = this.declarationAppElement;
9410
9316
  switch (this.type) {
9411
9317
  case ViewType.EMBEDDED:
9412
- appEl.parentView.visitProjectedNodes(ngContentIndex, cb, c);
9318
+ this.parentView.visitProjectedNodes(ngContentIndex, cb, c);
9413
9319
  break;
9414
9320
  case ViewType.COMPONENT:
9415
- appEl.parentView.visitProjectableNodesInternal(appEl.index, ngContentIndex, cb, c);
9321
+ if (this.parentView.type === ViewType.HOST) {
9322
+ var nodes = this.parentView._hostProjectableNodes[ngContentIndex] || [];
9323
+ for (var i = 0; i < nodes.length; i++) {
9324
+ cb(nodes[i], c);
9325
+ }
9326
+ }
9327
+ else {
9328
+ this.parentView.visitProjectableNodesInternal(this.parentIndex, ngContentIndex, cb, c);
9329
+ }
9416
9330
  break;
9417
9331
  }
9418
9332
  };
@@ -9447,15 +9361,6 @@
9447
9361
  * Overwritten by implementations
9448
9362
  */
9449
9363
  AppView.prototype.detectChangesInternal = function (throwOnChange) { };
9450
- AppView.prototype.markContentChildAsMoved = function (renderAppElement) { this.dirtyParentQueriesInternal(); };
9451
- AppView.prototype.addToContentChildren = function (renderAppElement) {
9452
- this.viewContainerElement = renderAppElement;
9453
- this.dirtyParentQueriesInternal();
9454
- };
9455
- AppView.prototype.removeFromContentChildren = function (renderAppElement) {
9456
- this.dirtyParentQueriesInternal();
9457
- this.viewContainerElement = null;
9458
- };
9459
9364
  AppView.prototype.markAsCheckOnce = function () { this.cdMode = ChangeDetectorStatus.CheckOnce; };
9460
9365
  AppView.prototype.markPathToRootAsCheckOnce = function () {
9461
9366
  var c = this;
@@ -9463,8 +9368,12 @@
9463
9368
  if (c.cdMode === ChangeDetectorStatus.Checked) {
9464
9369
  c.cdMode = ChangeDetectorStatus.CheckOnce;
9465
9370
  }
9466
- var parentEl = c.type === ViewType.COMPONENT ? c.declarationAppElement : c.viewContainerElement;
9467
- c = isPresent(parentEl) ? parentEl.parentView : null;
9371
+ if (c.type === ViewType.COMPONENT) {
9372
+ c = c.parentView;
9373
+ }
9374
+ else {
9375
+ c = c.viewContainer ? c.viewContainer.parentView : null;
9376
+ }
9468
9377
  }
9469
9378
  };
9470
9379
  AppView.prototype.eventHandler = function (cb) {
@@ -9475,15 +9384,27 @@
9475
9384
  }());
9476
9385
  var DebugAppView = (function (_super) {
9477
9386
  __extends$14(DebugAppView, _super);
9478
- function DebugAppView(clazz, componentType, type, viewUtils, parentInjector, declarationAppElement, cdMode, staticNodeDebugInfos) {
9479
- _super.call(this, clazz, componentType, type, viewUtils, parentInjector, declarationAppElement, cdMode);
9387
+ function DebugAppView(clazz, componentType, type, viewUtils, parentView, parentIndex, parentNode, cdMode, staticNodeDebugInfos, declaredViewContainer) {
9388
+ if (declaredViewContainer === void 0) { declaredViewContainer = null; }
9389
+ _super.call(this, clazz, componentType, type, viewUtils, parentView, parentIndex, parentNode, cdMode, declaredViewContainer);
9480
9390
  this.staticNodeDebugInfos = staticNodeDebugInfos;
9481
9391
  this._currentDebugContext = null;
9482
9392
  }
9483
- DebugAppView.prototype.create = function (context, rootSelectorOrNode) {
9393
+ DebugAppView.prototype.create = function (context) {
9394
+ this._resetDebug();
9395
+ try {
9396
+ return _super.prototype.create.call(this, context);
9397
+ }
9398
+ catch (e) {
9399
+ this._rethrowWithContext(e);
9400
+ throw e;
9401
+ }
9402
+ };
9403
+ DebugAppView.prototype.createHostView = function (rootSelectorOrNode, injector, projectableNodes) {
9404
+ if (projectableNodes === void 0) { projectableNodes = null; }
9484
9405
  this._resetDebug();
9485
9406
  try {
9486
- return _super.prototype.create.call(this, context, rootSelectorOrNode);
9407
+ return _super.prototype.createHostView.call(this, rootSelectorOrNode, injector, projectableNodes);
9487
9408
  }
9488
9409
  catch (e) {
9489
9410
  this._rethrowWithContext(e);
@@ -9561,6 +9482,130 @@
9561
9482
  return DebugAppView;
9562
9483
  }(AppView));
9563
9484
 
9485
+ /**
9486
+ * A ViewContainer is created for elements that have a ViewContainerRef
9487
+ * to keep track of the nested views.
9488
+ */
9489
+ var ViewContainer = (function () {
9490
+ function ViewContainer(index, parentIndex, parentView, nativeElement) {
9491
+ this.index = index;
9492
+ this.parentIndex = parentIndex;
9493
+ this.parentView = parentView;
9494
+ this.nativeElement = nativeElement;
9495
+ }
9496
+ Object.defineProperty(ViewContainer.prototype, "elementRef", {
9497
+ get: function () { return new ElementRef(this.nativeElement); },
9498
+ enumerable: true,
9499
+ configurable: true
9500
+ });
9501
+ Object.defineProperty(ViewContainer.prototype, "vcRef", {
9502
+ get: function () { return new ViewContainerRef_(this); },
9503
+ enumerable: true,
9504
+ configurable: true
9505
+ });
9506
+ Object.defineProperty(ViewContainer.prototype, "parentInjector", {
9507
+ get: function () { return this.parentView.injector(this.parentIndex); },
9508
+ enumerable: true,
9509
+ configurable: true
9510
+ });
9511
+ Object.defineProperty(ViewContainer.prototype, "injector", {
9512
+ get: function () { return this.parentView.injector(this.index); },
9513
+ enumerable: true,
9514
+ configurable: true
9515
+ });
9516
+ ViewContainer.prototype.detectChangesInNestedViews = function (throwOnChange) {
9517
+ if (this.nestedViews) {
9518
+ for (var i = 0; i < this.nestedViews.length; i++) {
9519
+ this.nestedViews[i].detectChanges(throwOnChange);
9520
+ }
9521
+ }
9522
+ };
9523
+ ViewContainer.prototype.destroyNestedViews = function () {
9524
+ if (this.nestedViews) {
9525
+ for (var i = 0; i < this.nestedViews.length; i++) {
9526
+ this.nestedViews[i].destroy();
9527
+ }
9528
+ }
9529
+ };
9530
+ ViewContainer.prototype.visitNestedViewRootNodes = function (cb, c) {
9531
+ if (this.nestedViews) {
9532
+ for (var i = 0; i < this.nestedViews.length; i++) {
9533
+ this.nestedViews[i].visitRootNodesInternal(cb, c);
9534
+ }
9535
+ }
9536
+ };
9537
+ ViewContainer.prototype.mapNestedViews = function (nestedViewClass, callback) {
9538
+ var result = [];
9539
+ if (this.nestedViews) {
9540
+ for (var i = 0; i < this.nestedViews.length; i++) {
9541
+ var nestedView = this.nestedViews[i];
9542
+ if (nestedView.clazz === nestedViewClass) {
9543
+ result.push(callback(nestedView));
9544
+ }
9545
+ }
9546
+ }
9547
+ if (this.projectedViews) {
9548
+ for (var i = 0; i < this.projectedViews.length; i++) {
9549
+ var projectedView = this.projectedViews[i];
9550
+ if (projectedView.clazz === nestedViewClass) {
9551
+ result.push(callback(projectedView));
9552
+ }
9553
+ }
9554
+ }
9555
+ return result;
9556
+ };
9557
+ ViewContainer.prototype.moveView = function (view, currentIndex) {
9558
+ var previousIndex = this.nestedViews.indexOf(view);
9559
+ if (view.type === ViewType.COMPONENT) {
9560
+ throw new Error("Component views can't be moved!");
9561
+ }
9562
+ var nestedViews = this.nestedViews;
9563
+ if (nestedViews == null) {
9564
+ nestedViews = [];
9565
+ this.nestedViews = nestedViews;
9566
+ }
9567
+ nestedViews.splice(previousIndex, 1);
9568
+ nestedViews.splice(currentIndex, 0, view);
9569
+ var prevView = currentIndex > 0 ? nestedViews[currentIndex - 1] : null;
9570
+ view.moveAfter(this, prevView);
9571
+ };
9572
+ ViewContainer.prototype.attachView = function (view, viewIndex) {
9573
+ if (view.type === ViewType.COMPONENT) {
9574
+ throw new Error("Component views can't be moved!");
9575
+ }
9576
+ var nestedViews = this.nestedViews;
9577
+ if (nestedViews == null) {
9578
+ nestedViews = [];
9579
+ this.nestedViews = nestedViews;
9580
+ }
9581
+ // perf: array.push is faster than array.splice!
9582
+ if (viewIndex >= nestedViews.length) {
9583
+ nestedViews.push(view);
9584
+ }
9585
+ else {
9586
+ nestedViews.splice(viewIndex, 0, view);
9587
+ }
9588
+ var prevView = viewIndex > 0 ? nestedViews[viewIndex - 1] : null;
9589
+ view.attachAfter(this, prevView);
9590
+ };
9591
+ ViewContainer.prototype.detachView = function (viewIndex) {
9592
+ var view = this.nestedViews[viewIndex];
9593
+ // perf: array.pop is faster than array.splice!
9594
+ if (viewIndex >= this.nestedViews.length - 1) {
9595
+ this.nestedViews.pop();
9596
+ }
9597
+ else {
9598
+ this.nestedViews.splice(viewIndex, 1);
9599
+ }
9600
+ if (view.type === ViewType.COMPONENT) {
9601
+ throw new Error("Component views can't be moved!");
9602
+ }
9603
+ view.detach();
9604
+ return view;
9605
+ };
9606
+ return ViewContainer;
9607
+ }());
9608
+
9564
9609
  var __core_private__ = {
9565
9610
  isDefaultChangeDetectionStrategy: isDefaultChangeDetectionStrategy,
9566
9611
  ChangeDetectorStatus: ChangeDetectorStatus,
@@ -9569,7 +9614,8 @@
9569
9614
  LIFECYCLE_HOOKS_VALUES: LIFECYCLE_HOOKS_VALUES,
9570
9615
  ReflectorReader: ReflectorReader,
9571
9616
  CodegenComponentFactoryResolver: CodegenComponentFactoryResolver,
9572
- AppElement: AppElement,
9617
+ ComponentRef_: ComponentRef_,
9618
+ ViewContainer: ViewContainer,
9573
9619
  AppView: AppView,
9574
9620
  DebugAppView: DebugAppView,
9575
9621
  NgModuleInjector: NgModuleInjector,
@@ -9601,6 +9647,7 @@
9601
9647
  clearStyles: clearStyles,
9602
9648
  renderStyles: renderStyles,
9603
9649
  collectAndResolveStyles: collectAndResolveStyles,
9650
+ APP_ID_RANDOM_PROVIDER: APP_ID_RANDOM_PROVIDER,
9604
9651
  AnimationStyles: AnimationStyles,
9605
9652
  ANY_STATE: ANY_STATE,
9606
9653
  DEFAULT_STATE: DEFAULT_STATE,