@angular-wave/angular.ts 0.0.4 → 0.0.5
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.
- package/dist/angular-ts.cjs.js +26 -86
- package/dist/angular-ts.esm.js +26 -86
- package/dist/angular-ts.umd.js +26 -86
- package/package.json +1 -4
- package/src/core/utils.js +8 -0
- package/src/directive/switch.js +5 -63
- package/src/directive/switch.md +66 -0
- package/src/jqLite.js +13 -23
- package/test/jqlite.spec.js +1 -13
- package/test/ng/compile.spec.js +2 -2
package/dist/angular-ts.cjs.js
CHANGED
|
@@ -616,6 +616,14 @@ function includes(array, obj) {
|
|
|
616
616
|
return Array.prototype.indexOf.call(array, obj) !== -1;
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
+
/**
|
|
620
|
+
* Removes the first occurrence of a specified value from an array.
|
|
621
|
+
*
|
|
622
|
+
* @template T
|
|
623
|
+
* @param {Array<T>} array - The array from which to remove the value.
|
|
624
|
+
* @param {T} value - The value to remove.
|
|
625
|
+
* @returns {number} - The index of the removed value, or -1 if the value was not found.
|
|
626
|
+
*/
|
|
619
627
|
function arrayRemove(array, value) {
|
|
620
628
|
const index = array.indexOf(value);
|
|
621
629
|
if (index >= 0) {
|
|
@@ -1467,17 +1475,8 @@ const CACHE = new Proxy(new Map(), {
|
|
|
1467
1475
|
* @returns {Object} jQuery object.
|
|
1468
1476
|
*/
|
|
1469
1477
|
|
|
1470
|
-
JQLite.cache = CACHE;
|
|
1471
|
-
|
|
1472
1478
|
let jqId = 1;
|
|
1473
1479
|
|
|
1474
|
-
/**
|
|
1475
|
-
* !!! This is an undocumented "private" function !!!
|
|
1476
|
-
* @param {JQLite|Element} node
|
|
1477
|
-
* @returns
|
|
1478
|
-
*/
|
|
1479
|
-
JQLite._data = (node) => JQLite.cache.get(node[EXPANDO]) || {};
|
|
1480
|
-
|
|
1481
1480
|
function jqNextId() {
|
|
1482
1481
|
return ++jqId;
|
|
1483
1482
|
}
|
|
@@ -1662,6 +1661,11 @@ function JQLite(element) {
|
|
|
1662
1661
|
}
|
|
1663
1662
|
var jqLite = JQLite;
|
|
1664
1663
|
|
|
1664
|
+
/**
|
|
1665
|
+
* @param {Element} element
|
|
1666
|
+
* @param {boolean} [onlyDescendants]
|
|
1667
|
+
* @returns {void}
|
|
1668
|
+
*/
|
|
1665
1669
|
function dealoc(element, onlyDescendants) {
|
|
1666
1670
|
if (!element) return;
|
|
1667
1671
|
if (!onlyDescendants && elementAcceptsData(element))
|
|
@@ -1680,13 +1684,13 @@ function dealoc(element, onlyDescendants) {
|
|
|
1680
1684
|
*/
|
|
1681
1685
|
function removeIfEmptyData(element) {
|
|
1682
1686
|
const expandoId = element[EXPANDO];
|
|
1683
|
-
const { events, data } =
|
|
1687
|
+
const { events, data } = CACHE.get(expandoId);
|
|
1684
1688
|
|
|
1685
1689
|
if (
|
|
1686
1690
|
(!data || !Object.keys(data).length) &&
|
|
1687
1691
|
(!events || !Object.keys(events).length)
|
|
1688
1692
|
) {
|
|
1689
|
-
|
|
1693
|
+
CACHE.delete(expandoId);
|
|
1690
1694
|
element[EXPANDO] = undefined; // don't delete DOM expandos. IE and Chrome don't like it
|
|
1691
1695
|
}
|
|
1692
1696
|
}
|
|
@@ -1714,8 +1718,8 @@ function jqLiteOff(element, type, fn, unsupported) {
|
|
|
1714
1718
|
} else {
|
|
1715
1719
|
const removeHandler = function (type) {
|
|
1716
1720
|
const listenerFns = events[type];
|
|
1717
|
-
if (isDefined(fn)) {
|
|
1718
|
-
arrayRemove(listenerFns
|
|
1721
|
+
if (isDefined(fn) && isArray(listenerFns)) {
|
|
1722
|
+
arrayRemove(listenerFns, fn);
|
|
1719
1723
|
}
|
|
1720
1724
|
if (!(isDefined(fn) && listenerFns && listenerFns.length > 0)) {
|
|
1721
1725
|
element.removeEventListener(type, handle);
|
|
@@ -1743,7 +1747,7 @@ function jqLiteOff(element, type, fn, unsupported) {
|
|
|
1743
1747
|
*/
|
|
1744
1748
|
function jqLiteRemoveData(element, name) {
|
|
1745
1749
|
const expandoId = element[EXPANDO];
|
|
1746
|
-
const expandoStore = expandoId &&
|
|
1750
|
+
const expandoStore = expandoId && CACHE.get(expandoId);
|
|
1747
1751
|
|
|
1748
1752
|
if (expandoStore) {
|
|
1749
1753
|
if (name) {
|
|
@@ -1764,7 +1768,7 @@ function jqLiteRemoveData(element, name) {
|
|
|
1764
1768
|
*/
|
|
1765
1769
|
function jqLiteExpandoStore(element, createIfNecessary = false) {
|
|
1766
1770
|
let expandoId = element[EXPANDO];
|
|
1767
|
-
let expandoStore = expandoId &&
|
|
1771
|
+
let expandoStore = expandoId && CACHE.get(expandoId);
|
|
1768
1772
|
|
|
1769
1773
|
if (createIfNecessary && !expandoStore) {
|
|
1770
1774
|
element[EXPANDO] = expandoId = jqNextId();
|
|
@@ -1773,7 +1777,7 @@ function jqLiteExpandoStore(element, createIfNecessary = false) {
|
|
|
1773
1777
|
data: {},
|
|
1774
1778
|
handle: null,
|
|
1775
1779
|
};
|
|
1776
|
-
|
|
1780
|
+
CACHE.set(expandoId, expandoStore);
|
|
1777
1781
|
}
|
|
1778
1782
|
|
|
1779
1783
|
return expandoStore;
|
|
@@ -1790,15 +1794,12 @@ function jqLiteData(element, key, value) {
|
|
|
1790
1794
|
const data = expandoStore && expandoStore.data;
|
|
1791
1795
|
|
|
1792
1796
|
if (isSimpleSetter) {
|
|
1793
|
-
// data('key', value)
|
|
1794
1797
|
data[kebabToCamel(key)] = value;
|
|
1795
1798
|
} else {
|
|
1796
1799
|
if (massGetter) {
|
|
1797
|
-
// data()
|
|
1798
1800
|
return data;
|
|
1799
1801
|
}
|
|
1800
1802
|
if (isSimpleGetter) {
|
|
1801
|
-
// data('key')
|
|
1802
1803
|
// don't force creation of expandoStore if it doesn't exist yet
|
|
1803
1804
|
return data && data[kebabToCamel(key)];
|
|
1804
1805
|
}
|
|
@@ -1945,7 +1946,7 @@ function getBooleanAttrName(element, name) {
|
|
|
1945
1946
|
|
|
1946
1947
|
function jqLiteCleanData(nodes) {
|
|
1947
1948
|
for (let i = 0, ii = nodes.length; i < ii; i++) {
|
|
1948
|
-
var events = (
|
|
1949
|
+
var events = (CACHE.get(nodes[i][EXPANDO]) || {}).events;
|
|
1949
1950
|
if (events && events.$destroy) {
|
|
1950
1951
|
jqLite(nodes[i]).triggerHandler("$destroy");
|
|
1951
1952
|
}
|
|
@@ -2080,8 +2081,6 @@ forEach(
|
|
|
2080
2081
|
let key;
|
|
2081
2082
|
const nodeCount = this.length;
|
|
2082
2083
|
|
|
2083
|
-
// jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
|
|
2084
|
-
// in a way that survives minification.
|
|
2085
2084
|
// jqLiteEmpty takes no arguments but is a setter.
|
|
2086
2085
|
if (
|
|
2087
2086
|
fn !== jqLiteEmpty &&
|
|
@@ -2091,7 +2090,6 @@ forEach(
|
|
|
2091
2090
|
// we are a write, but the object properties are the key/values
|
|
2092
2091
|
for (i = 0; i < nodeCount; i++) {
|
|
2093
2092
|
if (fn === jqLiteData) {
|
|
2094
|
-
// data() takes the whole object in jQuery
|
|
2095
2093
|
fn(this[i], arg1);
|
|
2096
2094
|
} else {
|
|
2097
2095
|
for (key in arg1) {
|
|
@@ -16734,66 +16732,6 @@ function ngStyleDirective() {
|
|
|
16734
16732
|
};
|
|
16735
16733
|
}
|
|
16736
16734
|
|
|
16737
|
-
/**
|
|
16738
|
-
* @ngdoc directive
|
|
16739
|
-
* @name ngSwitch
|
|
16740
|
-
* @restrict EA
|
|
16741
|
-
*
|
|
16742
|
-
* @description
|
|
16743
|
-
* The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression.
|
|
16744
|
-
* Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location
|
|
16745
|
-
* as specified in the template.
|
|
16746
|
-
*
|
|
16747
|
-
* The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it
|
|
16748
|
-
* from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element
|
|
16749
|
-
* matches the value obtained from the evaluated expression. In other words, you define a container element
|
|
16750
|
-
* (where you place the directive), place an expression on the **`on="..."` attribute**
|
|
16751
|
-
* (or the **`ng-switch="..."` attribute**), define any inner elements inside of the directive and place
|
|
16752
|
-
* a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on
|
|
16753
|
-
* expression is evaluated. If a matching expression is not found via a when attribute then an element with the default
|
|
16754
|
-
* attribute is displayed.
|
|
16755
|
-
*
|
|
16756
|
-
* <div class="alert alert-info">
|
|
16757
|
-
* Be aware that the attribute values to match against cannot be expressions. They are interpreted
|
|
16758
|
-
* as literal string values to match against.
|
|
16759
|
-
* For example, **`ng-switch-when="someVal"`** will match against the string `"someVal"` not against the
|
|
16760
|
-
* value of the expression `$scope.someVal`.
|
|
16761
|
-
* </div>
|
|
16762
|
-
|
|
16763
|
-
* @animations
|
|
16764
|
-
* | Animation | Occurs |
|
|
16765
|
-
* |----------------------------------|-------------------------------------|
|
|
16766
|
-
* | {@link ng.$animate#enter enter} | after the ngSwitch contents change and the matched child element is placed inside the container |
|
|
16767
|
-
* | {@link ng.$animate#leave leave} | after the ngSwitch contents change and just before the former contents are removed from the DOM |
|
|
16768
|
-
*
|
|
16769
|
-
* @usage
|
|
16770
|
-
*
|
|
16771
|
-
* ```
|
|
16772
|
-
* <ANY ng-switch="expression">
|
|
16773
|
-
* <ANY ng-switch-when="matchValue1">...</ANY>
|
|
16774
|
-
* <ANY ng-switch-when="matchValue2">...</ANY>
|
|
16775
|
-
* <ANY ng-switch-default>...</ANY>
|
|
16776
|
-
* </ANY>
|
|
16777
|
-
* ```
|
|
16778
|
-
*
|
|
16779
|
-
*
|
|
16780
|
-
* @scope
|
|
16781
|
-
* @priority 1200
|
|
16782
|
-
* @param {*} ngSwitch|on expression to match against <code>ng-switch-when</code>.
|
|
16783
|
-
* On child elements add:
|
|
16784
|
-
*
|
|
16785
|
-
* * `ngSwitchWhen`: the case statement to match against. If match then this
|
|
16786
|
-
* case will be displayed. If the same match appears multiple times, all the
|
|
16787
|
-
* elements will be displayed. It is possible to associate multiple values to
|
|
16788
|
-
* the same `ngSwitchWhen` by defining the optional attribute
|
|
16789
|
-
* `ngSwitchWhenSeparator`. The separator will be used to split the value of
|
|
16790
|
-
* the `ngSwitchWhen` attribute into multiple tokens, and the element will show
|
|
16791
|
-
* if any of the `ngSwitch` evaluates to any of these tokens.
|
|
16792
|
-
* * `ngSwitchDefault`: the default case when no other case match. If there
|
|
16793
|
-
* are multiple default cases, all of them will be displayed when no other
|
|
16794
|
-
* case match.
|
|
16795
|
-
*
|
|
16796
|
-
*/
|
|
16797
16735
|
const ngSwitchDirective = [
|
|
16798
16736
|
"$animate",
|
|
16799
16737
|
"$compile",
|
|
@@ -16803,11 +16741,13 @@ const ngSwitchDirective = [
|
|
|
16803
16741
|
// asks for $scope to fool the BC controller module
|
|
16804
16742
|
controller: [
|
|
16805
16743
|
"$scope",
|
|
16806
|
-
|
|
16807
|
-
|
|
16744
|
+
class {
|
|
16745
|
+
constructor() {
|
|
16746
|
+
this.cases = {};
|
|
16747
|
+
}
|
|
16808
16748
|
},
|
|
16809
16749
|
],
|
|
16810
|
-
link(scope,
|
|
16750
|
+
link(scope, _element, attr, ngSwitchController) {
|
|
16811
16751
|
const watchExpr = attr.ngSwitch || attr.on;
|
|
16812
16752
|
let selectedTranscludes = [];
|
|
16813
16753
|
const selectedElements = [];
|
package/dist/angular-ts.esm.js
CHANGED
|
@@ -614,6 +614,14 @@ function includes(array, obj) {
|
|
|
614
614
|
return Array.prototype.indexOf.call(array, obj) !== -1;
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
+
/**
|
|
618
|
+
* Removes the first occurrence of a specified value from an array.
|
|
619
|
+
*
|
|
620
|
+
* @template T
|
|
621
|
+
* @param {Array<T>} array - The array from which to remove the value.
|
|
622
|
+
* @param {T} value - The value to remove.
|
|
623
|
+
* @returns {number} - The index of the removed value, or -1 if the value was not found.
|
|
624
|
+
*/
|
|
617
625
|
function arrayRemove(array, value) {
|
|
618
626
|
const index = array.indexOf(value);
|
|
619
627
|
if (index >= 0) {
|
|
@@ -1465,17 +1473,8 @@ const CACHE = new Proxy(new Map(), {
|
|
|
1465
1473
|
* @returns {Object} jQuery object.
|
|
1466
1474
|
*/
|
|
1467
1475
|
|
|
1468
|
-
JQLite.cache = CACHE;
|
|
1469
|
-
|
|
1470
1476
|
let jqId = 1;
|
|
1471
1477
|
|
|
1472
|
-
/**
|
|
1473
|
-
* !!! This is an undocumented "private" function !!!
|
|
1474
|
-
* @param {JQLite|Element} node
|
|
1475
|
-
* @returns
|
|
1476
|
-
*/
|
|
1477
|
-
JQLite._data = (node) => JQLite.cache.get(node[EXPANDO]) || {};
|
|
1478
|
-
|
|
1479
1478
|
function jqNextId() {
|
|
1480
1479
|
return ++jqId;
|
|
1481
1480
|
}
|
|
@@ -1660,6 +1659,11 @@ function JQLite(element) {
|
|
|
1660
1659
|
}
|
|
1661
1660
|
var jqLite = JQLite;
|
|
1662
1661
|
|
|
1662
|
+
/**
|
|
1663
|
+
* @param {Element} element
|
|
1664
|
+
* @param {boolean} [onlyDescendants]
|
|
1665
|
+
* @returns {void}
|
|
1666
|
+
*/
|
|
1663
1667
|
function dealoc(element, onlyDescendants) {
|
|
1664
1668
|
if (!element) return;
|
|
1665
1669
|
if (!onlyDescendants && elementAcceptsData(element))
|
|
@@ -1678,13 +1682,13 @@ function dealoc(element, onlyDescendants) {
|
|
|
1678
1682
|
*/
|
|
1679
1683
|
function removeIfEmptyData(element) {
|
|
1680
1684
|
const expandoId = element[EXPANDO];
|
|
1681
|
-
const { events, data } =
|
|
1685
|
+
const { events, data } = CACHE.get(expandoId);
|
|
1682
1686
|
|
|
1683
1687
|
if (
|
|
1684
1688
|
(!data || !Object.keys(data).length) &&
|
|
1685
1689
|
(!events || !Object.keys(events).length)
|
|
1686
1690
|
) {
|
|
1687
|
-
|
|
1691
|
+
CACHE.delete(expandoId);
|
|
1688
1692
|
element[EXPANDO] = undefined; // don't delete DOM expandos. IE and Chrome don't like it
|
|
1689
1693
|
}
|
|
1690
1694
|
}
|
|
@@ -1712,8 +1716,8 @@ function jqLiteOff(element, type, fn, unsupported) {
|
|
|
1712
1716
|
} else {
|
|
1713
1717
|
const removeHandler = function (type) {
|
|
1714
1718
|
const listenerFns = events[type];
|
|
1715
|
-
if (isDefined(fn)) {
|
|
1716
|
-
arrayRemove(listenerFns
|
|
1719
|
+
if (isDefined(fn) && isArray(listenerFns)) {
|
|
1720
|
+
arrayRemove(listenerFns, fn);
|
|
1717
1721
|
}
|
|
1718
1722
|
if (!(isDefined(fn) && listenerFns && listenerFns.length > 0)) {
|
|
1719
1723
|
element.removeEventListener(type, handle);
|
|
@@ -1741,7 +1745,7 @@ function jqLiteOff(element, type, fn, unsupported) {
|
|
|
1741
1745
|
*/
|
|
1742
1746
|
function jqLiteRemoveData(element, name) {
|
|
1743
1747
|
const expandoId = element[EXPANDO];
|
|
1744
|
-
const expandoStore = expandoId &&
|
|
1748
|
+
const expandoStore = expandoId && CACHE.get(expandoId);
|
|
1745
1749
|
|
|
1746
1750
|
if (expandoStore) {
|
|
1747
1751
|
if (name) {
|
|
@@ -1762,7 +1766,7 @@ function jqLiteRemoveData(element, name) {
|
|
|
1762
1766
|
*/
|
|
1763
1767
|
function jqLiteExpandoStore(element, createIfNecessary = false) {
|
|
1764
1768
|
let expandoId = element[EXPANDO];
|
|
1765
|
-
let expandoStore = expandoId &&
|
|
1769
|
+
let expandoStore = expandoId && CACHE.get(expandoId);
|
|
1766
1770
|
|
|
1767
1771
|
if (createIfNecessary && !expandoStore) {
|
|
1768
1772
|
element[EXPANDO] = expandoId = jqNextId();
|
|
@@ -1771,7 +1775,7 @@ function jqLiteExpandoStore(element, createIfNecessary = false) {
|
|
|
1771
1775
|
data: {},
|
|
1772
1776
|
handle: null,
|
|
1773
1777
|
};
|
|
1774
|
-
|
|
1778
|
+
CACHE.set(expandoId, expandoStore);
|
|
1775
1779
|
}
|
|
1776
1780
|
|
|
1777
1781
|
return expandoStore;
|
|
@@ -1788,15 +1792,12 @@ function jqLiteData(element, key, value) {
|
|
|
1788
1792
|
const data = expandoStore && expandoStore.data;
|
|
1789
1793
|
|
|
1790
1794
|
if (isSimpleSetter) {
|
|
1791
|
-
// data('key', value)
|
|
1792
1795
|
data[kebabToCamel(key)] = value;
|
|
1793
1796
|
} else {
|
|
1794
1797
|
if (massGetter) {
|
|
1795
|
-
// data()
|
|
1796
1798
|
return data;
|
|
1797
1799
|
}
|
|
1798
1800
|
if (isSimpleGetter) {
|
|
1799
|
-
// data('key')
|
|
1800
1801
|
// don't force creation of expandoStore if it doesn't exist yet
|
|
1801
1802
|
return data && data[kebabToCamel(key)];
|
|
1802
1803
|
}
|
|
@@ -1943,7 +1944,7 @@ function getBooleanAttrName(element, name) {
|
|
|
1943
1944
|
|
|
1944
1945
|
function jqLiteCleanData(nodes) {
|
|
1945
1946
|
for (let i = 0, ii = nodes.length; i < ii; i++) {
|
|
1946
|
-
var events = (
|
|
1947
|
+
var events = (CACHE.get(nodes[i][EXPANDO]) || {}).events;
|
|
1947
1948
|
if (events && events.$destroy) {
|
|
1948
1949
|
jqLite(nodes[i]).triggerHandler("$destroy");
|
|
1949
1950
|
}
|
|
@@ -2078,8 +2079,6 @@ forEach(
|
|
|
2078
2079
|
let key;
|
|
2079
2080
|
const nodeCount = this.length;
|
|
2080
2081
|
|
|
2081
|
-
// jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
|
|
2082
|
-
// in a way that survives minification.
|
|
2083
2082
|
// jqLiteEmpty takes no arguments but is a setter.
|
|
2084
2083
|
if (
|
|
2085
2084
|
fn !== jqLiteEmpty &&
|
|
@@ -2089,7 +2088,6 @@ forEach(
|
|
|
2089
2088
|
// we are a write, but the object properties are the key/values
|
|
2090
2089
|
for (i = 0; i < nodeCount; i++) {
|
|
2091
2090
|
if (fn === jqLiteData) {
|
|
2092
|
-
// data() takes the whole object in jQuery
|
|
2093
2091
|
fn(this[i], arg1);
|
|
2094
2092
|
} else {
|
|
2095
2093
|
for (key in arg1) {
|
|
@@ -16732,66 +16730,6 @@ function ngStyleDirective() {
|
|
|
16732
16730
|
};
|
|
16733
16731
|
}
|
|
16734
16732
|
|
|
16735
|
-
/**
|
|
16736
|
-
* @ngdoc directive
|
|
16737
|
-
* @name ngSwitch
|
|
16738
|
-
* @restrict EA
|
|
16739
|
-
*
|
|
16740
|
-
* @description
|
|
16741
|
-
* The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression.
|
|
16742
|
-
* Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location
|
|
16743
|
-
* as specified in the template.
|
|
16744
|
-
*
|
|
16745
|
-
* The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it
|
|
16746
|
-
* from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element
|
|
16747
|
-
* matches the value obtained from the evaluated expression. In other words, you define a container element
|
|
16748
|
-
* (where you place the directive), place an expression on the **`on="..."` attribute**
|
|
16749
|
-
* (or the **`ng-switch="..."` attribute**), define any inner elements inside of the directive and place
|
|
16750
|
-
* a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on
|
|
16751
|
-
* expression is evaluated. If a matching expression is not found via a when attribute then an element with the default
|
|
16752
|
-
* attribute is displayed.
|
|
16753
|
-
*
|
|
16754
|
-
* <div class="alert alert-info">
|
|
16755
|
-
* Be aware that the attribute values to match against cannot be expressions. They are interpreted
|
|
16756
|
-
* as literal string values to match against.
|
|
16757
|
-
* For example, **`ng-switch-when="someVal"`** will match against the string `"someVal"` not against the
|
|
16758
|
-
* value of the expression `$scope.someVal`.
|
|
16759
|
-
* </div>
|
|
16760
|
-
|
|
16761
|
-
* @animations
|
|
16762
|
-
* | Animation | Occurs |
|
|
16763
|
-
* |----------------------------------|-------------------------------------|
|
|
16764
|
-
* | {@link ng.$animate#enter enter} | after the ngSwitch contents change and the matched child element is placed inside the container |
|
|
16765
|
-
* | {@link ng.$animate#leave leave} | after the ngSwitch contents change and just before the former contents are removed from the DOM |
|
|
16766
|
-
*
|
|
16767
|
-
* @usage
|
|
16768
|
-
*
|
|
16769
|
-
* ```
|
|
16770
|
-
* <ANY ng-switch="expression">
|
|
16771
|
-
* <ANY ng-switch-when="matchValue1">...</ANY>
|
|
16772
|
-
* <ANY ng-switch-when="matchValue2">...</ANY>
|
|
16773
|
-
* <ANY ng-switch-default>...</ANY>
|
|
16774
|
-
* </ANY>
|
|
16775
|
-
* ```
|
|
16776
|
-
*
|
|
16777
|
-
*
|
|
16778
|
-
* @scope
|
|
16779
|
-
* @priority 1200
|
|
16780
|
-
* @param {*} ngSwitch|on expression to match against <code>ng-switch-when</code>.
|
|
16781
|
-
* On child elements add:
|
|
16782
|
-
*
|
|
16783
|
-
* * `ngSwitchWhen`: the case statement to match against. If match then this
|
|
16784
|
-
* case will be displayed. If the same match appears multiple times, all the
|
|
16785
|
-
* elements will be displayed. It is possible to associate multiple values to
|
|
16786
|
-
* the same `ngSwitchWhen` by defining the optional attribute
|
|
16787
|
-
* `ngSwitchWhenSeparator`. The separator will be used to split the value of
|
|
16788
|
-
* the `ngSwitchWhen` attribute into multiple tokens, and the element will show
|
|
16789
|
-
* if any of the `ngSwitch` evaluates to any of these tokens.
|
|
16790
|
-
* * `ngSwitchDefault`: the default case when no other case match. If there
|
|
16791
|
-
* are multiple default cases, all of them will be displayed when no other
|
|
16792
|
-
* case match.
|
|
16793
|
-
*
|
|
16794
|
-
*/
|
|
16795
16733
|
const ngSwitchDirective = [
|
|
16796
16734
|
"$animate",
|
|
16797
16735
|
"$compile",
|
|
@@ -16801,11 +16739,13 @@ const ngSwitchDirective = [
|
|
|
16801
16739
|
// asks for $scope to fool the BC controller module
|
|
16802
16740
|
controller: [
|
|
16803
16741
|
"$scope",
|
|
16804
|
-
|
|
16805
|
-
|
|
16742
|
+
class {
|
|
16743
|
+
constructor() {
|
|
16744
|
+
this.cases = {};
|
|
16745
|
+
}
|
|
16806
16746
|
},
|
|
16807
16747
|
],
|
|
16808
|
-
link(scope,
|
|
16748
|
+
link(scope, _element, attr, ngSwitchController) {
|
|
16809
16749
|
const watchExpr = attr.ngSwitch || attr.on;
|
|
16810
16750
|
let selectedTranscludes = [];
|
|
16811
16751
|
const selectedElements = [];
|
package/dist/angular-ts.umd.js
CHANGED
|
@@ -619,6 +619,14 @@
|
|
|
619
619
|
return Array.prototype.indexOf.call(array, obj) !== -1;
|
|
620
620
|
}
|
|
621
621
|
|
|
622
|
+
/**
|
|
623
|
+
* Removes the first occurrence of a specified value from an array.
|
|
624
|
+
*
|
|
625
|
+
* @template T
|
|
626
|
+
* @param {Array<T>} array - The array from which to remove the value.
|
|
627
|
+
* @param {T} value - The value to remove.
|
|
628
|
+
* @returns {number} - The index of the removed value, or -1 if the value was not found.
|
|
629
|
+
*/
|
|
622
630
|
function arrayRemove(array, value) {
|
|
623
631
|
const index = array.indexOf(value);
|
|
624
632
|
if (index >= 0) {
|
|
@@ -1470,17 +1478,8 @@
|
|
|
1470
1478
|
* @returns {Object} jQuery object.
|
|
1471
1479
|
*/
|
|
1472
1480
|
|
|
1473
|
-
JQLite.cache = CACHE;
|
|
1474
|
-
|
|
1475
1481
|
let jqId = 1;
|
|
1476
1482
|
|
|
1477
|
-
/**
|
|
1478
|
-
* !!! This is an undocumented "private" function !!!
|
|
1479
|
-
* @param {JQLite|Element} node
|
|
1480
|
-
* @returns
|
|
1481
|
-
*/
|
|
1482
|
-
JQLite._data = (node) => JQLite.cache.get(node[EXPANDO]) || {};
|
|
1483
|
-
|
|
1484
1483
|
function jqNextId() {
|
|
1485
1484
|
return ++jqId;
|
|
1486
1485
|
}
|
|
@@ -1665,6 +1664,11 @@
|
|
|
1665
1664
|
}
|
|
1666
1665
|
var jqLite = JQLite;
|
|
1667
1666
|
|
|
1667
|
+
/**
|
|
1668
|
+
* @param {Element} element
|
|
1669
|
+
* @param {boolean} [onlyDescendants]
|
|
1670
|
+
* @returns {void}
|
|
1671
|
+
*/
|
|
1668
1672
|
function dealoc(element, onlyDescendants) {
|
|
1669
1673
|
if (!element) return;
|
|
1670
1674
|
if (!onlyDescendants && elementAcceptsData(element))
|
|
@@ -1683,13 +1687,13 @@
|
|
|
1683
1687
|
*/
|
|
1684
1688
|
function removeIfEmptyData(element) {
|
|
1685
1689
|
const expandoId = element[EXPANDO];
|
|
1686
|
-
const { events, data } =
|
|
1690
|
+
const { events, data } = CACHE.get(expandoId);
|
|
1687
1691
|
|
|
1688
1692
|
if (
|
|
1689
1693
|
(!data || !Object.keys(data).length) &&
|
|
1690
1694
|
(!events || !Object.keys(events).length)
|
|
1691
1695
|
) {
|
|
1692
|
-
|
|
1696
|
+
CACHE.delete(expandoId);
|
|
1693
1697
|
element[EXPANDO] = undefined; // don't delete DOM expandos. IE and Chrome don't like it
|
|
1694
1698
|
}
|
|
1695
1699
|
}
|
|
@@ -1717,8 +1721,8 @@
|
|
|
1717
1721
|
} else {
|
|
1718
1722
|
const removeHandler = function (type) {
|
|
1719
1723
|
const listenerFns = events[type];
|
|
1720
|
-
if (isDefined(fn)) {
|
|
1721
|
-
arrayRemove(listenerFns
|
|
1724
|
+
if (isDefined(fn) && isArray(listenerFns)) {
|
|
1725
|
+
arrayRemove(listenerFns, fn);
|
|
1722
1726
|
}
|
|
1723
1727
|
if (!(isDefined(fn) && listenerFns && listenerFns.length > 0)) {
|
|
1724
1728
|
element.removeEventListener(type, handle);
|
|
@@ -1746,7 +1750,7 @@
|
|
|
1746
1750
|
*/
|
|
1747
1751
|
function jqLiteRemoveData(element, name) {
|
|
1748
1752
|
const expandoId = element[EXPANDO];
|
|
1749
|
-
const expandoStore = expandoId &&
|
|
1753
|
+
const expandoStore = expandoId && CACHE.get(expandoId);
|
|
1750
1754
|
|
|
1751
1755
|
if (expandoStore) {
|
|
1752
1756
|
if (name) {
|
|
@@ -1767,7 +1771,7 @@
|
|
|
1767
1771
|
*/
|
|
1768
1772
|
function jqLiteExpandoStore(element, createIfNecessary = false) {
|
|
1769
1773
|
let expandoId = element[EXPANDO];
|
|
1770
|
-
let expandoStore = expandoId &&
|
|
1774
|
+
let expandoStore = expandoId && CACHE.get(expandoId);
|
|
1771
1775
|
|
|
1772
1776
|
if (createIfNecessary && !expandoStore) {
|
|
1773
1777
|
element[EXPANDO] = expandoId = jqNextId();
|
|
@@ -1776,7 +1780,7 @@
|
|
|
1776
1780
|
data: {},
|
|
1777
1781
|
handle: null,
|
|
1778
1782
|
};
|
|
1779
|
-
|
|
1783
|
+
CACHE.set(expandoId, expandoStore);
|
|
1780
1784
|
}
|
|
1781
1785
|
|
|
1782
1786
|
return expandoStore;
|
|
@@ -1793,15 +1797,12 @@
|
|
|
1793
1797
|
const data = expandoStore && expandoStore.data;
|
|
1794
1798
|
|
|
1795
1799
|
if (isSimpleSetter) {
|
|
1796
|
-
// data('key', value)
|
|
1797
1800
|
data[kebabToCamel(key)] = value;
|
|
1798
1801
|
} else {
|
|
1799
1802
|
if (massGetter) {
|
|
1800
|
-
// data()
|
|
1801
1803
|
return data;
|
|
1802
1804
|
}
|
|
1803
1805
|
if (isSimpleGetter) {
|
|
1804
|
-
// data('key')
|
|
1805
1806
|
// don't force creation of expandoStore if it doesn't exist yet
|
|
1806
1807
|
return data && data[kebabToCamel(key)];
|
|
1807
1808
|
}
|
|
@@ -1948,7 +1949,7 @@
|
|
|
1948
1949
|
|
|
1949
1950
|
function jqLiteCleanData(nodes) {
|
|
1950
1951
|
for (let i = 0, ii = nodes.length; i < ii; i++) {
|
|
1951
|
-
var events = (
|
|
1952
|
+
var events = (CACHE.get(nodes[i][EXPANDO]) || {}).events;
|
|
1952
1953
|
if (events && events.$destroy) {
|
|
1953
1954
|
jqLite(nodes[i]).triggerHandler("$destroy");
|
|
1954
1955
|
}
|
|
@@ -2083,8 +2084,6 @@
|
|
|
2083
2084
|
let key;
|
|
2084
2085
|
const nodeCount = this.length;
|
|
2085
2086
|
|
|
2086
|
-
// jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
|
|
2087
|
-
// in a way that survives minification.
|
|
2088
2087
|
// jqLiteEmpty takes no arguments but is a setter.
|
|
2089
2088
|
if (
|
|
2090
2089
|
fn !== jqLiteEmpty &&
|
|
@@ -2094,7 +2093,6 @@
|
|
|
2094
2093
|
// we are a write, but the object properties are the key/values
|
|
2095
2094
|
for (i = 0; i < nodeCount; i++) {
|
|
2096
2095
|
if (fn === jqLiteData) {
|
|
2097
|
-
// data() takes the whole object in jQuery
|
|
2098
2096
|
fn(this[i], arg1);
|
|
2099
2097
|
} else {
|
|
2100
2098
|
for (key in arg1) {
|
|
@@ -16737,66 +16735,6 @@
|
|
|
16737
16735
|
};
|
|
16738
16736
|
}
|
|
16739
16737
|
|
|
16740
|
-
/**
|
|
16741
|
-
* @ngdoc directive
|
|
16742
|
-
* @name ngSwitch
|
|
16743
|
-
* @restrict EA
|
|
16744
|
-
*
|
|
16745
|
-
* @description
|
|
16746
|
-
* The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression.
|
|
16747
|
-
* Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location
|
|
16748
|
-
* as specified in the template.
|
|
16749
|
-
*
|
|
16750
|
-
* The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it
|
|
16751
|
-
* from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element
|
|
16752
|
-
* matches the value obtained from the evaluated expression. In other words, you define a container element
|
|
16753
|
-
* (where you place the directive), place an expression on the **`on="..."` attribute**
|
|
16754
|
-
* (or the **`ng-switch="..."` attribute**), define any inner elements inside of the directive and place
|
|
16755
|
-
* a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on
|
|
16756
|
-
* expression is evaluated. If a matching expression is not found via a when attribute then an element with the default
|
|
16757
|
-
* attribute is displayed.
|
|
16758
|
-
*
|
|
16759
|
-
* <div class="alert alert-info">
|
|
16760
|
-
* Be aware that the attribute values to match against cannot be expressions. They are interpreted
|
|
16761
|
-
* as literal string values to match against.
|
|
16762
|
-
* For example, **`ng-switch-when="someVal"`** will match against the string `"someVal"` not against the
|
|
16763
|
-
* value of the expression `$scope.someVal`.
|
|
16764
|
-
* </div>
|
|
16765
|
-
|
|
16766
|
-
* @animations
|
|
16767
|
-
* | Animation | Occurs |
|
|
16768
|
-
* |----------------------------------|-------------------------------------|
|
|
16769
|
-
* | {@link ng.$animate#enter enter} | after the ngSwitch contents change and the matched child element is placed inside the container |
|
|
16770
|
-
* | {@link ng.$animate#leave leave} | after the ngSwitch contents change and just before the former contents are removed from the DOM |
|
|
16771
|
-
*
|
|
16772
|
-
* @usage
|
|
16773
|
-
*
|
|
16774
|
-
* ```
|
|
16775
|
-
* <ANY ng-switch="expression">
|
|
16776
|
-
* <ANY ng-switch-when="matchValue1">...</ANY>
|
|
16777
|
-
* <ANY ng-switch-when="matchValue2">...</ANY>
|
|
16778
|
-
* <ANY ng-switch-default>...</ANY>
|
|
16779
|
-
* </ANY>
|
|
16780
|
-
* ```
|
|
16781
|
-
*
|
|
16782
|
-
*
|
|
16783
|
-
* @scope
|
|
16784
|
-
* @priority 1200
|
|
16785
|
-
* @param {*} ngSwitch|on expression to match against <code>ng-switch-when</code>.
|
|
16786
|
-
* On child elements add:
|
|
16787
|
-
*
|
|
16788
|
-
* * `ngSwitchWhen`: the case statement to match against. If match then this
|
|
16789
|
-
* case will be displayed. If the same match appears multiple times, all the
|
|
16790
|
-
* elements will be displayed. It is possible to associate multiple values to
|
|
16791
|
-
* the same `ngSwitchWhen` by defining the optional attribute
|
|
16792
|
-
* `ngSwitchWhenSeparator`. The separator will be used to split the value of
|
|
16793
|
-
* the `ngSwitchWhen` attribute into multiple tokens, and the element will show
|
|
16794
|
-
* if any of the `ngSwitch` evaluates to any of these tokens.
|
|
16795
|
-
* * `ngSwitchDefault`: the default case when no other case match. If there
|
|
16796
|
-
* are multiple default cases, all of them will be displayed when no other
|
|
16797
|
-
* case match.
|
|
16798
|
-
*
|
|
16799
|
-
*/
|
|
16800
16738
|
const ngSwitchDirective = [
|
|
16801
16739
|
"$animate",
|
|
16802
16740
|
"$compile",
|
|
@@ -16806,11 +16744,13 @@
|
|
|
16806
16744
|
// asks for $scope to fool the BC controller module
|
|
16807
16745
|
controller: [
|
|
16808
16746
|
"$scope",
|
|
16809
|
-
|
|
16810
|
-
|
|
16747
|
+
class {
|
|
16748
|
+
constructor() {
|
|
16749
|
+
this.cases = {};
|
|
16750
|
+
}
|
|
16811
16751
|
},
|
|
16812
16752
|
],
|
|
16813
|
-
link(scope,
|
|
16753
|
+
link(scope, _element, attr, ngSwitchController) {
|
|
16814
16754
|
const watchExpr = attr.ngSwitch || attr.on;
|
|
16815
16755
|
let selectedTranscludes = [];
|
|
16816
16756
|
const selectedElements = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-wave/angular.ts",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/angular-ts.cjs.js",
|
|
7
7
|
"module": "dist/angular-ts.esm.js",
|
|
@@ -40,8 +40,5 @@
|
|
|
40
40
|
"sinon": "latest",
|
|
41
41
|
"typescript": "latest",
|
|
42
42
|
"vite": "latest"
|
|
43
|
-
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
|
|
46
43
|
}
|
|
47
44
|
}
|
package/src/core/utils.js
CHANGED
|
@@ -617,6 +617,14 @@ export function includes(array, obj) {
|
|
|
617
617
|
return Array.prototype.indexOf.call(array, obj) !== -1;
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
+
/**
|
|
621
|
+
* Removes the first occurrence of a specified value from an array.
|
|
622
|
+
*
|
|
623
|
+
* @template T
|
|
624
|
+
* @param {Array<T>} array - The array from which to remove the value.
|
|
625
|
+
* @param {T} value - The value to remove.
|
|
626
|
+
* @returns {number} - The index of the removed value, or -1 if the value was not found.
|
|
627
|
+
*/
|
|
620
628
|
export function arrayRemove(array, value) {
|
|
621
629
|
const index = array.indexOf(value);
|
|
622
630
|
if (index >= 0) {
|
package/src/directive/switch.js
CHANGED
|
@@ -1,66 +1,6 @@
|
|
|
1
1
|
import { forEach } from "../core/utils";
|
|
2
2
|
import { getBlockNodes } from "../jqLite";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @ngdoc directive
|
|
6
|
-
* @name ngSwitch
|
|
7
|
-
* @restrict EA
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
|
-
* The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression.
|
|
11
|
-
* Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location
|
|
12
|
-
* as specified in the template.
|
|
13
|
-
*
|
|
14
|
-
* The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it
|
|
15
|
-
* from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element
|
|
16
|
-
* matches the value obtained from the evaluated expression. In other words, you define a container element
|
|
17
|
-
* (where you place the directive), place an expression on the **`on="..."` attribute**
|
|
18
|
-
* (or the **`ng-switch="..."` attribute**), define any inner elements inside of the directive and place
|
|
19
|
-
* a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on
|
|
20
|
-
* expression is evaluated. If a matching expression is not found via a when attribute then an element with the default
|
|
21
|
-
* attribute is displayed.
|
|
22
|
-
*
|
|
23
|
-
* <div class="alert alert-info">
|
|
24
|
-
* Be aware that the attribute values to match against cannot be expressions. They are interpreted
|
|
25
|
-
* as literal string values to match against.
|
|
26
|
-
* For example, **`ng-switch-when="someVal"`** will match against the string `"someVal"` not against the
|
|
27
|
-
* value of the expression `$scope.someVal`.
|
|
28
|
-
* </div>
|
|
29
|
-
|
|
30
|
-
* @animations
|
|
31
|
-
* | Animation | Occurs |
|
|
32
|
-
* |----------------------------------|-------------------------------------|
|
|
33
|
-
* | {@link ng.$animate#enter enter} | after the ngSwitch contents change and the matched child element is placed inside the container |
|
|
34
|
-
* | {@link ng.$animate#leave leave} | after the ngSwitch contents change and just before the former contents are removed from the DOM |
|
|
35
|
-
*
|
|
36
|
-
* @usage
|
|
37
|
-
*
|
|
38
|
-
* ```
|
|
39
|
-
* <ANY ng-switch="expression">
|
|
40
|
-
* <ANY ng-switch-when="matchValue1">...</ANY>
|
|
41
|
-
* <ANY ng-switch-when="matchValue2">...</ANY>
|
|
42
|
-
* <ANY ng-switch-default>...</ANY>
|
|
43
|
-
* </ANY>
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @scope
|
|
48
|
-
* @priority 1200
|
|
49
|
-
* @param {*} ngSwitch|on expression to match against <code>ng-switch-when</code>.
|
|
50
|
-
* On child elements add:
|
|
51
|
-
*
|
|
52
|
-
* * `ngSwitchWhen`: the case statement to match against. If match then this
|
|
53
|
-
* case will be displayed. If the same match appears multiple times, all the
|
|
54
|
-
* elements will be displayed. It is possible to associate multiple values to
|
|
55
|
-
* the same `ngSwitchWhen` by defining the optional attribute
|
|
56
|
-
* `ngSwitchWhenSeparator`. The separator will be used to split the value of
|
|
57
|
-
* the `ngSwitchWhen` attribute into multiple tokens, and the element will show
|
|
58
|
-
* if any of the `ngSwitch` evaluates to any of these tokens.
|
|
59
|
-
* * `ngSwitchDefault`: the default case when no other case match. If there
|
|
60
|
-
* are multiple default cases, all of them will be displayed when no other
|
|
61
|
-
* case match.
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
4
|
export const ngSwitchDirective = [
|
|
65
5
|
"$animate",
|
|
66
6
|
"$compile",
|
|
@@ -70,11 +10,13 @@ export const ngSwitchDirective = [
|
|
|
70
10
|
// asks for $scope to fool the BC controller module
|
|
71
11
|
controller: [
|
|
72
12
|
"$scope",
|
|
73
|
-
|
|
74
|
-
|
|
13
|
+
class {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.cases = {};
|
|
16
|
+
}
|
|
75
17
|
},
|
|
76
18
|
],
|
|
77
|
-
link(scope,
|
|
19
|
+
link(scope, _element, attr, ngSwitchController) {
|
|
78
20
|
const watchExpr = attr.ngSwitch || attr.on;
|
|
79
21
|
let selectedTranscludes = [];
|
|
80
22
|
const selectedElements = [];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/\*\*
|
|
2
|
+
|
|
3
|
+
- @ngdoc directive
|
|
4
|
+
- @name ngSwitch
|
|
5
|
+
- @restrict EA
|
|
6
|
+
-
|
|
7
|
+
- @description
|
|
8
|
+
- The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression.
|
|
9
|
+
- Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location
|
|
10
|
+
- as specified in the template.
|
|
11
|
+
-
|
|
12
|
+
- The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it
|
|
13
|
+
- from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element
|
|
14
|
+
- matches the value obtained from the evaluated expression. In other words, you define a container element
|
|
15
|
+
- (where you place the directive), place an expression on the **`on="..."` attribute**
|
|
16
|
+
- (or the **`ng-switch="..."` attribute**), define any inner elements inside of the directive and place
|
|
17
|
+
- a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on
|
|
18
|
+
- expression is evaluated. If a matching expression is not found via a when attribute then an element with the default
|
|
19
|
+
- attribute is displayed.
|
|
20
|
+
-
|
|
21
|
+
- <div class="alert alert-info">
|
|
22
|
+
- Be aware that the attribute values to match against cannot be expressions. They are interpreted
|
|
23
|
+
- as literal string values to match against.
|
|
24
|
+
- For example, **`ng-switch-when="someVal"`** will match against the string `"someVal"` not against the
|
|
25
|
+
- value of the expression `$scope.someVal`.
|
|
26
|
+
- </div>
|
|
27
|
+
|
|
28
|
+
- @animations
|
|
29
|
+
- | Animation | Occurs |
|
|
30
|
+
- |----------------------------------|-------------------------------------|
|
|
31
|
+
- | {@link ng.$animate#enter enter} | after the ngSwitch contents change and the matched child element is placed inside the container |
|
|
32
|
+
- | {@link ng.$animate#leave leave} | after the ngSwitch contents change and just before the former contents are removed from the DOM |
|
|
33
|
+
-
|
|
34
|
+
- @usage
|
|
35
|
+
-
|
|
36
|
+
- ```
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- <ANY ng-switch="expression">
|
|
41
|
+
- <ANY ng-switch-when="matchValue1">...</ANY>
|
|
42
|
+
- <ANY ng-switch-when="matchValue2">...</ANY>
|
|
43
|
+
- <ANY ng-switch-default>...</ANY>
|
|
44
|
+
- </ANY>
|
|
45
|
+
- ```
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
-
|
|
50
|
+
-
|
|
51
|
+
- @scope
|
|
52
|
+
- @priority 1200
|
|
53
|
+
- @param {\*} ngSwitch|on expression to match against <code>ng-switch-when</code>.
|
|
54
|
+
- On child elements add:
|
|
55
|
+
-
|
|
56
|
+
- - `ngSwitchWhen`: the case statement to match against. If match then this
|
|
57
|
+
- case will be displayed. If the same match appears multiple times, all the
|
|
58
|
+
- elements will be displayed. It is possible to associate multiple values to
|
|
59
|
+
- the same `ngSwitchWhen` by defining the optional attribute
|
|
60
|
+
- `ngSwitchWhenSeparator`. The separator will be used to split the value of
|
|
61
|
+
- the `ngSwitchWhen` attribute into multiple tokens, and the element will show
|
|
62
|
+
- if any of the `ngSwitch` evaluates to any of these tokens.
|
|
63
|
+
- - `ngSwitchDefault`: the default case when no other case match. If there
|
|
64
|
+
- are multiple default cases, all of them will be displayed when no other
|
|
65
|
+
- case match.
|
|
66
|
+
- \*/
|
package/src/jqLite.js
CHANGED
|
@@ -94,17 +94,8 @@ import { CACHE, EXPANDO } from "./core/cache";
|
|
|
94
94
|
* @returns {Object} jQuery object.
|
|
95
95
|
*/
|
|
96
96
|
|
|
97
|
-
JQLite.cache = CACHE;
|
|
98
|
-
|
|
99
97
|
let jqId = 1;
|
|
100
98
|
|
|
101
|
-
/**
|
|
102
|
-
* !!! This is an undocumented "private" function !!!
|
|
103
|
-
* @param {JQLite|Element} node
|
|
104
|
-
* @returns
|
|
105
|
-
*/
|
|
106
|
-
JQLite._data = (node) => JQLite.cache.get(node[EXPANDO]) || {};
|
|
107
|
-
|
|
108
99
|
function jqNextId() {
|
|
109
100
|
return ++jqId;
|
|
110
101
|
}
|
|
@@ -289,6 +280,11 @@ export function JQLite(element) {
|
|
|
289
280
|
}
|
|
290
281
|
export var jqLite = JQLite;
|
|
291
282
|
|
|
283
|
+
/**
|
|
284
|
+
* @param {Element} element
|
|
285
|
+
* @param {boolean} [onlyDescendants]
|
|
286
|
+
* @returns {void}
|
|
287
|
+
*/
|
|
292
288
|
export function dealoc(element, onlyDescendants) {
|
|
293
289
|
if (!element) return;
|
|
294
290
|
if (!onlyDescendants && elementAcceptsData(element))
|
|
@@ -307,13 +303,13 @@ export function dealoc(element, onlyDescendants) {
|
|
|
307
303
|
*/
|
|
308
304
|
function removeIfEmptyData(element) {
|
|
309
305
|
const expandoId = element[EXPANDO];
|
|
310
|
-
const { events, data } =
|
|
306
|
+
const { events, data } = CACHE.get(expandoId);
|
|
311
307
|
|
|
312
308
|
if (
|
|
313
309
|
(!data || !Object.keys(data).length) &&
|
|
314
310
|
(!events || !Object.keys(events).length)
|
|
315
311
|
) {
|
|
316
|
-
|
|
312
|
+
CACHE.delete(expandoId);
|
|
317
313
|
element[EXPANDO] = undefined; // don't delete DOM expandos. IE and Chrome don't like it
|
|
318
314
|
}
|
|
319
315
|
}
|
|
@@ -341,8 +337,8 @@ function jqLiteOff(element, type, fn, unsupported) {
|
|
|
341
337
|
} else {
|
|
342
338
|
const removeHandler = function (type) {
|
|
343
339
|
const listenerFns = events[type];
|
|
344
|
-
if (isDefined(fn)) {
|
|
345
|
-
arrayRemove(listenerFns
|
|
340
|
+
if (isDefined(fn) && isArray(listenerFns)) {
|
|
341
|
+
arrayRemove(listenerFns, fn);
|
|
346
342
|
}
|
|
347
343
|
if (!(isDefined(fn) && listenerFns && listenerFns.length > 0)) {
|
|
348
344
|
element.removeEventListener(type, handle);
|
|
@@ -370,7 +366,7 @@ function jqLiteOff(element, type, fn, unsupported) {
|
|
|
370
366
|
*/
|
|
371
367
|
function jqLiteRemoveData(element, name) {
|
|
372
368
|
const expandoId = element[EXPANDO];
|
|
373
|
-
const expandoStore = expandoId &&
|
|
369
|
+
const expandoStore = expandoId && CACHE.get(expandoId);
|
|
374
370
|
|
|
375
371
|
if (expandoStore) {
|
|
376
372
|
if (name) {
|
|
@@ -391,7 +387,7 @@ function jqLiteRemoveData(element, name) {
|
|
|
391
387
|
*/
|
|
392
388
|
function jqLiteExpandoStore(element, createIfNecessary = false) {
|
|
393
389
|
let expandoId = element[EXPANDO];
|
|
394
|
-
let expandoStore = expandoId &&
|
|
390
|
+
let expandoStore = expandoId && CACHE.get(expandoId);
|
|
395
391
|
|
|
396
392
|
if (createIfNecessary && !expandoStore) {
|
|
397
393
|
element[EXPANDO] = expandoId = jqNextId();
|
|
@@ -400,7 +396,7 @@ function jqLiteExpandoStore(element, createIfNecessary = false) {
|
|
|
400
396
|
data: {},
|
|
401
397
|
handle: null,
|
|
402
398
|
};
|
|
403
|
-
|
|
399
|
+
CACHE.set(expandoId, expandoStore);
|
|
404
400
|
}
|
|
405
401
|
|
|
406
402
|
return expandoStore;
|
|
@@ -417,15 +413,12 @@ function jqLiteData(element, key, value) {
|
|
|
417
413
|
const data = expandoStore && expandoStore.data;
|
|
418
414
|
|
|
419
415
|
if (isSimpleSetter) {
|
|
420
|
-
// data('key', value)
|
|
421
416
|
data[kebabToCamel(key)] = value;
|
|
422
417
|
} else {
|
|
423
418
|
if (massGetter) {
|
|
424
|
-
// data()
|
|
425
419
|
return data;
|
|
426
420
|
}
|
|
427
421
|
if (isSimpleGetter) {
|
|
428
|
-
// data('key')
|
|
429
422
|
// don't force creation of expandoStore if it doesn't exist yet
|
|
430
423
|
return data && data[kebabToCamel(key)];
|
|
431
424
|
}
|
|
@@ -572,7 +565,7 @@ export function getBooleanAttrName(element, name) {
|
|
|
572
565
|
|
|
573
566
|
export function jqLiteCleanData(nodes) {
|
|
574
567
|
for (let i = 0, ii = nodes.length; i < ii; i++) {
|
|
575
|
-
var events = (
|
|
568
|
+
var events = (CACHE.get(nodes[i][EXPANDO]) || {}).events;
|
|
576
569
|
if (events && events.$destroy) {
|
|
577
570
|
jqLite(nodes[i]).triggerHandler("$destroy");
|
|
578
571
|
}
|
|
@@ -707,8 +700,6 @@ forEach(
|
|
|
707
700
|
let key;
|
|
708
701
|
const nodeCount = this.length;
|
|
709
702
|
|
|
710
|
-
// jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
|
|
711
|
-
// in a way that survives minification.
|
|
712
703
|
// jqLiteEmpty takes no arguments but is a setter.
|
|
713
704
|
if (
|
|
714
705
|
fn !== jqLiteEmpty &&
|
|
@@ -718,7 +709,6 @@ forEach(
|
|
|
718
709
|
// we are a write, but the object properties are the key/values
|
|
719
710
|
for (i = 0; i < nodeCount; i++) {
|
|
720
711
|
if (fn === jqLiteData) {
|
|
721
|
-
// data() takes the whole object in jQuery
|
|
722
712
|
fn(this[i], arg1);
|
|
723
713
|
} else {
|
|
724
714
|
for (key in arg1) {
|
package/test/jqlite.spec.js
CHANGED
|
@@ -228,18 +228,6 @@ describe("jqLite", () => {
|
|
|
228
228
|
});
|
|
229
229
|
});
|
|
230
230
|
|
|
231
|
-
describe("_data", () => {
|
|
232
|
-
it("should provide access to the events present on the element", () => {
|
|
233
|
-
const element = jqLite("<i>foo</i>");
|
|
234
|
-
// TODO: REMOVE angular becomes TESTED
|
|
235
|
-
angular.element = jqLite;
|
|
236
|
-
expect(angular.element._data(element[0]).events).toBeUndefined();
|
|
237
|
-
|
|
238
|
-
element.on("click", () => {});
|
|
239
|
-
expect(angular.element._data(element[0]).events.click).toBeDefined();
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
231
|
describe("inheritedData", () => {
|
|
244
232
|
it("should retrieve data attached to the current element", () => {
|
|
245
233
|
const element = jqLite("<i>foo</i>");
|
|
@@ -541,7 +529,7 @@ describe("jqLite", () => {
|
|
|
541
529
|
|
|
542
530
|
it("should not break on cleanData(), if element has no data", () => {
|
|
543
531
|
const selected = jqLite([a, b, c]);
|
|
544
|
-
spyOn(
|
|
532
|
+
spyOn(CACHE, "get").and.returnValue(undefined);
|
|
545
533
|
expect(() => {
|
|
546
534
|
jqLite.cleanData(selected);
|
|
547
535
|
}).not.toThrow();
|
package/test/ng/compile.spec.js
CHANGED
|
@@ -13903,7 +13903,7 @@ describe("$compile", () => {
|
|
|
13903
13903
|
firstRepeatedElem = element.children(".ng-scope").eq(0);
|
|
13904
13904
|
|
|
13905
13905
|
expect(firstRepeatedElem.data("$scope")).toBeDefined();
|
|
13906
|
-
privateData =
|
|
13906
|
+
privateData = CACHE.get(firstRepeatedElem[0]);
|
|
13907
13907
|
expect(privateData.events).toBeDefined();
|
|
13908
13908
|
|
|
13909
13909
|
expect(privateData.events.click).toBeDefined();
|
|
@@ -13919,7 +13919,7 @@ describe("$compile", () => {
|
|
|
13919
13919
|
|
|
13920
13920
|
expect(destroyCount).toBe(2);
|
|
13921
13921
|
expect(firstRepeatedElem.data("$scope")).not.toBeDefined();
|
|
13922
|
-
privateData =
|
|
13922
|
+
privateData = CACHE.get(firstRepeatedElem[0]);
|
|
13923
13923
|
expect(privateData && privateData.events).not.toBeDefined();
|
|
13924
13924
|
}
|
|
13925
13925
|
|