@angular-wave/angular.ts 0.4.1 → 0.4.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.
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +7 -7
- package/src/angular.spec.js +1 -264
- package/src/animations/animate-css-driver.js +2 -2
- package/src/animations/animate-css.js +7 -8
- package/src/animations/animate-js-driver.js +1 -3
- package/src/animations/animate-js.js +4 -4
- package/src/animations/animate-queue.js +6 -6
- package/src/animations/animation.js +3 -3
- package/src/animations/shared.js +16 -14
- package/src/core/compile/attributes.js +2 -3
- package/src/core/compile/compile.js +248 -232
- package/src/core/compile/compile.spec.js +46 -51
- package/src/core/compile/compile.test.js +1 -1
- package/src/core/interpolate/interpolate.js +2 -2
- package/src/core/interval/interval.test.js +1 -1
- package/src/core/{parser/lexer.html → parse/ast/ast.html} +1 -1
- package/src/core/{parser → parse/ast}/ast.js +43 -29
- package/src/core/parse/ast/ast.spec.js +1462 -0
- package/src/core/parse/ast/ast.test.js +10 -0
- package/src/core/{parser → parse}/interpreter.js +10 -10
- package/src/core/parse/lexer/lexer.html +18 -0
- package/src/core/{parser → parse/lexer}/lexer.js +1 -1
- package/src/core/{parser → parse/lexer}/lexer.spec.js +2 -2
- package/src/core/parse/lexer/lexer.test.js +10 -0
- package/src/core/{parser → parse}/parse.html +1 -1
- package/src/core/{parser → parse}/parse.js +6 -6
- package/src/core/{parser → parse}/parse.spec.js +6 -1725
- package/src/core/parse/parse.test.js +10 -0
- package/src/core/parse/parser/parser.html +18 -0
- package/src/core/{parser → parse/parser}/parser.js +6 -6
- package/src/core/parse/parser/parser.spec.js +8 -0
- package/src/core/parse/parser/parser.test.js +10 -0
- package/src/core/sce/sce.js +1 -2
- package/src/core/scope/scope.js +4 -5
- package/src/directive/attrs/attrs.test.js +11 -0
- package/src/directive/attrs/boolean.html +18 -0
- package/src/directive/attrs/boolean.test.js +11 -0
- package/src/directive/attrs/element-style.html +21 -0
- package/src/directive/attrs/element-style.test.js +11 -0
- package/src/directive/bind/bing-html.spec.js +1 -1
- package/src/directive/class/class.js +1 -1
- package/src/directive/form/form.js +12 -19
- package/src/directive/if/if.spec.js +2 -3
- package/src/directive/if/if.test.js +1 -2
- package/src/directive/include/include.js +2 -2
- package/src/directive/input/input.js +1 -2
- package/src/directive/input/input.spec.js +187 -191
- package/src/directive/list/list.js +2 -2
- package/src/directive/model/model.js +14 -19
- package/src/directive/model-options/model-options.js +22 -26
- package/src/directive/options/options.js +1 -3
- package/src/directive/options/options.spec.js +3 -4
- package/src/directive/repeat/repeat.js +2 -2
- package/src/directive/repeat/repeat.spec.js +48 -57
- package/src/directive/select/select.spec.js +9 -10
- package/src/directive/switch/switch.js +1 -2
- package/src/directive/validators/validators.js +3 -3
- package/src/public.js +1 -1
- package/src/router/directives/state-directives.js +18 -16
- package/src/router/directives/view-directive.js +2 -2
- package/src/router/state/views.js +2 -2
- package/src/router/url/url-service.js +2 -8
- package/src/router/url/url-service.spec.js +3 -4
- package/src/services/http/http.js +5 -6
- package/src/services/http-backend/http-backend.js +19 -17
- package/src/shared/common.js +5 -8
- package/src/shared/jqlite/jqlite.js +14 -12
- package/src/shared/jqlite/jqlite.spec.js +2 -2
- package/src/shared/utils.js +15 -92
- package/types/animations/shared.d.ts +1 -1
- package/types/core/compile/compile.d.ts +1 -1
- package/types/core/interpolate/interpolate.d.ts +1 -1
- package/types/core/{parser → parse/ast}/ast.d.ts +17 -17
- package/types/core/{parser → parse}/interpreter.d.ts +7 -7
- package/types/core/{parser → parse/parser}/parser.d.ts +8 -8
- package/types/core/scope/scope.d.ts +3 -3
- package/types/directive/class/class.d.ts +3 -3
- package/types/directive/form/form.d.ts +1 -0
- package/types/directive/model/model.d.ts +6 -6
- package/types/directive/validators/validators.d.ts +3 -3
- package/types/shared/common.d.ts +0 -1
- package/types/shared/utils.d.ts +0 -35
- package/src/core/parser/parser.test.js +0 -19
- /package/src/core/{parser → parse}/ast-type.js +0 -0
- /package/src/core/{parser → parse}/parse.md +0 -0
- /package/types/core/{parser → parse}/ast-type.d.ts +0 -0
- /package/types/core/{parser → parse/lexer}/lexer.d.ts +0 -0
- /package/types/core/{parser → parse}/parse.d.ts +0 -0
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
minErr,
|
|
13
13
|
assertArg,
|
|
14
14
|
assertNotHasOwnProperty,
|
|
15
|
-
forEach,
|
|
16
15
|
isDefined,
|
|
17
16
|
isFunction,
|
|
18
17
|
isObject,
|
|
@@ -74,7 +73,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
74
73
|
|
|
75
74
|
const bindings = Object.create(null);
|
|
76
75
|
|
|
77
|
-
forEach(
|
|
76
|
+
Object.entries(scope).forEach(([scopeName, definition]) => {
|
|
78
77
|
definition = definition.trim();
|
|
79
78
|
|
|
80
79
|
if (definition in bindingCache) {
|
|
@@ -337,7 +336,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
337
336
|
|
|
338
337
|
// Copy any annotation properties (starting with $) over to the factory and controller constructor functions
|
|
339
338
|
// These could be used by libraries such as the new component router
|
|
340
|
-
forEach(
|
|
339
|
+
Object.entries(options).forEach(([key, val]) => {
|
|
341
340
|
if (key.charAt(0) === "$") {
|
|
342
341
|
factory[key] = val;
|
|
343
342
|
// Don't try to copy over annotations to named controller
|
|
@@ -528,7 +527,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
528
527
|
* @param {*} $interpolate
|
|
529
528
|
* @param {import("../exception-handler").ErrorHandler} $exceptionHandler
|
|
530
529
|
* @param {*} $templateRequest
|
|
531
|
-
* @param {import("../
|
|
530
|
+
* @param {import("../parse/parse").ParseService} $parse
|
|
532
531
|
* @param {*} $controller
|
|
533
532
|
* @param {import('../scope/scope').Scope} $rootScope
|
|
534
533
|
* @param {*} $sce
|
|
@@ -1352,51 +1351,57 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
1352
1351
|
}
|
|
1353
1352
|
|
|
1354
1353
|
// Bind the required controllers to the controller, if `require` is an object and `bindToController` is truthy
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1354
|
+
if (controllerDirectives) {
|
|
1355
|
+
Object.entries(controllerDirectives).forEach(
|
|
1356
|
+
([name, controllerDirective]) => {
|
|
1357
|
+
const { require } = controllerDirective;
|
|
1358
|
+
if (
|
|
1359
|
+
controllerDirective.bindToController &&
|
|
1360
|
+
!Array.isArray(require) &&
|
|
1361
|
+
isObject(require)
|
|
1362
|
+
) {
|
|
1363
|
+
extend(
|
|
1364
|
+
elementControllers[name].instance,
|
|
1365
|
+
getControllers(name, require, $element, elementControllers),
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1368
1371
|
|
|
1369
1372
|
// Handle the init and destroy lifecycle hooks on all controllers that have them
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1373
|
+
if (elementControllers) {
|
|
1374
|
+
Object.values(elementControllers).forEach((controller) => {
|
|
1375
|
+
const controllerInstance = controller.instance;
|
|
1376
|
+
if (isFunction(controllerInstance.$onChanges)) {
|
|
1377
|
+
try {
|
|
1378
|
+
controllerInstance.$onChanges(
|
|
1379
|
+
controller.bindingInfo.initialChanges,
|
|
1380
|
+
);
|
|
1381
|
+
} catch (e) {
|
|
1382
|
+
$exceptionHandler(e);
|
|
1383
|
+
}
|
|
1379
1384
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1385
|
+
if (isFunction(controllerInstance.$onInit)) {
|
|
1386
|
+
try {
|
|
1387
|
+
controllerInstance.$onInit();
|
|
1388
|
+
} catch (e) {
|
|
1389
|
+
$exceptionHandler(e);
|
|
1390
|
+
}
|
|
1386
1391
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1392
|
+
if (isFunction(controllerInstance.$doCheck)) {
|
|
1393
|
+
controllerScope.$watch(() => {
|
|
1394
|
+
controllerInstance.$doCheck();
|
|
1395
|
+
});
|
|
1390
1396
|
controllerInstance.$doCheck();
|
|
1391
|
-
}
|
|
1392
|
-
controllerInstance.$
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
});
|
|
1397
|
+
}
|
|
1398
|
+
if (isFunction(controllerInstance.$onDestroy)) {
|
|
1399
|
+
controllerScope.$on("$destroy", () => {
|
|
1400
|
+
controllerInstance.$onDestroy();
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1400
1405
|
|
|
1401
1406
|
// PRELINKING
|
|
1402
1407
|
for (i = 0, ii = preLinkFns.length; i < ii; i++) {
|
|
@@ -1456,13 +1461,15 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
1456
1461
|
);
|
|
1457
1462
|
}
|
|
1458
1463
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
controllerInstance.$postLink
|
|
1464
|
-
|
|
1465
|
-
|
|
1464
|
+
if (elementControllers) {
|
|
1465
|
+
// Trigger $postLink lifecycle hooks
|
|
1466
|
+
Object.values(elementControllers).forEach((controller) => {
|
|
1467
|
+
const controllerInstance = controller.instance;
|
|
1468
|
+
if (isFunction(controllerInstance.$postLink)) {
|
|
1469
|
+
controllerInstance.$postLink();
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1466
1473
|
|
|
1467
1474
|
// This is the function that is injected as `$transclude`.
|
|
1468
1475
|
// Note: all arguments are optional!
|
|
@@ -1683,42 +1690,45 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
1683
1690
|
const filledSlots = Object.create(null);
|
|
1684
1691
|
|
|
1685
1692
|
// Parse the element selectors
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1693
|
+
Object.entries(directiveValue).forEach(
|
|
1694
|
+
([slotName, elementSelector]) => {
|
|
1695
|
+
// If an element selector starts with a ? then it is optional
|
|
1696
|
+
const optional = elementSelector.charAt(0) === "?";
|
|
1697
|
+
elementSelector = optional
|
|
1698
|
+
? elementSelector.substring(1)
|
|
1699
|
+
: elementSelector;
|
|
1700
|
+
|
|
1701
|
+
slotMap[elementSelector] = slotName;
|
|
1702
|
+
|
|
1703
|
+
// We explicitly assign `null` since this implies that a slot was defined but not filled.
|
|
1704
|
+
// Later when calling boundTransclusion functions with a slot name we only error if the
|
|
1705
|
+
// slot is `undefined`
|
|
1706
|
+
slots[slotName] = null;
|
|
1707
|
+
|
|
1708
|
+
// filledSlots contains `true` for all slots that are either optional or have been
|
|
1709
|
+
// filled. This is used to check that we have not missed any required slots
|
|
1710
|
+
filledSlots[slotName] = optional;
|
|
1711
|
+
},
|
|
1712
|
+
);
|
|
1704
1713
|
|
|
1705
1714
|
// Add the matching elements into their slot
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
slots[slotName]
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1715
|
+
JQLite($compileNode[0].childNodes)
|
|
1716
|
+
.elements()
|
|
1717
|
+
.forEach((node) => {
|
|
1718
|
+
const slotName =
|
|
1719
|
+
slotMap[directiveNormalize(getNodeName(node))];
|
|
1720
|
+
if (slotName) {
|
|
1721
|
+
filledSlots[slotName] = true;
|
|
1722
|
+
slots[slotName] =
|
|
1723
|
+
slots[slotName] || document.createDocumentFragment();
|
|
1724
|
+
slots[slotName].appendChild(node);
|
|
1725
|
+
} else {
|
|
1726
|
+
$template.appendChild(node);
|
|
1727
|
+
}
|
|
1728
|
+
});
|
|
1719
1729
|
|
|
1720
1730
|
// Check for required slots that were not filled
|
|
1721
|
-
forEach(
|
|
1731
|
+
Object.entries(filledSlots).forEach(([slotName, filled]) => {
|
|
1722
1732
|
if (!filled) {
|
|
1723
1733
|
throw $compileMinErr(
|
|
1724
1734
|
"reqslot",
|
|
@@ -2009,7 +2019,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2009
2019
|
}
|
|
2010
2020
|
} else if (isObject(require)) {
|
|
2011
2021
|
value = {};
|
|
2012
|
-
forEach(
|
|
2022
|
+
Object.entries(require).forEach(([property, controller]) => {
|
|
2013
2023
|
value[property] = getControllers(
|
|
2014
2024
|
directiveName,
|
|
2015
2025
|
controller,
|
|
@@ -2184,7 +2194,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2184
2194
|
const dstAttr = dst.$attr;
|
|
2185
2195
|
|
|
2186
2196
|
// reapply the old attributes to the new element
|
|
2187
|
-
forEach(
|
|
2197
|
+
Object.entries(dst).forEach(([key, value]) => {
|
|
2188
2198
|
if (key.charAt(0) !== "$") {
|
|
2189
2199
|
if (src[key] && src[key] !== value) {
|
|
2190
2200
|
if (value.length) {
|
|
@@ -2198,7 +2208,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2198
2208
|
});
|
|
2199
2209
|
|
|
2200
2210
|
// copy the new attributes on the old attrs object
|
|
2201
|
-
forEach(
|
|
2211
|
+
Object.entries(src).forEach(([key, value]) => {
|
|
2202
2212
|
// Check if we already set this attribute in the loop above.
|
|
2203
2213
|
// `dst` will never contain hasOwnProperty as DOM parser won't let it.
|
|
2204
2214
|
// You will get an "InvalidCharacterError: DOM Exception 5" error if you
|
|
@@ -2309,11 +2319,13 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2309
2319
|
postLinkFns,
|
|
2310
2320
|
previousCompileContext,
|
|
2311
2321
|
);
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2322
|
+
if ($rootElement) {
|
|
2323
|
+
Object.entries($rootElement).forEach(([i, node]) => {
|
|
2324
|
+
if (node === compileNode) {
|
|
2325
|
+
$rootElement[i] = $compileNode[0];
|
|
2326
|
+
}
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2317
2329
|
afterTemplateChildLinkFn = compileNodes(
|
|
2318
2330
|
$compileNode[0].childNodes,
|
|
2319
2331
|
childTranscludeFn,
|
|
@@ -2856,161 +2868,165 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2856
2868
|
const initialChanges = {};
|
|
2857
2869
|
let changes;
|
|
2858
2870
|
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
removeWatch = attrs.$observe(attrName, (value) => {
|
|
2876
|
-
if (isString(value) || isBoolean(value)) {
|
|
2877
|
-
const oldValue = destination[scopeName];
|
|
2878
|
-
recordChanges(scopeName, value, oldValue);
|
|
2879
|
-
destination[scopeName] = value;
|
|
2871
|
+
if (bindings) {
|
|
2872
|
+
Object.entries(bindings).forEach(([scopeName, definition]) => {
|
|
2873
|
+
const { attrName } = definition;
|
|
2874
|
+
const { optional } = definition;
|
|
2875
|
+
const { mode } = definition; // @, =, <, or &
|
|
2876
|
+
let lastValue;
|
|
2877
|
+
let parentGet;
|
|
2878
|
+
let parentSet;
|
|
2879
|
+
let compare;
|
|
2880
|
+
let removeWatch;
|
|
2881
|
+
|
|
2882
|
+
switch (mode) {
|
|
2883
|
+
case "@":
|
|
2884
|
+
if (!optional && !Object.hasOwnProperty.call(attrs, attrName)) {
|
|
2885
|
+
strictBindingsCheck(attrName, directive.name);
|
|
2886
|
+
destination[scopeName] = attrs[attrName] = undefined;
|
|
2880
2887
|
}
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2888
|
+
removeWatch = attrs.$observe(attrName, (value) => {
|
|
2889
|
+
if (isString(value) || isBoolean(value)) {
|
|
2890
|
+
const oldValue = destination[scopeName];
|
|
2891
|
+
recordChanges(scopeName, value, oldValue);
|
|
2892
|
+
destination[scopeName] = value;
|
|
2893
|
+
}
|
|
2894
|
+
});
|
|
2895
|
+
attrs.$$observers[attrName].$$scope = scope;
|
|
2896
|
+
lastValue = attrs[attrName];
|
|
2897
|
+
if (isString(lastValue)) {
|
|
2898
|
+
// If the attribute has been provided then we trigger an interpolation to ensure
|
|
2899
|
+
// the value is there for use in the link fn
|
|
2900
|
+
destination[scopeName] = $interpolate(lastValue)(scope);
|
|
2901
|
+
} else if (isBoolean(lastValue)) {
|
|
2902
|
+
// If the attributes is one of the BOOLEAN_ATTR then AngularJS will have converted
|
|
2903
|
+
// the value to boolean rather than a string, so we special case this situation
|
|
2904
|
+
destination[scopeName] = lastValue;
|
|
2905
|
+
}
|
|
2906
|
+
initialChanges[scopeName] = new SimpleChange(
|
|
2907
|
+
UNINITALIZED_VALIED,
|
|
2908
|
+
destination[scopeName],
|
|
2909
|
+
);
|
|
2910
|
+
removeWatchCollection.push(removeWatch);
|
|
2911
|
+
break;
|
|
2899
2912
|
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2913
|
+
case "=":
|
|
2914
|
+
if (!Object.hasOwnProperty.call(attrs, attrName)) {
|
|
2915
|
+
if (optional) break;
|
|
2916
|
+
strictBindingsCheck(attrName, directive.name);
|
|
2917
|
+
attrs[attrName] = undefined;
|
|
2918
|
+
}
|
|
2919
|
+
if (optional && !attrs[attrName]) break;
|
|
2907
2920
|
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2921
|
+
parentGet = $parse(attrs[attrName]);
|
|
2922
|
+
if (parentGet.literal) {
|
|
2923
|
+
compare = equals;
|
|
2924
|
+
} else {
|
|
2925
|
+
compare = simpleCompare;
|
|
2926
|
+
}
|
|
2927
|
+
parentSet =
|
|
2928
|
+
parentGet.assign ||
|
|
2929
|
+
function () {
|
|
2930
|
+
// reset the change, or we will throw this exception on every $digest
|
|
2931
|
+
lastValue = destination[scopeName] = parentGet(scope);
|
|
2932
|
+
throw $compileMinErr(
|
|
2933
|
+
"nonassign",
|
|
2934
|
+
"Expression '{0}' in attribute '{1}' used with directive '{2}' is non-assignable!",
|
|
2935
|
+
attrs[attrName],
|
|
2936
|
+
attrName,
|
|
2937
|
+
directive.name,
|
|
2938
|
+
);
|
|
2939
|
+
};
|
|
2940
|
+
lastValue = destination[scopeName] = parentGet(scope);
|
|
2941
|
+
var parentValueWatch = function parentValueWatch(parentValue) {
|
|
2942
|
+
if (!compare(parentValue, destination[scopeName])) {
|
|
2943
|
+
// we are out of sync and need to copy
|
|
2944
|
+
if (!compare(parentValue, lastValue)) {
|
|
2945
|
+
// parent changed and it has precedence
|
|
2946
|
+
destination[scopeName] = parentValue;
|
|
2947
|
+
} else {
|
|
2948
|
+
// if the parent can be assigned then do so
|
|
2949
|
+
parentSet(scope, (parentValue = destination[scopeName]));
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
lastValue = parentValue;
|
|
2953
|
+
return lastValue;
|
|
2954
|
+
};
|
|
2955
|
+
parentValueWatch.$stateful = true;
|
|
2956
|
+
if (definition.collection) {
|
|
2957
|
+
removeWatch = scope.$watchCollection(
|
|
2922
2958
|
attrs[attrName],
|
|
2923
|
-
|
|
2924
|
-
|
|
2959
|
+
parentValueWatch,
|
|
2960
|
+
);
|
|
2961
|
+
} else {
|
|
2962
|
+
removeWatch = scope.$watch(
|
|
2963
|
+
$parse(attrs[attrName], parentValueWatch),
|
|
2964
|
+
null,
|
|
2965
|
+
parentGet.literal,
|
|
2925
2966
|
);
|
|
2926
|
-
};
|
|
2927
|
-
lastValue = destination[scopeName] = parentGet(scope);
|
|
2928
|
-
var parentValueWatch = function parentValueWatch(parentValue) {
|
|
2929
|
-
if (!compare(parentValue, destination[scopeName])) {
|
|
2930
|
-
// we are out of sync and need to copy
|
|
2931
|
-
if (!compare(parentValue, lastValue)) {
|
|
2932
|
-
// parent changed and it has precedence
|
|
2933
|
-
destination[scopeName] = parentValue;
|
|
2934
|
-
} else {
|
|
2935
|
-
// if the parent can be assigned then do so
|
|
2936
|
-
parentSet(scope, (parentValue = destination[scopeName]));
|
|
2937
|
-
}
|
|
2938
2967
|
}
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
};
|
|
2942
|
-
parentValueWatch.$stateful = true;
|
|
2943
|
-
if (definition.collection) {
|
|
2944
|
-
removeWatch = scope.$watchCollection(
|
|
2945
|
-
attrs[attrName],
|
|
2946
|
-
parentValueWatch,
|
|
2947
|
-
);
|
|
2948
|
-
} else {
|
|
2949
|
-
removeWatch = scope.$watch(
|
|
2950
|
-
$parse(attrs[attrName], parentValueWatch),
|
|
2951
|
-
null,
|
|
2952
|
-
parentGet.literal,
|
|
2953
|
-
);
|
|
2954
|
-
}
|
|
2955
|
-
removeWatchCollection.push(removeWatch);
|
|
2956
|
-
break;
|
|
2968
|
+
removeWatchCollection.push(removeWatch);
|
|
2969
|
+
break;
|
|
2957
2970
|
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2971
|
+
case "<":
|
|
2972
|
+
if (!Object.hasOwnProperty.call(attrs, attrName)) {
|
|
2973
|
+
if (optional) break;
|
|
2974
|
+
strictBindingsCheck(attrName, directive.name);
|
|
2975
|
+
attrs[attrName] = undefined;
|
|
2976
|
+
}
|
|
2977
|
+
if (optional && !attrs[attrName]) break;
|
|
2965
2978
|
|
|
2966
|
-
|
|
2967
|
-
|
|
2979
|
+
parentGet = $parse(attrs[attrName]);
|
|
2980
|
+
var isLiteral = parentGet.literal;
|
|
2968
2981
|
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2982
|
+
var initialValue = (destination[scopeName] = parentGet(scope));
|
|
2983
|
+
initialChanges[scopeName] = new SimpleChange(
|
|
2984
|
+
UNINITALIZED_VALIED,
|
|
2985
|
+
destination[scopeName],
|
|
2986
|
+
);
|
|
2974
2987
|
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2988
|
+
removeWatch = scope[
|
|
2989
|
+
definition.collection ? "$watchCollection" : "$watch"
|
|
2990
|
+
](parentGet, (newValue, oldValue) => {
|
|
2991
|
+
if (oldValue === newValue) {
|
|
2992
|
+
if (
|
|
2993
|
+
oldValue === initialValue ||
|
|
2994
|
+
(isLiteral && equals(oldValue, initialValue))
|
|
2995
|
+
) {
|
|
2996
|
+
return;
|
|
2997
|
+
}
|
|
2998
|
+
oldValue = initialValue;
|
|
2984
2999
|
}
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
destination[scopeName] = newValue;
|
|
2989
|
-
});
|
|
2990
|
-
|
|
2991
|
-
removeWatchCollection.push(removeWatch);
|
|
2992
|
-
break;
|
|
2993
|
-
|
|
2994
|
-
case "&":
|
|
2995
|
-
if (!optional && !Object.hasOwnProperty.call(attrs, attrName)) {
|
|
2996
|
-
strictBindingsCheck(attrName, directive.name);
|
|
2997
|
-
}
|
|
2998
|
-
// Don't assign Object.prototype method to scope
|
|
2999
|
-
parentGet = Object.prototype.hasOwnProperty.call(attrs, attrName)
|
|
3000
|
-
? $parse(attrs[attrName])
|
|
3001
|
-
: () => {};
|
|
3000
|
+
recordChanges(scopeName, newValue, oldValue);
|
|
3001
|
+
destination[scopeName] = newValue;
|
|
3002
|
+
});
|
|
3002
3003
|
|
|
3003
|
-
|
|
3004
|
-
if (parentGet.toString() === (() => {}).toString() && optional)
|
|
3004
|
+
removeWatchCollection.push(removeWatch);
|
|
3005
3005
|
break;
|
|
3006
3006
|
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3007
|
+
case "&":
|
|
3008
|
+
if (!optional && !Object.hasOwnProperty.call(attrs, attrName)) {
|
|
3009
|
+
strictBindingsCheck(attrName, directive.name);
|
|
3010
|
+
}
|
|
3011
|
+
// Don't assign Object.prototype method to scope
|
|
3012
|
+
parentGet = Object.prototype.hasOwnProperty.call(
|
|
3013
|
+
attrs,
|
|
3014
|
+
attrName,
|
|
3015
|
+
)
|
|
3016
|
+
? $parse(attrs[attrName])
|
|
3017
|
+
: () => {};
|
|
3018
|
+
|
|
3019
|
+
// Don't assign noop to destination if expression is not valid
|
|
3020
|
+
if (parentGet.toString() === (() => {}).toString() && optional)
|
|
3021
|
+
break;
|
|
3022
|
+
|
|
3023
|
+
destination[scopeName] = function (locals) {
|
|
3024
|
+
return parentGet(scope, locals);
|
|
3025
|
+
};
|
|
3026
|
+
break;
|
|
3027
|
+
}
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3014
3030
|
function recordChanges(key, currentValue, previousValue) {
|
|
3015
3031
|
if (
|
|
3016
3032
|
isFunction(destination.$onChanges) &&
|