@angular-wave/angular.ts 0.0.1 → 0.0.4
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/Makefile +1 -1
- package/dist/angular-ts.cjs.js +506 -1696
- package/dist/angular-ts.esm.js +506 -1696
- package/dist/angular-ts.umd.js +506 -1696
- package/package.json +1 -1
- package/public/README.md +1 -0
- package/src/animations/{animateCss.js → animate-css.js} +0 -1
- package/src/animations/animation.js +428 -431
- package/src/animations/module.js +9 -9
- package/src/core/cache.js +2 -0
- package/src/core/compile.js +6 -1102
- package/src/core/compile.md +1192 -0
- package/src/core/location.js +1 -1
- package/src/core/utils.js +1 -1
- package/src/directive/a.js +1 -1
- package/src/directive/attrs.js +1 -1
- package/src/directive/csp.md +89 -0
- package/src/directive/input.js +3 -3
- package/src/directive/{ngModel.js → model.js} +1 -1
- package/src/directive/select.js +5 -5
- package/src/jqLite.js +1 -22
- package/src/public.js +24 -24
- package/src/services/log.js +66 -116
- package/src/services/log.md +39 -0
- package/test/jqlite.spec.js +5 -35
- package/test/messages/messages.spec.js +1 -1
- package/test/ng/compile.spec.js +17 -16
- package/test/ng/directive/model-options.spec.js +1 -1
- package/test/ng/directive/model.spec.js +1 -1
- package/test/ng/directive/options.spec.js +61 -61
- package/test/ng/directive/select.spec.js +22 -22
- package/test/ng/http-backend.spec.js +1 -1
- package/test/ng/on.spec.js +1 -1
- package/test/ng/prop.spec.js +54 -62
- package/test/ng/sanitize-uri.spec.js +1 -1
- package/test/ng/scope.spec.js +1 -1
- package/test/original-test.html +1 -1
- package/types/jqlite.d.ts +1 -32
- package/dist/build/angular-mocks.js +0 -3757
- package/dist/build/angular-parse-ext.js +0 -1275
- package/dist/build/angular-resource.js +0 -911
- package/dist/build/angular-touch.js +0 -368
- package/src/core/attributes.js +0 -199
- package/src/directive/ngCsp.js +0 -82
- /package/{dist/build → legacy}/angular-animate.js +0 -0
- /package/{dist/build → legacy}/angular-aria.js +0 -0
- /package/{dist/build → legacy}/angular-message-format.js +0 -0
- /package/{dist/build → legacy}/angular-messages.js +0 -0
- /package/{dist/build → legacy}/angular-route.js +0 -0
- /package/{dist/build → legacy}/angular-sanitize.js +0 -0
- /package/{dist/build → legacy}/angular.js +0 -0
- /package/src/animations/{animateCache.js → animate-cache.js} +0 -0
- /package/src/animations/{animateChildrenDirective.js → animate-children-directive.js} +0 -0
- /package/src/animations/{animateCssDriver.js → animate-css-driver.js} +0 -0
- /package/src/animations/{animateJsDriver.js → animate-js-driver.js} +0 -0
- /package/src/animations/{animateJs.js → animate-js.js} +0 -0
- /package/src/animations/{animateQueue.js → animate-queue.js} +0 -0
- /package/src/animations/{ngAnimateSwap.js → animate-swap.js} +0 -0
- /package/src/animations/{rafScheduler.js → raf-scheduler.js} +0 -0
- /package/src/core/{animateCss.js → animate-css.js} +0 -0
- /package/src/core/{animateRunner.js → animate-runner.js} +0 -0
- /package/src/core/{exceptionHandler.js → exception-handler.js} +0 -0
- /package/src/core/{intervalFactory.js → interval-factory.js} +0 -0
- /package/src/core/{rootScope.js → root-scope.js} +0 -0
- /package/src/core/{sanitizeUri.js → sanitize-uri.js} +0 -0
- /package/src/core/{taskTrackerFactory.js → task-tracker-factory.js} +0 -0
- /package/src/directive/{ngClass.js → class.js} +0 -0
- /package/src/directive/{ngController.js → controller.js} +0 -0
- /package/src/directive/{ngIf.js → if.js} +0 -0
- /package/src/directive/{ngInclude.js → include.js} +0 -0
- /package/src/directive/{ngModelOptions.js → model-options.js} +0 -0
- /package/src/directive/{ngOptions.js → options.js} +0 -0
- /package/src/directive/{ngRef.js → ref.js} +0 -0
- /package/src/directive/{ngRepeat.js → repeat.js} +0 -0
- /package/src/directive/{ngShowHide.js → show-hide.js} +0 -0
- /package/src/directive/{ngSwitch.js → switch.js} +0 -0
- /package/src/directive/{ngTransclude.js → transclude.js} +0 -0
- /package/src/{routeToRegExp.js → route-to-reg-exp.js} +0 -0
- /package/src/services/{anchorScroll.js → anchor-scroll.js} +0 -0
- /package/src/services/{cacheFactory.js → cache-factory.js} +0 -0
- /package/src/services/{cookieReader.js → cookie-reader.js} +0 -0
- /package/src/services/{httpBackend.js → http-backend.js} +0 -0
- /package/src/services/{templateRequest.js → template-request.js} +0 -0
- /package/test/ng/{anomate.spec.js → animate.spec.js} +0 -0
package/dist/angular-ts.cjs.js
CHANGED
|
@@ -604,7 +604,7 @@ function isElement(node) {
|
|
|
604
604
|
return !!(
|
|
605
605
|
node &&
|
|
606
606
|
(node.nodeName || // We are a direct element.
|
|
607
|
-
(node.
|
|
607
|
+
(node.attr && node.find))
|
|
608
608
|
); // We have an on and find method part of jQuery API.
|
|
609
609
|
}
|
|
610
610
|
|
|
@@ -1351,6 +1351,8 @@ function directiveNormalize(name) {
|
|
|
1351
1351
|
*
|
|
1352
1352
|
*/
|
|
1353
1353
|
|
|
1354
|
+
const EXPANDO = "ngId";
|
|
1355
|
+
|
|
1354
1356
|
/**
|
|
1355
1357
|
* Expando cache for adding properties to DOM nodes with JavaScript.
|
|
1356
1358
|
* This used to be an Object in JQLite decorator, but swapped out for a Map
|
|
@@ -1413,12 +1415,10 @@ const CACHE = new Proxy(new Map(), {
|
|
|
1413
1415
|
* ## AngularJS's jqLite
|
|
1414
1416
|
* jqLite provides only the following jQuery methods:
|
|
1415
1417
|
*
|
|
1416
|
-
* - [`addClass()`](http://api.jquery.com/addClass/) - Does not support a function as first argument
|
|
1417
1418
|
* - [`after()`](http://api.jquery.com/after/)
|
|
1418
1419
|
* - [`append()`](http://api.jquery.com/append/) - Contrary to jQuery, this doesn't clone elements
|
|
1419
1420
|
* so will not work correctly when invoked on a jqLite object containing more than one DOM node
|
|
1420
1421
|
* - [`attr()`](http://api.jquery.com/attr/) - Does not support functions as parameters
|
|
1421
|
-
* - [`bind()`](http://api.jquery.com/bind/) (_deprecated_, use [`on()`](http://api.jquery.com/on/)) - Does not support namespaces, selectors or eventData
|
|
1422
1422
|
* - [`children()`](http://api.jquery.com/children/) - Does not support selectors
|
|
1423
1423
|
* - [`data()`](http://api.jquery.com/data/)
|
|
1424
1424
|
* - [`empty()`](http://api.jquery.com/empty/)
|
|
@@ -1429,7 +1429,6 @@ const CACHE = new Proxy(new Map(), {
|
|
|
1429
1429
|
* - [`one()`](http://api.jquery.com/one/) - Does not support namespaces or selectors
|
|
1430
1430
|
* - [`parent()`](http://api.jquery.com/parent/) - Does not support selectors
|
|
1431
1431
|
* - [`prepend()`](http://api.jquery.com/prepend/)
|
|
1432
|
-
* - [`prop()`](http://api.jquery.com/prop/)
|
|
1433
1432
|
* - [`remove()`](http://api.jquery.com/remove/)
|
|
1434
1433
|
* - [`removeData()`](http://api.jquery.com/removeData/)
|
|
1435
1434
|
* - [`replaceWith()`](http://api.jquery.com/replaceWith/)
|
|
@@ -1470,7 +1469,6 @@ const CACHE = new Proxy(new Map(), {
|
|
|
1470
1469
|
|
|
1471
1470
|
JQLite.cache = CACHE;
|
|
1472
1471
|
|
|
1473
|
-
const EXPANDO = "ngId";
|
|
1474
1472
|
let jqId = 1;
|
|
1475
1473
|
|
|
1476
1474
|
/**
|
|
@@ -1565,13 +1563,6 @@ function elementAcceptsData(node) {
|
|
|
1565
1563
|
}
|
|
1566
1564
|
}
|
|
1567
1565
|
|
|
1568
|
-
function jqLiteHasData(node) {
|
|
1569
|
-
for (const key in JQLite.cache.get(node[EXPANDO])) {
|
|
1570
|
-
return true;
|
|
1571
|
-
}
|
|
1572
|
-
return false;
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
1566
|
function jqLiteBuildFragment(html, context) {
|
|
1576
1567
|
let tmp;
|
|
1577
1568
|
let tag;
|
|
@@ -1967,7 +1958,6 @@ forEach(
|
|
|
1967
1958
|
{
|
|
1968
1959
|
data: jqLiteData,
|
|
1969
1960
|
removeData: jqLiteRemoveData,
|
|
1970
|
-
hasData: jqLiteHasData,
|
|
1971
1961
|
cleanData: jqLiteCleanData,
|
|
1972
1962
|
},
|
|
1973
1963
|
(fn, name) => {
|
|
@@ -2040,15 +2030,6 @@ forEach(
|
|
|
2040
2030
|
return ret === null ? undefined : ret;
|
|
2041
2031
|
}
|
|
2042
2032
|
},
|
|
2043
|
-
|
|
2044
|
-
prop(element, name, value) {
|
|
2045
|
-
if (isDefined(value)) {
|
|
2046
|
-
element[name] = value;
|
|
2047
|
-
} else {
|
|
2048
|
-
return element[name];
|
|
2049
|
-
}
|
|
2050
|
-
},
|
|
2051
|
-
|
|
2052
2033
|
text: (function () {
|
|
2053
2034
|
getText.$dv = "";
|
|
2054
2035
|
return getText;
|
|
@@ -6412,1104 +6393,6 @@ function createEventDirective(
|
|
|
6412
6393
|
};
|
|
6413
6394
|
}
|
|
6414
6395
|
|
|
6415
|
-
/* ! VARIABLE/FUNCTION NAMING CONVENTIONS THAT APPLY TO THIS FILE!
|
|
6416
|
-
*
|
|
6417
|
-
* DOM-related variables:
|
|
6418
|
-
*
|
|
6419
|
-
* - "node" - DOM Node
|
|
6420
|
-
* - "element" - DOM Element or Node
|
|
6421
|
-
* - "$node" or "$element" - jqLite-wrapped node or element
|
|
6422
|
-
*
|
|
6423
|
-
*
|
|
6424
|
-
* Compiler related stuff:
|
|
6425
|
-
*
|
|
6426
|
-
* - "linkFn" - linking fn of a single directive
|
|
6427
|
-
* - "nodeLinkFn" - function that aggregates all linking fns for a particular node
|
|
6428
|
-
* - "childLinkFn" - function that aggregates all linking fns for child nodes of a particular node
|
|
6429
|
-
* - "compositeLinkFn" - function that aggregates all linking fns for a compilation root (nodeList)
|
|
6430
|
-
*/
|
|
6431
|
-
|
|
6432
|
-
/**
|
|
6433
|
-
* @ngdoc service
|
|
6434
|
-
* @name $compile
|
|
6435
|
-
* @kind function
|
|
6436
|
-
*
|
|
6437
|
-
* @description
|
|
6438
|
-
* Compiles an HTML string or DOM into a template and produces a template function, which
|
|
6439
|
-
* can then be used to link {@link ng.$rootScope.Scope `scope`} and the template together.
|
|
6440
|
-
*
|
|
6441
|
-
* The compilation is a process of walking the DOM tree and matching DOM elements to
|
|
6442
|
-
* {@link ng.$compileProvider#directive directives}.
|
|
6443
|
-
*
|
|
6444
|
-
* <div class="alert alert-warning">
|
|
6445
|
-
* **Note:** This document is an in-depth reference of all directive options.
|
|
6446
|
-
* For a gentle introduction to directives with examples of common use cases,
|
|
6447
|
-
* see the {@link guide/directive directive guide}.
|
|
6448
|
-
* </div>
|
|
6449
|
-
*
|
|
6450
|
-
* ## Comprehensive Directive API
|
|
6451
|
-
*
|
|
6452
|
-
* There are many different options for a directive.
|
|
6453
|
-
*
|
|
6454
|
-
* The difference resides in the return value of the factory function.
|
|
6455
|
-
* You can either return a {@link $compile#directive-definition-object Directive Definition Object (see below)}
|
|
6456
|
-
* that defines the directive properties, or just the `postLink` function (all other properties will have
|
|
6457
|
-
* the default values).
|
|
6458
|
-
*
|
|
6459
|
-
* <div class="alert alert-success">
|
|
6460
|
-
* **Best Practice:** It's recommended to use the "directive definition object" form.
|
|
6461
|
-
* </div>
|
|
6462
|
-
*
|
|
6463
|
-
* Here's an example directive declared with a Directive Definition Object:
|
|
6464
|
-
*
|
|
6465
|
-
* ```js
|
|
6466
|
-
* let myModule = angular.module(...);
|
|
6467
|
-
*
|
|
6468
|
-
* myModule.directive('directiveName', function factory(injectables) {
|
|
6469
|
-
* let directiveDefinitionObject = {
|
|
6470
|
-
* {@link $compile#-priority- priority}: 0,
|
|
6471
|
-
* {@link $compile#-template- template}: '<div></div>', // or // function(tElement, tAttrs) { ... },
|
|
6472
|
-
* // or
|
|
6473
|
-
* // {@link $compile#-templateurl- templateUrl}: 'directive.html', // or // function(tElement, tAttrs) { ... },
|
|
6474
|
-
* {@link $compile#-transclude- transclude}: false,
|
|
6475
|
-
* {@link $compile#-restrict- restrict}: 'A',
|
|
6476
|
-
* {@link $compile#-templatenamespace- templateNamespace}: 'html',
|
|
6477
|
-
* {@link $compile#-scope- scope}: false,
|
|
6478
|
-
* {@link $compile#-controller- controller}: function($scope, $element, $attrs, $transclude, otherInjectables) { ... },
|
|
6479
|
-
* {@link $compile#-controlleras- controllerAs}: 'stringIdentifier',
|
|
6480
|
-
* {@link $compile#-bindtocontroller- bindToController}: false,
|
|
6481
|
-
* {@link $compile#-require- require}: 'siblingDirectiveName', // or // ['^parentDirectiveName', '?optionalDirectiveName', '?^optionalParent'],
|
|
6482
|
-
* {@link $compile#-multielement- multiElement}: false,
|
|
6483
|
-
* {@link $compile#-compile- compile}: function compile(tElement, tAttrs, transclude) {
|
|
6484
|
-
* return {
|
|
6485
|
-
* {@link $compile#pre-linking-function pre}: function preLink(scope, iElement, iAttrs, controller) { ... },
|
|
6486
|
-
* {@link $compile#post-linking-function post}: function postLink(scope, iElement, iAttrs, controller) { ... }
|
|
6487
|
-
* }
|
|
6488
|
-
* // or
|
|
6489
|
-
* // return function postLink( ... ) { ... }
|
|
6490
|
-
* },
|
|
6491
|
-
* // or
|
|
6492
|
-
* // {@link $compile#-link- link}: {
|
|
6493
|
-
* // {@link $compile#pre-linking-function pre}: function preLink(scope, iElement, iAttrs, controller) { ... },
|
|
6494
|
-
* // {@link $compile#post-linking-function post}: function postLink(scope, iElement, iAttrs, controller) { ... }
|
|
6495
|
-
* // }
|
|
6496
|
-
* // or
|
|
6497
|
-
* // {@link $compile#-link- link}: function postLink( ... ) { ... }
|
|
6498
|
-
* };
|
|
6499
|
-
* return directiveDefinitionObject;
|
|
6500
|
-
* });
|
|
6501
|
-
* ```
|
|
6502
|
-
*
|
|
6503
|
-
* <div class="alert alert-warning">
|
|
6504
|
-
* **Note:** Any unspecified options will use the default value. You can see the default values below.
|
|
6505
|
-
* </div>
|
|
6506
|
-
*
|
|
6507
|
-
* Therefore the above can be simplified as:
|
|
6508
|
-
*
|
|
6509
|
-
* ```js
|
|
6510
|
-
* let myModule = angular.module(...);
|
|
6511
|
-
*
|
|
6512
|
-
* myModule.directive('directiveName', function factory(injectables) {
|
|
6513
|
-
* let directiveDefinitionObject = {
|
|
6514
|
-
* link: function postLink(scope, iElement, iAttrs) { ... }
|
|
6515
|
-
* };
|
|
6516
|
-
* return directiveDefinitionObject;
|
|
6517
|
-
* // or
|
|
6518
|
-
* // return function postLink(scope, iElement, iAttrs) { ... }
|
|
6519
|
-
* });
|
|
6520
|
-
* ```
|
|
6521
|
-
*
|
|
6522
|
-
* ### Life-cycle hooks
|
|
6523
|
-
* Directive controllers can provide the following methods that are called by AngularJS at points in the life-cycle of the
|
|
6524
|
-
* directive:
|
|
6525
|
-
* * `$onInit()` - Called on each controller after all the controllers on an element have been constructed and
|
|
6526
|
-
* had their bindings initialized (and before the pre & post linking functions for the directives on
|
|
6527
|
-
* this element). This is a good place to put initialization code for your controller.
|
|
6528
|
-
* * `$onChanges(changesObj)` - Called whenever one-way (`<`) or interpolation (`@`) bindings are updated. The
|
|
6529
|
-
* `changesObj` is a hash whose keys are the names of the bound properties that have changed, and the values are an
|
|
6530
|
-
* object of the form `{ currentValue, previousValue, isFirstChange() }`. Use this hook to trigger updates within a
|
|
6531
|
-
* component such as cloning the bound value to prevent accidental mutation of the outer value. Note that this will
|
|
6532
|
-
* also be called when your bindings are initialized.
|
|
6533
|
-
* * `$doCheck()` - Called on each turn of the digest cycle. Provides an opportunity to detect and act on
|
|
6534
|
-
* changes. Any actions that you wish to take in response to the changes that you detect must be
|
|
6535
|
-
* invoked from this hook; implementing this has no effect on when `$onChanges` is called. For example, this hook
|
|
6536
|
-
* could be useful if you wish to perform a deep equality check, or to check a Date object, changes to which would not
|
|
6537
|
-
* be detected by AngularJS's change detector and thus not trigger `$onChanges`. This hook is invoked with no arguments;
|
|
6538
|
-
* if detecting changes, you must store the previous value(s) for comparison to the current values.
|
|
6539
|
-
* * `$onDestroy()` - Called on a controller when its containing scope is destroyed. Use this hook for releasing
|
|
6540
|
-
* external resources, watches and event handlers. Note that components have their `$onDestroy()` hooks called in
|
|
6541
|
-
* the same order as the `$scope.$broadcast` events are triggered, which is top down. This means that parent
|
|
6542
|
-
* components will have their `$onDestroy()` hook called before child components.
|
|
6543
|
-
* * `$postLink()` - Called after this controller's element and its children have been linked. Similar to the post-link
|
|
6544
|
-
* function this hook can be used to set up DOM event handlers and do direct DOM manipulation.
|
|
6545
|
-
* Note that child elements that contain `templateUrl` directives will not have been compiled and linked since
|
|
6546
|
-
* they are waiting for their template to load asynchronously and their own compilation and linking has been
|
|
6547
|
-
* suspended until that occurs.
|
|
6548
|
-
*
|
|
6549
|
-
* #### Comparison with life-cycle hooks in the new Angular
|
|
6550
|
-
* The new Angular also uses life-cycle hooks for its components. While the AngularJS life-cycle hooks are similar there are
|
|
6551
|
-
* some differences that you should be aware of, especially when it comes to moving your code from AngularJS to Angular:
|
|
6552
|
-
*
|
|
6553
|
-
* * AngularJS hooks are prefixed with `$`, such as `$onInit`. Angular hooks are prefixed with `ng`, such as `ngOnInit`.
|
|
6554
|
-
* * AngularJS hooks can be defined on the controller prototype or added to the controller inside its constructor.
|
|
6555
|
-
* In Angular you can only define hooks on the prototype of the Component class.
|
|
6556
|
-
* * Due to the differences in change-detection, you may get many more calls to `$doCheck` in AngularJS than you would to
|
|
6557
|
-
* `ngDoCheck` in Angular.
|
|
6558
|
-
* * Changes to the model inside `$doCheck` will trigger new turns of the digest loop, which will cause the changes to be
|
|
6559
|
-
* propagated throughout the application.
|
|
6560
|
-
* Angular does not allow the `ngDoCheck` hook to trigger a change outside of the component. It will either throw an
|
|
6561
|
-
* error or do nothing depending upon the state of `enableProdMode()`.
|
|
6562
|
-
*
|
|
6563
|
-
* #### Life-cycle hook examples
|
|
6564
|
-
*
|
|
6565
|
-
* This example shows how you can check for mutations to a Date object even though the identity of the object
|
|
6566
|
-
* has not changed.
|
|
6567
|
-
*
|
|
6568
|
-
* <example name="doCheckDateExample" module="do-check-module">
|
|
6569
|
-
* <file name="app.js">
|
|
6570
|
-
* angular.module('do-check-module', [])
|
|
6571
|
-
* .component('app', {
|
|
6572
|
-
* template:
|
|
6573
|
-
* 'Month: <input ng-model="$ctrl.month" ng-change="$ctrl.updateDate()">' +
|
|
6574
|
-
* 'Date: {{ $ctrl.date }}' +
|
|
6575
|
-
* '<test date="$ctrl.date"></test>',
|
|
6576
|
-
* controller: function() {
|
|
6577
|
-
* this.date = new Date();
|
|
6578
|
-
* this.month = this.date.getMonth();
|
|
6579
|
-
* this.updateDate = function() {
|
|
6580
|
-
* this.date.setMonth(this.month);
|
|
6581
|
-
* };
|
|
6582
|
-
* }
|
|
6583
|
-
* })
|
|
6584
|
-
* .component('test', {
|
|
6585
|
-
* bindings: { date: '<' },
|
|
6586
|
-
* template:
|
|
6587
|
-
* '<pre>{{ $ctrl.log | json }}</pre>',
|
|
6588
|
-
* controller: function() {
|
|
6589
|
-
* let previousValue;
|
|
6590
|
-
* this.log = [];
|
|
6591
|
-
* this.$doCheck = function() {
|
|
6592
|
-
* let currentValue = this.date && this.date.valueOf();
|
|
6593
|
-
* if (previousValue !== currentValue) {
|
|
6594
|
-
* this.log.push('doCheck: date mutated: ' + this.date);
|
|
6595
|
-
* previousValue = currentValue;
|
|
6596
|
-
* }
|
|
6597
|
-
* };
|
|
6598
|
-
* }
|
|
6599
|
-
* });
|
|
6600
|
-
* </file>
|
|
6601
|
-
* <file name="index.html">
|
|
6602
|
-
* <app></app>
|
|
6603
|
-
* </file>
|
|
6604
|
-
* </example>
|
|
6605
|
-
*
|
|
6606
|
-
* This example show how you might use `$doCheck` to trigger changes in your component's inputs even if the
|
|
6607
|
-
* actual identity of the component doesn't change. (Be aware that cloning and deep equality checks on large
|
|
6608
|
-
* arrays or objects can have a negative impact on your application performance.)
|
|
6609
|
-
*
|
|
6610
|
-
* <example name="doCheckArrayExample" module="do-check-module">
|
|
6611
|
-
* <file name="index.html">
|
|
6612
|
-
* <div ng-init="items = []">
|
|
6613
|
-
* <button ng-click="items.push(items.length)">Add Item</button>
|
|
6614
|
-
* <button ng-click="items = []">Reset Items</button>
|
|
6615
|
-
* <pre>{{ items }}</pre>
|
|
6616
|
-
* <test items="items"></test>
|
|
6617
|
-
* </div>
|
|
6618
|
-
* </file>
|
|
6619
|
-
* <file name="app.js">
|
|
6620
|
-
* angular.module('do-check-module', [])
|
|
6621
|
-
* .component('test', {
|
|
6622
|
-
* bindings: { items: '<' },
|
|
6623
|
-
* template:
|
|
6624
|
-
* '<pre>{{ $ctrl.log | json }}</pre>',
|
|
6625
|
-
* controller: function() {
|
|
6626
|
-
* this.log = [];
|
|
6627
|
-
*
|
|
6628
|
-
* this.$doCheck = function() {
|
|
6629
|
-
* if (this.items_ref !== this.items) {
|
|
6630
|
-
* this.log.push('doCheck: items changed');
|
|
6631
|
-
* this.items_ref = this.items;
|
|
6632
|
-
* }
|
|
6633
|
-
* if (!angular.equals(this.items_clone, this.items)) {
|
|
6634
|
-
* this.log.push('doCheck: items mutated');
|
|
6635
|
-
* this.items_clone = structuredClone(this.items);
|
|
6636
|
-
* }
|
|
6637
|
-
* };
|
|
6638
|
-
* }
|
|
6639
|
-
* });
|
|
6640
|
-
* </file>
|
|
6641
|
-
* </example>
|
|
6642
|
-
*
|
|
6643
|
-
*
|
|
6644
|
-
* ### Directive Definition Object
|
|
6645
|
-
*
|
|
6646
|
-
* The directive definition object provides instructions to the {@link ng.$compile
|
|
6647
|
-
* compiler}. The attributes are:
|
|
6648
|
-
*
|
|
6649
|
-
* #### `multiElement`
|
|
6650
|
-
* When this property is set to true (default is `false`), the HTML compiler will collect DOM nodes between
|
|
6651
|
-
* nodes with the attributes `directive-name-start` and `directive-name-end`, and group them
|
|
6652
|
-
* together as the directive elements. It is recommended that this feature be used on directives
|
|
6653
|
-
* which are not strictly behavioral (such as {@link ngClick}), and which
|
|
6654
|
-
* do not manipulate or replace child nodes (such as {@link ngInclude}).
|
|
6655
|
-
*
|
|
6656
|
-
* #### `priority`
|
|
6657
|
-
* When there are multiple directives defined on a single DOM element, sometimes it
|
|
6658
|
-
* is necessary to specify the order in which the directives are applied. The `priority` is used
|
|
6659
|
-
* to sort the directives before their `compile` functions get called. Priority is defined as a
|
|
6660
|
-
* number. Directives with greater numerical `priority` are compiled first. Pre-link functions
|
|
6661
|
-
* are also run in priority order, but post-link functions are run in reverse order. The order
|
|
6662
|
-
* of directives with the same priority is undefined. The default priority is `0`.
|
|
6663
|
-
*
|
|
6664
|
-
* #### `terminal`
|
|
6665
|
-
* If set to true then the current `priority` will be the last set of directives
|
|
6666
|
-
* which will execute (any directives at the current priority will still execute
|
|
6667
|
-
* as the order of execution on same `priority` is undefined). Note that expressions
|
|
6668
|
-
* and other directives used in the directive's template will also be excluded from execution.
|
|
6669
|
-
*
|
|
6670
|
-
* #### `scope`
|
|
6671
|
-
* The scope property can be `false`, `true`, or an object:
|
|
6672
|
-
*
|
|
6673
|
-
* * **`false` (default):** No scope will be created for the directive. The directive will use its
|
|
6674
|
-
* parent's scope.
|
|
6675
|
-
*
|
|
6676
|
-
* * **`true`:** A new child scope that prototypically inherits from its parent will be created for
|
|
6677
|
-
* the directive's element. If multiple directives on the same element request a new scope,
|
|
6678
|
-
* only one new scope is created.
|
|
6679
|
-
*
|
|
6680
|
-
* * **`{...}` (an object hash):** A new "isolate" scope is created for the directive's template.
|
|
6681
|
-
* The 'isolate' scope differs from normal scope in that it does not prototypically
|
|
6682
|
-
* inherit from its parent scope. This is useful when creating reusable components, which should not
|
|
6683
|
-
* accidentally read or modify data in the parent scope. Note that an isolate scope
|
|
6684
|
-
* directive without a `template` or `templateUrl` will not apply the isolate scope
|
|
6685
|
-
* to its children elements.
|
|
6686
|
-
*
|
|
6687
|
-
* The 'isolate' scope object hash defines a set of local scope properties derived from attributes on the
|
|
6688
|
-
* directive's element. These local properties are useful for aliasing values for templates. The keys in
|
|
6689
|
-
* the object hash map to the name of the property on the isolate scope; the values define how the property
|
|
6690
|
-
* is bound to the parent scope, via matching attributes on the directive's element:
|
|
6691
|
-
*
|
|
6692
|
-
* * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is
|
|
6693
|
-
* always a string since DOM attributes are strings. If no `attr` name is specified then the
|
|
6694
|
-
* attribute name is assumed to be the same as the local name. Given `<my-component
|
|
6695
|
-
* my-attr="hello {{name}}">` and the isolate scope definition `scope: { localName:'@myAttr' }`,
|
|
6696
|
-
* the directive's scope property `localName` will reflect the interpolated value of `hello
|
|
6697
|
-
* {{name}}`. As the `name` attribute changes so will the `localName` property on the directive's
|
|
6698
|
-
* scope. The `name` is read from the parent scope (not the directive's scope).
|
|
6699
|
-
*
|
|
6700
|
-
* * `=` or `=attr` - set up a bidirectional binding between a local scope property and an expression
|
|
6701
|
-
* passed via the attribute `attr`. The expression is evaluated in the context of the parent scope.
|
|
6702
|
-
* If no `attr` name is specified then the attribute name is assumed to be the same as the local
|
|
6703
|
-
* name. Given `<my-component my-attr="parentModel">` and the isolate scope definition `scope: {
|
|
6704
|
-
* localModel: '=myAttr' }`, the property `localModel` on the directive's scope will reflect the
|
|
6705
|
-
* value of `parentModel` on the parent scope. Changes to `parentModel` will be reflected in
|
|
6706
|
-
* `localModel` and vice versa. If the binding expression is non-assignable, or if the attribute
|
|
6707
|
-
* isn't optional and doesn't exist, an exception
|
|
6708
|
-
* ({@link error/$compile/nonassign `$compile:nonassign`}) will be thrown upon discovering changes
|
|
6709
|
-
* to the local value, since it will be impossible to sync them back to the parent scope.
|
|
6710
|
-
*
|
|
6711
|
-
* By default, the {@link ng.$rootScope.Scope#$watch `$watch`}
|
|
6712
|
-
* method is used for tracking changes, and the equality check is based on object identity.
|
|
6713
|
-
* However, if an object literal or an array literal is passed as the binding expression, the
|
|
6714
|
-
* equality check is done by value (using the {@link angular.equals} function). It's also possible
|
|
6715
|
-
* to watch the evaluated value shallowly with {@link ng.$rootScope.Scope#$watchCollection
|
|
6716
|
-
* `$watchCollection`}: use `=*` or `=*attr`
|
|
6717
|
-
*
|
|
6718
|
-
* * `<` or `<attr` - set up a one-way (one-directional) binding between a local scope property and an
|
|
6719
|
-
* expression passed via the attribute `attr`. The expression is evaluated in the context of the
|
|
6720
|
-
* parent scope. If no `attr` name is specified then the attribute name is assumed to be the same as the
|
|
6721
|
-
* local name.
|
|
6722
|
-
*
|
|
6723
|
-
* For example, given `<my-component my-attr="parentModel">` and directive definition of
|
|
6724
|
-
* `scope: { localModel:'<myAttr' }`, then the isolated scope property `localModel` will reflect the
|
|
6725
|
-
* value of `parentModel` on the parent scope. Any changes to `parentModel` will be reflected
|
|
6726
|
-
* in `localModel`, but changes in `localModel` will not reflect in `parentModel`. There are however
|
|
6727
|
-
* two caveats:
|
|
6728
|
-
* 1. one-way binding does not copy the value from the parent to the isolate scope, it simply
|
|
6729
|
-
* sets the same value. That means if your bound value is an object, changes to its properties
|
|
6730
|
-
* in the isolated scope will be reflected in the parent scope (because both reference the same object).
|
|
6731
|
-
* 2. one-way binding watches changes to the **identity** of the parent value. That means the
|
|
6732
|
-
* {@link ng.$rootScope.Scope#$watch `$watch`} on the parent value only fires if the reference
|
|
6733
|
-
* to the value has changed. In most cases, this should not be of concern, but can be important
|
|
6734
|
-
* to know if you one-way bind to an object, and then replace that object in the isolated scope.
|
|
6735
|
-
* If you now change a property of the object in your parent scope, the change will not be
|
|
6736
|
-
* propagated to the isolated scope, because the identity of the object on the parent scope
|
|
6737
|
-
* has not changed. Instead you must assign a new object.
|
|
6738
|
-
*
|
|
6739
|
-
* One-way binding is useful if you do not plan to propagate changes to your isolated scope bindings
|
|
6740
|
-
* back to the parent. However, it does not make this completely impossible.
|
|
6741
|
-
*
|
|
6742
|
-
* By default, the {@link ng.$rootScope.Scope#$watch `$watch`}
|
|
6743
|
-
* method is used for tracking changes, and the equality check is based on object identity.
|
|
6744
|
-
* It's also possible to watch the evaluated value shallowly with
|
|
6745
|
-
* {@link ng.$rootScope.Scope#$watchCollection `$watchCollection`}: use `<*` or `<*attr`
|
|
6746
|
-
*
|
|
6747
|
-
* * `&` or `&attr` - provides a way to execute an expression in the context of the parent scope. If
|
|
6748
|
-
* no `attr` name is specified then the attribute name is assumed to be the same as the local name.
|
|
6749
|
-
* Given `<my-component my-attr="count = count + value">` and the isolate scope definition `scope: {
|
|
6750
|
-
* localFn:'&myAttr' }`, the isolate scope property `localFn` will point to a function wrapper for
|
|
6751
|
-
* the `count = count + value` expression. Often it's desirable to pass data from the isolated scope
|
|
6752
|
-
* via an expression to the parent scope. This can be done by passing a map of local variable names
|
|
6753
|
-
* and values into the expression wrapper fn. For example, if the expression is `increment(amount)`
|
|
6754
|
-
* then we can specify the amount value by calling the `localFn` as `localFn({amount: 22})`.
|
|
6755
|
-
*
|
|
6756
|
-
* All 4 kinds of bindings (`@`, `=`, `<`, and `&`) can be made optional by adding `?` to the expression.
|
|
6757
|
-
* The marker must come after the mode and before the attribute name.
|
|
6758
|
-
* See the {@link error/$compile/iscp Invalid Isolate Scope Definition error} for definition examples.
|
|
6759
|
-
* This is useful to refine the interface directives provide.
|
|
6760
|
-
* One subtle difference between optional and non-optional happens **when the binding attribute is not
|
|
6761
|
-
* set**:
|
|
6762
|
-
* - the binding is optional: the property will not be defined
|
|
6763
|
-
* - the binding is not optional: the property is defined
|
|
6764
|
-
*
|
|
6765
|
-
* ```js
|
|
6766
|
-
*app.directive('testDir', function() {
|
|
6767
|
-
return {
|
|
6768
|
-
scope: {
|
|
6769
|
-
notoptional: '=',
|
|
6770
|
-
optional: '=?',
|
|
6771
|
-
},
|
|
6772
|
-
bindToController: true,
|
|
6773
|
-
controller: function() {
|
|
6774
|
-
this.$onInit = function() {
|
|
6775
|
-
console.log(this.hasOwnProperty('notoptional')) // true
|
|
6776
|
-
console.log(this.hasOwnProperty('optional')) // false
|
|
6777
|
-
}
|
|
6778
|
-
}
|
|
6779
|
-
}
|
|
6780
|
-
})
|
|
6781
|
-
*```
|
|
6782
|
-
*
|
|
6783
|
-
*
|
|
6784
|
-
* ##### Combining directives with different scope defintions
|
|
6785
|
-
*
|
|
6786
|
-
* In general it's possible to apply more than one directive to one element, but there might be limitations
|
|
6787
|
-
* depending on the type of scope required by the directives. The following points will help explain these limitations.
|
|
6788
|
-
* For simplicity only two directives are taken into account, but it is also applicable for several directives:
|
|
6789
|
-
*
|
|
6790
|
-
* * **no scope** + **no scope** => Two directives which don't require their own scope will use their parent's scope
|
|
6791
|
-
* * **child scope** + **no scope** => Both directives will share one single child scope
|
|
6792
|
-
* * **child scope** + **child scope** => Both directives will share one single child scope
|
|
6793
|
-
* * **isolated scope** + **no scope** => The isolated directive will use it's own created isolated scope. The other directive will use
|
|
6794
|
-
* its parent's scope
|
|
6795
|
-
* * **isolated scope** + **child scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives cannot
|
|
6796
|
-
* be applied to the same element.
|
|
6797
|
-
* * **isolated scope** + **isolated scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives
|
|
6798
|
-
* cannot be applied to the same element.
|
|
6799
|
-
*
|
|
6800
|
-
*
|
|
6801
|
-
* #### `bindToController`
|
|
6802
|
-
* This property is used to bind scope properties directly to the controller. It can be either
|
|
6803
|
-
* `true` or an object hash with the same format as the `scope` property.
|
|
6804
|
-
*
|
|
6805
|
-
* When an isolate scope is used for a directive (see above), `bindToController: true` will
|
|
6806
|
-
* allow a component to have its properties bound to the controller, rather than to scope.
|
|
6807
|
-
*
|
|
6808
|
-
* After the controller is instantiated, the initial values of the isolate scope bindings will be bound to the controller
|
|
6809
|
-
* properties. You can access these bindings once they have been initialized by providing a controller method called
|
|
6810
|
-
* `$onInit`, which is called after all the controllers on an element have been constructed and had their bindings
|
|
6811
|
-
* initialized.
|
|
6812
|
-
*
|
|
6813
|
-
* It is also possible to set `bindToController` to an object hash with the same format as the `scope` property.
|
|
6814
|
-
* This will set up the scope bindings to the controller directly. Note that `scope` can still be used
|
|
6815
|
-
* to define which kind of scope is created. By default, no scope is created. Use `scope: {}` to create an isolate
|
|
6816
|
-
* scope (useful for component directives).
|
|
6817
|
-
*
|
|
6818
|
-
* If both `bindToController` and `scope` are defined and have object hashes, `bindToController` overrides `scope`.
|
|
6819
|
-
*
|
|
6820
|
-
*
|
|
6821
|
-
* #### `controller`
|
|
6822
|
-
* Controller constructor function. The controller is instantiated before the
|
|
6823
|
-
* pre-linking phase and can be accessed by other directives (see
|
|
6824
|
-
* `require` attribute). This allows the directives to communicate with each other and augment
|
|
6825
|
-
* each other's behavior. The controller is injectable (and supports bracket notation) with the following locals:
|
|
6826
|
-
*
|
|
6827
|
-
* * `$scope` - Current scope associated with the element
|
|
6828
|
-
* * `$element` - Current element
|
|
6829
|
-
* * `$attrs` - Current attributes object for the element
|
|
6830
|
-
* * `$transclude` - A transclude linking function pre-bound to the correct transclusion scope:
|
|
6831
|
-
* `function([scope], cloneLinkingFn, futureParentElement, slotName)`:
|
|
6832
|
-
* * `scope`: (optional) override the scope.
|
|
6833
|
-
* * `cloneLinkingFn`: (optional) argument to create clones of the original transcluded content.
|
|
6834
|
-
* * `futureParentElement` (optional):
|
|
6835
|
-
* * defines the parent to which the `cloneLinkingFn` will add the cloned elements.
|
|
6836
|
-
* * default: `$element.parent()` resp. `$element` for `transclude:'element'` resp. `transclude:true`.
|
|
6837
|
-
* * only needed for transcludes that are allowed to contain non html elements (e.g. SVG elements)
|
|
6838
|
-
* and when the `cloneLinkingFn` is passed,
|
|
6839
|
-
* as those elements need to created and cloned in a special way when they are defined outside their
|
|
6840
|
-
* usual containers (e.g. like `<svg>`).
|
|
6841
|
-
* * See also the `directive.templateNamespace` property.
|
|
6842
|
-
* * `slotName`: (optional) the name of the slot to transclude. If falsy (e.g. `null`, `undefined` or `''`)
|
|
6843
|
-
* then the default transclusion is provided.
|
|
6844
|
-
* The `$transclude` function also has a method on it, `$transclude.isSlotFilled(slotName)`, which returns
|
|
6845
|
-
* `true` if the specified slot contains content (i.e. one or more DOM nodes).
|
|
6846
|
-
*
|
|
6847
|
-
* #### `require`
|
|
6848
|
-
* Require another directive and inject its controller as the fourth argument to the linking function. The
|
|
6849
|
-
* `require` property can be a string, an array or an object:
|
|
6850
|
-
* * a **string** containing the name of the directive to pass to the linking function
|
|
6851
|
-
* * an **array** containing the names of directives to pass to the linking function. The argument passed to the
|
|
6852
|
-
* linking function will be an array of controllers in the same order as the names in the `require` property
|
|
6853
|
-
* * an **object** whose property values are the names of the directives to pass to the linking function. The argument
|
|
6854
|
-
* passed to the linking function will also be an object with matching keys, whose values will hold the corresponding
|
|
6855
|
-
* controllers.
|
|
6856
|
-
*
|
|
6857
|
-
* If the `require` property is an object and `bindToController` is truthy, then the required controllers are
|
|
6858
|
-
* bound to the controller using the keys of the `require` property. This binding occurs after all the controllers
|
|
6859
|
-
* have been constructed but before `$onInit` is called.
|
|
6860
|
-
* If the name of the required controller is the same as the local name (the key), the name can be
|
|
6861
|
-
* omitted. For example, `{parentDir: '^^'}` is equivalent to `{parentDir: '^^parentDir'}`.
|
|
6862
|
-
* See the {@link $compileProvider#component} helper for an example of how this can be used.
|
|
6863
|
-
* If no such required directive(s) can be found, or if the directive does not have a controller, then an error is
|
|
6864
|
-
* raised (unless no link function is specified and the required controllers are not being bound to the directive
|
|
6865
|
-
* controller, in which case error checking is skipped). The name can be prefixed with:
|
|
6866
|
-
*
|
|
6867
|
-
* * (no prefix) - Locate the required controller on the current element. Throw an error if not found.
|
|
6868
|
-
* * `?` - Attempt to locate the required controller or pass `null` to the `link` fn if not found.
|
|
6869
|
-
* * `^` - Locate the required controller by searching the element and its parents. Throw an error if not found.
|
|
6870
|
-
* * `^^` - Locate the required controller by searching the element's parents. Throw an error if not found.
|
|
6871
|
-
* * `?^` - Attempt to locate the required controller by searching the element and its parents or pass
|
|
6872
|
-
* `null` to the `link` fn if not found.
|
|
6873
|
-
* * `?^^` - Attempt to locate the required controller by searching the element's parents, or pass
|
|
6874
|
-
* `null` to the `link` fn if not found.
|
|
6875
|
-
*
|
|
6876
|
-
*
|
|
6877
|
-
* #### `controllerAs`
|
|
6878
|
-
* Identifier name for a reference to the controller in the directive's scope.
|
|
6879
|
-
* This allows the controller to be referenced from the directive template. This is especially
|
|
6880
|
-
* useful when a directive is used as component, i.e. with an `isolate` scope. It's also possible
|
|
6881
|
-
* to use it in a directive without an `isolate` / `new` scope, but you need to be aware that the
|
|
6882
|
-
* `controllerAs` reference might overwrite a property that already exists on the parent scope.
|
|
6883
|
-
*
|
|
6884
|
-
*
|
|
6885
|
-
* #### `restrict`
|
|
6886
|
-
* String of subset of `EACM` which restricts the directive to a specific directive
|
|
6887
|
-
* declaration style. If omitted, the defaults (elements and attributes) are used.
|
|
6888
|
-
*
|
|
6889
|
-
* * `E` - Element name (default): `<my-directive></my-directive>`
|
|
6890
|
-
* * `A` - Attribute (default): `<div my-directive="exp"></div>`
|
|
6891
|
-
* * `C` - Class: `<div class="my-directive: exp;"></div>`
|
|
6892
|
-
* * `M` - Comment: `<!-- directive: my-directive exp -->`
|
|
6893
|
-
*
|
|
6894
|
-
*
|
|
6895
|
-
* #### `templateNamespace`
|
|
6896
|
-
* String representing the document type used by the markup in the template.
|
|
6897
|
-
* AngularJS needs this information as those elements need to be created and cloned
|
|
6898
|
-
* in a special way when they are defined outside their usual containers like `<svg>` and `<math>`.
|
|
6899
|
-
*
|
|
6900
|
-
* * `html` - All root nodes in the template are HTML. Root nodes may also be
|
|
6901
|
-
* top-level elements such as `<svg>` or `<math>`.
|
|
6902
|
-
* * `svg` - The root nodes in the template are SVG elements (excluding `<math>`).
|
|
6903
|
-
* * `math` - The root nodes in the template are MathML elements (excluding `<svg>`).
|
|
6904
|
-
*
|
|
6905
|
-
* If no `templateNamespace` is specified, then the namespace is considered to be `html`.
|
|
6906
|
-
*
|
|
6907
|
-
* #### `template`
|
|
6908
|
-
* HTML markup that may:
|
|
6909
|
-
* * Replace the contents of the directive's element (default).
|
|
6910
|
-
* * Replace the directive's element itself (if `replace` is true - DEPRECATED).
|
|
6911
|
-
* * Wrap the contents of the directive's element (if `transclude` is true).
|
|
6912
|
-
*
|
|
6913
|
-
* Value may be:
|
|
6914
|
-
*
|
|
6915
|
-
* * A string. For example `<div red-on-hover>{{delete_str}}</div>`.
|
|
6916
|
-
* * A function which takes two arguments `tElement` and `tAttrs` (described in the `compile`
|
|
6917
|
-
* function api below) and returns a string value.
|
|
6918
|
-
*
|
|
6919
|
-
*
|
|
6920
|
-
* #### `templateUrl`
|
|
6921
|
-
* This is similar to `template` but the template is loaded from the specified URL, asynchronously.
|
|
6922
|
-
*
|
|
6923
|
-
* Because template loading is asynchronous the compiler will suspend compilation of directives on that element
|
|
6924
|
-
* for later when the template has been resolved. In the meantime it will continue to compile and link
|
|
6925
|
-
* sibling and parent elements as though this element had not contained any directives.
|
|
6926
|
-
*
|
|
6927
|
-
* The compiler does not suspend the entire compilation to wait for templates to be loaded because this
|
|
6928
|
-
* would result in the whole app "stalling" until all templates are loaded asynchronously - even in the
|
|
6929
|
-
* case when only one deeply nested directive has `templateUrl`.
|
|
6930
|
-
*
|
|
6931
|
-
* Template loading is asynchronous even if the template has been preloaded into the {@link $templateCache}.
|
|
6932
|
-
*
|
|
6933
|
-
* You can specify `templateUrl` as a string representing the URL or as a function which takes two
|
|
6934
|
-
* arguments `tElement` and `tAttrs` (described in the `compile` function api below) and returns
|
|
6935
|
-
* a string value representing the url. In either case, the template URL is passed through {@link
|
|
6936
|
-
* $sce#getTrustedResourceUrl $sce.getTrustedResourceUrl}.
|
|
6937
|
-
*
|
|
6938
|
-
*
|
|
6939
|
-
* #### `replace`
|
|
6940
|
-
* <div class="alert alert-danger">
|
|
6941
|
-
* **Note:** `replace` is deprecated in AngularJS and has been removed in the new Angular (v2+).
|
|
6942
|
-
* </div>
|
|
6943
|
-
*
|
|
6944
|
-
* Specifies what the template should replace. Defaults to `false`.
|
|
6945
|
-
*
|
|
6946
|
-
* * `true` - the template will replace the directive's element.
|
|
6947
|
-
* * `false` - the template will replace the contents of the directive's element.
|
|
6948
|
-
*
|
|
6949
|
-
* The replacement process migrates all of the attributes / classes from the old element to the new
|
|
6950
|
-
* one. See the {@link guide/directive#template-expanding-directive
|
|
6951
|
-
* Directives Guide} for an example.
|
|
6952
|
-
*
|
|
6953
|
-
* There are very few scenarios where element replacement is required for the application function,
|
|
6954
|
-
* the main one being reusable custom components that are used within SVG contexts
|
|
6955
|
-
* (because SVG doesn't work with custom elements in the DOM tree).
|
|
6956
|
-
*
|
|
6957
|
-
* #### `transclude`
|
|
6958
|
-
* Extract the contents of the element where the directive appears and make it available to the directive.
|
|
6959
|
-
* The contents are compiled and provided to the directive as a **transclusion function**. See the
|
|
6960
|
-
* {@link $compile#transclusion Transclusion} section below.
|
|
6961
|
-
*
|
|
6962
|
-
*
|
|
6963
|
-
* #### `compile`
|
|
6964
|
-
*
|
|
6965
|
-
* ```js
|
|
6966
|
-
* function compile(tElement, tAttrs, transclude) { ... }
|
|
6967
|
-
* ```
|
|
6968
|
-
*
|
|
6969
|
-
* The compile function deals with transforming the template DOM. Since most directives do not do
|
|
6970
|
-
* template transformation, it is not used often. The compile function takes the following arguments:
|
|
6971
|
-
*
|
|
6972
|
-
* * `tElement` - template element - The element where the directive has been declared. It is
|
|
6973
|
-
* safe to do template transformation on the element and child elements only.
|
|
6974
|
-
*
|
|
6975
|
-
* * `tAttrs` - template attributes - Normalized list of attributes declared on this element shared
|
|
6976
|
-
* between all directive compile functions.
|
|
6977
|
-
*
|
|
6978
|
-
* * `transclude` - [*DEPRECATED*!] A transclude linking function: `function(scope, cloneLinkingFn)`
|
|
6979
|
-
*
|
|
6980
|
-
* <div class="alert alert-warning">
|
|
6981
|
-
* **Note:** The template instance and the link instance may be different objects if the template has
|
|
6982
|
-
* been cloned. For this reason it is **not** safe to do anything other than DOM transformations that
|
|
6983
|
-
* apply to all cloned DOM nodes within the compile function. Specifically, DOM listener registration
|
|
6984
|
-
* should be done in a linking function rather than in a compile function.
|
|
6985
|
-
* </div>
|
|
6986
|
-
|
|
6987
|
-
* <div class="alert alert-warning">
|
|
6988
|
-
* **Note:** The compile function cannot handle directives that recursively use themselves in their
|
|
6989
|
-
* own templates or compile functions. Compiling these directives results in an infinite loop and
|
|
6990
|
-
* stack overflow errors.
|
|
6991
|
-
*
|
|
6992
|
-
* This can be avoided by manually using `$compile` in the postLink function to imperatively compile
|
|
6993
|
-
* a directive's template instead of relying on automatic template compilation via `template` or
|
|
6994
|
-
* `templateUrl` declaration or manual compilation inside the compile function.
|
|
6995
|
-
* </div>
|
|
6996
|
-
*
|
|
6997
|
-
* <div class="alert alert-danger">
|
|
6998
|
-
* **Note:** The `transclude` function that is passed to the compile function is deprecated, as it
|
|
6999
|
-
* e.g. does not know about the right outer scope. Please use the transclude function that is passed
|
|
7000
|
-
* to the link function instead.
|
|
7001
|
-
* </div>
|
|
7002
|
-
|
|
7003
|
-
* A compile function can have a return value which can be either a function or an object.
|
|
7004
|
-
*
|
|
7005
|
-
* * returning a (post-link) function - is equivalent to registering the linking function via the
|
|
7006
|
-
* `link` property of the config object when the compile function is empty.
|
|
7007
|
-
*
|
|
7008
|
-
* * returning an object with function(s) registered via `pre` and `post` properties - allows you to
|
|
7009
|
-
* control when a linking function should be called during the linking phase. See info about
|
|
7010
|
-
* pre-linking and post-linking functions below.
|
|
7011
|
-
*
|
|
7012
|
-
*
|
|
7013
|
-
* #### `link`
|
|
7014
|
-
* This property is used only if the `compile` property is not defined.
|
|
7015
|
-
*
|
|
7016
|
-
* ```js
|
|
7017
|
-
* function link(scope, iElement, iAttrs, controller, transcludeFn) { ... }
|
|
7018
|
-
* ```
|
|
7019
|
-
*
|
|
7020
|
-
* The link function is responsible for registering DOM listeners as well as updating the DOM. It is
|
|
7021
|
-
* executed after the template has been cloned. This is where most of the directive logic will be
|
|
7022
|
-
* put.
|
|
7023
|
-
*
|
|
7024
|
-
* * `scope` - {@link ng.$rootScope.Scope Scope} - The scope to be used by the
|
|
7025
|
-
* directive for registering {@link ng.$rootScope.Scope#$watch watches}.
|
|
7026
|
-
*
|
|
7027
|
-
* * `iElement` - instance element - The element where the directive is to be used. It is safe to
|
|
7028
|
-
* manipulate the children of the element only in `postLink` function since the children have
|
|
7029
|
-
* already been linked.
|
|
7030
|
-
*
|
|
7031
|
-
* * `iAttrs` - instance attributes - Normalized list of attributes declared on this element shared
|
|
7032
|
-
* between all directive linking functions.
|
|
7033
|
-
*
|
|
7034
|
-
* * `controller` - the directive's required controller instance(s) - Instances are shared
|
|
7035
|
-
* among all directives, which allows the directives to use the controllers as a communication
|
|
7036
|
-
* channel. The exact value depends on the directive's `require` property:
|
|
7037
|
-
* * no controller(s) required: the directive's own controller, or `undefined` if it doesn't have one
|
|
7038
|
-
* * `string`: the controller instance
|
|
7039
|
-
* * `array`: array of controller instances
|
|
7040
|
-
*
|
|
7041
|
-
* If a required controller cannot be found, and it is optional, the instance is `null`,
|
|
7042
|
-
* otherwise the {@link error:$compile:ctreq Missing Required Controller} error is thrown.
|
|
7043
|
-
*
|
|
7044
|
-
* Note that you can also require the directive's own controller - it will be made available like
|
|
7045
|
-
* any other controller.
|
|
7046
|
-
*
|
|
7047
|
-
* * `transcludeFn` - A transclude linking function pre-bound to the correct transclusion scope.
|
|
7048
|
-
* This is the same as the `$transclude` parameter of directive controllers,
|
|
7049
|
-
* see {@link ng.$compile#-controller- the controller section for details}.
|
|
7050
|
-
* `function([scope], cloneLinkingFn, futureParentElement)`.
|
|
7051
|
-
*
|
|
7052
|
-
* #### Pre-linking function
|
|
7053
|
-
*
|
|
7054
|
-
* Executed before the child elements are linked. Not safe to do DOM transformation since the
|
|
7055
|
-
* compiler linking function will fail to locate the correct elements for linking.
|
|
7056
|
-
*
|
|
7057
|
-
* #### Post-linking function
|
|
7058
|
-
*
|
|
7059
|
-
* Executed after the child elements are linked.
|
|
7060
|
-
*
|
|
7061
|
-
* Note that child elements that contain `templateUrl` directives will not have been compiled
|
|
7062
|
-
* and linked since they are waiting for their template to load asynchronously and their own
|
|
7063
|
-
* compilation and linking has been suspended until that occurs.
|
|
7064
|
-
*
|
|
7065
|
-
* It is safe to do DOM transformation in the post-linking function on elements that are not waiting
|
|
7066
|
-
* for their async templates to be resolved.
|
|
7067
|
-
*
|
|
7068
|
-
*
|
|
7069
|
-
* ### Transclusion
|
|
7070
|
-
*
|
|
7071
|
-
* Transclusion is the process of extracting a collection of DOM elements from one part of the DOM and
|
|
7072
|
-
* copying them to another part of the DOM, while maintaining their connection to the original AngularJS
|
|
7073
|
-
* scope from where they were taken.
|
|
7074
|
-
*
|
|
7075
|
-
* Transclusion is used (often with {@link ngTransclude}) to insert the
|
|
7076
|
-
* original contents of a directive's element into a specified place in the template of the directive.
|
|
7077
|
-
* The benefit of transclusion, over simply moving the DOM elements manually, is that the transcluded
|
|
7078
|
-
* content has access to the properties on the scope from which it was taken, even if the directive
|
|
7079
|
-
* has isolated scope.
|
|
7080
|
-
* See the {@link guide/directive#creating-a-directive-that-wraps-other-elements Directives Guide}.
|
|
7081
|
-
*
|
|
7082
|
-
* This makes it possible for the widget to have private state for its template, while the transcluded
|
|
7083
|
-
* content has access to its originating scope.
|
|
7084
|
-
*
|
|
7085
|
-
* <div class="alert alert-warning">
|
|
7086
|
-
* **Note:** When testing an element transclude directive you must not place the directive at the root of the
|
|
7087
|
-
* DOM fragment that is being compiled. See {@link guide/unit-testing#testing-transclusion-directives
|
|
7088
|
-
* Testing Transclusion Directives}.
|
|
7089
|
-
* </div>
|
|
7090
|
-
*
|
|
7091
|
-
* There are three kinds of transclusion depending upon whether you want to transclude just the contents of the
|
|
7092
|
-
* directive's element, the entire element or multiple parts of the element contents:
|
|
7093
|
-
*
|
|
7094
|
-
* * `true` - transclude the content (i.e. the child nodes) of the directive's element.
|
|
7095
|
-
* * `'element'` - transclude the whole of the directive's element including any directives on this
|
|
7096
|
-
* element that are defined at a lower priority than this directive. When used, the `template`
|
|
7097
|
-
* property is ignored.
|
|
7098
|
-
* * **`{...}` (an object hash):** - map elements of the content onto transclusion "slots" in the template.
|
|
7099
|
-
*
|
|
7100
|
-
* **Multi-slot transclusion** is declared by providing an object for the `transclude` property.
|
|
7101
|
-
*
|
|
7102
|
-
* This object is a map where the keys are the name of the slot to fill and the value is an element selector
|
|
7103
|
-
* used to match the HTML to the slot. The element selector should be in normalized form (e.g. `myElement`)
|
|
7104
|
-
* and will match the standard element variants (e.g. `my-element`, `my:element`, `data-my-element`, etc).
|
|
7105
|
-
*
|
|
7106
|
-
* For further information check out the guide on {@link guide/directive#matching-directives Matching Directives}.
|
|
7107
|
-
*
|
|
7108
|
-
* If the element selector is prefixed with a `?` then that slot is optional.
|
|
7109
|
-
*
|
|
7110
|
-
* For example, the transclude object `{ slotA: '?myCustomElement' }` maps `<my-custom-element>` elements to
|
|
7111
|
-
* the `slotA` slot, which can be accessed via the `$transclude` function or via the {@link ngTransclude} directive.
|
|
7112
|
-
*
|
|
7113
|
-
* Slots that are not marked as optional (`?`) will trigger a compile time error if there are no matching elements
|
|
7114
|
-
* in the transclude content. If you wish to know if an optional slot was filled with content, then you can call
|
|
7115
|
-
* `$transclude.isSlotFilled(slotName)` on the transclude function passed to the directive's link function and
|
|
7116
|
-
* injectable into the directive's controller.
|
|
7117
|
-
*
|
|
7118
|
-
*
|
|
7119
|
-
* #### Transclusion Functions
|
|
7120
|
-
*
|
|
7121
|
-
* When a directive requests transclusion, the compiler extracts its contents and provides a **transclusion
|
|
7122
|
-
* function** to the directive's `link` function and `controller`. This transclusion function is a special
|
|
7123
|
-
* **linking function** that will return the compiled contents linked to a new transclusion scope.
|
|
7124
|
-
*
|
|
7125
|
-
* <div class="alert alert-info">
|
|
7126
|
-
* If you are just using {@link ngTransclude} then you don't need to worry about this function, since
|
|
7127
|
-
* ngTransclude will deal with it for us.
|
|
7128
|
-
* </div>
|
|
7129
|
-
*
|
|
7130
|
-
* If you want to manually control the insertion and removal of the transcluded content in your directive
|
|
7131
|
-
* then you must use this transclude function. When you call a transclude function it returns a jqLite/JQuery
|
|
7132
|
-
* object that contains the compiled DOM, which is linked to the correct transclusion scope.
|
|
7133
|
-
*
|
|
7134
|
-
* When you call a transclusion function you can pass in a **clone attach function**. This function accepts
|
|
7135
|
-
* two parameters, `function(clone, scope) { ... }`, where the `clone` is a fresh compiled copy of your transcluded
|
|
7136
|
-
* content and the `scope` is the newly created transclusion scope, which the clone will be linked to.
|
|
7137
|
-
*
|
|
7138
|
-
* <div class="alert alert-info">
|
|
7139
|
-
* **Best Practice**: Always provide a `cloneFn` (clone attach function) when you call a transclude function
|
|
7140
|
-
* since you then get a fresh clone of the original DOM and also have access to the new transclusion scope.
|
|
7141
|
-
* </div>
|
|
7142
|
-
*
|
|
7143
|
-
* It is normal practice to attach your transcluded content (`clone`) to the DOM inside your **clone
|
|
7144
|
-
* attach function**:
|
|
7145
|
-
*
|
|
7146
|
-
* ```js
|
|
7147
|
-
* let transcludedContent, transclusionScope;
|
|
7148
|
-
*
|
|
7149
|
-
* $transclude(function(clone, scope) {
|
|
7150
|
-
* element.append(clone);
|
|
7151
|
-
* transcludedContent = clone;
|
|
7152
|
-
* transclusionScope = scope;
|
|
7153
|
-
* });
|
|
7154
|
-
* ```
|
|
7155
|
-
*
|
|
7156
|
-
* Later, if you want to remove the transcluded content from your DOM then you should also destroy the
|
|
7157
|
-
* associated transclusion scope:
|
|
7158
|
-
*
|
|
7159
|
-
* ```js
|
|
7160
|
-
* transcludedContent.remove();
|
|
7161
|
-
* transclusionScope.$destroy();
|
|
7162
|
-
* ```
|
|
7163
|
-
*
|
|
7164
|
-
* <div class="alert alert-info">
|
|
7165
|
-
* **Best Practice**: if you intend to add and remove transcluded content manually in your directive
|
|
7166
|
-
* (by calling the transclude function to get the DOM and calling `element.remove()` to remove it),
|
|
7167
|
-
* then you are also responsible for calling `$destroy` on the transclusion scope.
|
|
7168
|
-
* </div>
|
|
7169
|
-
*
|
|
7170
|
-
* The built-in DOM manipulation directives, such as {@link ngIf}, {@link ngSwitch} and {@link ngRepeat}
|
|
7171
|
-
* automatically destroy their transcluded clones as necessary so you do not need to worry about this if
|
|
7172
|
-
* you are simply using {@link ngTransclude} to inject the transclusion into your directive.
|
|
7173
|
-
*
|
|
7174
|
-
*
|
|
7175
|
-
* #### Transclusion Scopes
|
|
7176
|
-
*
|
|
7177
|
-
* When you call a transclude function it returns a DOM fragment that is pre-bound to a **transclusion
|
|
7178
|
-
* scope**. This scope is special, in that it is a child of the directive's scope (and so gets destroyed
|
|
7179
|
-
* when the directive's scope gets destroyed) but it inherits the properties of the scope from which it
|
|
7180
|
-
* was taken.
|
|
7181
|
-
*
|
|
7182
|
-
* For example consider a directive that uses transclusion and isolated scope. The DOM hierarchy might look
|
|
7183
|
-
* like this:
|
|
7184
|
-
*
|
|
7185
|
-
* ```html
|
|
7186
|
-
* <div ng-app>
|
|
7187
|
-
* <div isolate>
|
|
7188
|
-
* <div transclusion>
|
|
7189
|
-
* </div>
|
|
7190
|
-
* </div>
|
|
7191
|
-
* </div>
|
|
7192
|
-
* ```
|
|
7193
|
-
*
|
|
7194
|
-
* The `$parent` scope hierarchy will look like this:
|
|
7195
|
-
*
|
|
7196
|
-
```
|
|
7197
|
-
- $rootScope
|
|
7198
|
-
- isolate
|
|
7199
|
-
- transclusion
|
|
7200
|
-
```
|
|
7201
|
-
*
|
|
7202
|
-
* but the scopes will inherit prototypically from different scopes to their `$parent`.
|
|
7203
|
-
*
|
|
7204
|
-
```
|
|
7205
|
-
- $rootScope
|
|
7206
|
-
- transclusion
|
|
7207
|
-
- isolate
|
|
7208
|
-
```
|
|
7209
|
-
*
|
|
7210
|
-
*
|
|
7211
|
-
* ### Attributes
|
|
7212
|
-
*
|
|
7213
|
-
* The {@link ng.$compile.directive.Attributes Attributes} object - passed as a parameter in the
|
|
7214
|
-
* `link()` or `compile()` functions. It has a variety of uses.
|
|
7215
|
-
*
|
|
7216
|
-
* * *Accessing normalized attribute names:* Directives like `ngBind` can be expressed in many ways:
|
|
7217
|
-
* `ng:bind`, `data-ng-bind`, or `x-ng-bind`. The attributes object allows for normalized access
|
|
7218
|
-
* to the attributes.
|
|
7219
|
-
*
|
|
7220
|
-
* * *Directive inter-communication:* All directives share the same instance of the attributes
|
|
7221
|
-
* object which allows the directives to use the attributes object as inter directive
|
|
7222
|
-
* communication.
|
|
7223
|
-
*
|
|
7224
|
-
* * *Supports interpolation:* Interpolation attributes are assigned to the attribute object
|
|
7225
|
-
* allowing other directives to read the interpolated value.
|
|
7226
|
-
*
|
|
7227
|
-
* * *Observing interpolated attributes:* Use `$observe` to observe the value changes of attributes
|
|
7228
|
-
* that contain interpolation (e.g. `src="{{bar}}"`). Not only is this very efficient but it's also
|
|
7229
|
-
* the only way to easily get the actual value because during the linking phase the interpolation
|
|
7230
|
-
* hasn't been evaluated yet and so the value is at this time set to `undefined`.
|
|
7231
|
-
*
|
|
7232
|
-
* ```js
|
|
7233
|
-
* function linkingFn(scope, elm, attrs, ctrl) {
|
|
7234
|
-
* // get the attribute value
|
|
7235
|
-
* console.log(attrs.ngModel);
|
|
7236
|
-
*
|
|
7237
|
-
* // change the attribute
|
|
7238
|
-
* attrs.$set('ngModel', 'new value');
|
|
7239
|
-
*
|
|
7240
|
-
* // observe changes to interpolated attribute
|
|
7241
|
-
* attrs.$observe('ngModel', function(value) {
|
|
7242
|
-
* console.log('ngModel has changed value to ' + value);
|
|
7243
|
-
* });
|
|
7244
|
-
* }
|
|
7245
|
-
* ```
|
|
7246
|
-
*
|
|
7247
|
-
*
|
|
7248
|
-
*
|
|
7249
|
-
* @param {string|Element} element Element or HTML string to compile into a template function.
|
|
7250
|
-
* @param {function(angular.Scope, cloneAttachFn=)} transclude function available to directives - DEPRECATED.
|
|
7251
|
-
*
|
|
7252
|
-
* <div class="alert alert-danger">
|
|
7253
|
-
* **Note:** Passing a `transclude` function to the $compile function is deprecated, as it
|
|
7254
|
-
* e.g. will not use the right outer scope. Please pass the transclude function as a
|
|
7255
|
-
* `parentBoundTranscludeFn` to the link function instead.
|
|
7256
|
-
* </div>
|
|
7257
|
-
*
|
|
7258
|
-
* @param {number} maxPriority only apply directives lower than given priority (Only effects the
|
|
7259
|
-
* root element(s), not their children)
|
|
7260
|
-
* @returns {function(scope, cloneAttachFn=, options=)} a link function which is used to bind template
|
|
7261
|
-
* (a DOM element/tree) to a scope. Where:
|
|
7262
|
-
*
|
|
7263
|
-
* * `scope` - A {@link ng.$rootScope.Scope Scope} to bind to.
|
|
7264
|
-
* * `cloneAttachFn` - If `cloneAttachFn` is provided, then the link function will clone the
|
|
7265
|
-
* `template` and call the `cloneAttachFn` function allowing the caller to attach the
|
|
7266
|
-
* cloned elements to the DOM document at the appropriate place. The `cloneAttachFn` is
|
|
7267
|
-
* called as: <br/> `cloneAttachFn(clonedElement, scope)` where:
|
|
7268
|
-
*
|
|
7269
|
-
* * `clonedElement` - is a clone of the original `element` passed into the compiler.
|
|
7270
|
-
* * `scope` - is the current scope with which the linking function is working with.
|
|
7271
|
-
*
|
|
7272
|
-
* * `options` - An optional object hash with linking options. If `options` is provided, then the following
|
|
7273
|
-
* keys may be used to control linking behavior:
|
|
7274
|
-
*
|
|
7275
|
-
* * `parentBoundTranscludeFn` - the transclude function made available to
|
|
7276
|
-
* directives; if given, it will be passed through to the link functions of
|
|
7277
|
-
* directives found in `element` during compilation.
|
|
7278
|
-
* * `transcludeControllers` - an object hash with keys that map controller names
|
|
7279
|
-
* to a hash with the key `instance`, which maps to the controller instance;
|
|
7280
|
-
* if given, it will make the controllers available to directives on the compileNode:
|
|
7281
|
-
* ```
|
|
7282
|
-
* {
|
|
7283
|
-
* parent: {
|
|
7284
|
-
* instance: parentControllerInstance
|
|
7285
|
-
* }
|
|
7286
|
-
* }
|
|
7287
|
-
* ```
|
|
7288
|
-
* * `futureParentElement` - defines the parent to which the `cloneAttachFn` will add
|
|
7289
|
-
* the cloned elements; only needed for transcludes that are allowed to contain non HTML
|
|
7290
|
-
* elements (e.g. SVG elements). See also the `directive.controller` property.
|
|
7291
|
-
*
|
|
7292
|
-
* Calling the linking function returns the element of the template. It is either the original
|
|
7293
|
-
* element passed in, or the clone of the element if the `cloneAttachFn` is provided.
|
|
7294
|
-
*
|
|
7295
|
-
* After linking the view is not updated until after a call to `$digest`, which typically is done by
|
|
7296
|
-
* AngularJS automatically.
|
|
7297
|
-
*
|
|
7298
|
-
* If you need access to the bound view, there are two ways to do it:
|
|
7299
|
-
*
|
|
7300
|
-
* - If you are not asking the linking function to clone the template, create the DOM element(s)
|
|
7301
|
-
* before you send them to the compiler and keep this reference around.
|
|
7302
|
-
* ```js
|
|
7303
|
-
* let element = angular.element('<p>{{total}}</p>');
|
|
7304
|
-
* $compile(element)(scope);
|
|
7305
|
-
* ```
|
|
7306
|
-
*
|
|
7307
|
-
* - if on the other hand, you need the element to be cloned, the view reference from the original
|
|
7308
|
-
* example would not point to the clone, but rather to the original template that was cloned. In
|
|
7309
|
-
* this case, you can access the clone either via the `cloneAttachFn` or the value returned by the
|
|
7310
|
-
* linking function:
|
|
7311
|
-
* ```js
|
|
7312
|
-
* let templateElement = angular.element('<p>{{total}}</p>');
|
|
7313
|
-
* let clonedElement = $compile(templateElement)(scope, function(clonedElement, scope) {
|
|
7314
|
-
* // Attach the clone to DOM document at the right place.
|
|
7315
|
-
* });
|
|
7316
|
-
*
|
|
7317
|
-
* // Now we have reference to the cloned DOM via `clonedElement`.
|
|
7318
|
-
* // NOTE: The `clonedElement` returned by the linking function is the same as the
|
|
7319
|
-
* // `clonedElement` passed to `cloneAttachFn`.
|
|
7320
|
-
* ```
|
|
7321
|
-
*
|
|
7322
|
-
*
|
|
7323
|
-
* For information on how the compiler works, see the
|
|
7324
|
-
* {@link guide/compiler AngularJS HTML Compiler} section of the Developer Guide.
|
|
7325
|
-
*
|
|
7326
|
-
* @knownIssue
|
|
7327
|
-
*
|
|
7328
|
-
* ### Double Compilation
|
|
7329
|
-
*
|
|
7330
|
-
Double compilation occurs when an already compiled part of the DOM gets
|
|
7331
|
-
compiled again. This is an undesired effect and can lead to misbehaving directives, performance issues,
|
|
7332
|
-
and memory leaks. Refer to the Compiler Guide {@link guide/compiler#double-compilation-and-how-to-avoid-it
|
|
7333
|
-
section on double compilation} for an in-depth explanation and ways to avoid it.
|
|
7334
|
-
|
|
7335
|
-
* @knownIssue
|
|
7336
|
-
|
|
7337
|
-
### Issues with `replace: true`
|
|
7338
|
-
*
|
|
7339
|
-
* <div class="alert alert-danger">
|
|
7340
|
-
* **Note**: {@link $compile#-replace- `replace: true`} is deprecated and not recommended to use,
|
|
7341
|
-
* mainly due to the issues listed here. It has been completely removed in the new Angular.
|
|
7342
|
-
* </div>
|
|
7343
|
-
*
|
|
7344
|
-
* #### Attribute values are not merged
|
|
7345
|
-
*
|
|
7346
|
-
* When a `replace` directive encounters the same attribute on the original and the replace node,
|
|
7347
|
-
* it will simply deduplicate the attribute and join the values with a space or with a `;` in case of
|
|
7348
|
-
* the `style` attribute.
|
|
7349
|
-
* ```html
|
|
7350
|
-
* Original Node: <span class="original" style="color: red;"></span>
|
|
7351
|
-
* Replace Template: <span class="replaced" style="background: blue;"></span>
|
|
7352
|
-
* Result: <span class="original replaced" style="color: red; background: blue;"></span>
|
|
7353
|
-
* ```
|
|
7354
|
-
*
|
|
7355
|
-
* That means attributes that contain AngularJS expressions will not be merged correctly, e.g.
|
|
7356
|
-
* {@link ngShow} or {@link ngClass} will cause a {@link $parse} error:
|
|
7357
|
-
*
|
|
7358
|
-
* ```html
|
|
7359
|
-
* Original Node: <span ng-class="{'something': something}" ng-show="!condition"></span>
|
|
7360
|
-
* Replace Template: <span ng-class="{'else': else}" ng-show="otherCondition"></span>
|
|
7361
|
-
* Result: <span ng-class="{'something': something} {'else': else}" ng-show="!condition otherCondition"></span>
|
|
7362
|
-
* ```
|
|
7363
|
-
*
|
|
7364
|
-
* See issue [#5695](https://github.com/angular/angular.js/issues/5695).
|
|
7365
|
-
*
|
|
7366
|
-
* #### Directives are not deduplicated before compilation
|
|
7367
|
-
*
|
|
7368
|
-
* When the original node and the replace template declare the same directive(s), they will be
|
|
7369
|
-
* {@link guide/compiler#double-compilation-and-how-to-avoid-it compiled twice} because the compiler
|
|
7370
|
-
* does not deduplicate them. In many cases, this is not noticeable, but e.g. {@link ngModel} will
|
|
7371
|
-
* attach `$formatters` and `$parsers` twice.
|
|
7372
|
-
*
|
|
7373
|
-
* See issue [#2573](https://github.com/angular/angular.js/issues/2573).
|
|
7374
|
-
*
|
|
7375
|
-
* #### `transclude: element` in the replace template root can have unexpected effects
|
|
7376
|
-
*
|
|
7377
|
-
* When the replace template has a directive at the root node that uses
|
|
7378
|
-
* {@link $compile#-transclude- `transclude: element`}, e.g.
|
|
7379
|
-
* {@link ngIf} or {@link ngRepeat}, the DOM structure or scope inheritance can be incorrect.
|
|
7380
|
-
* See the following issues:
|
|
7381
|
-
*
|
|
7382
|
-
* - Incorrect scope on replaced element:
|
|
7383
|
-
* [#9837](https://github.com/angular/angular.js/issues/9837)
|
|
7384
|
-
* - Different DOM between `template` and `templateUrl`:
|
|
7385
|
-
* [#10612](https://github.com/angular/angular.js/issues/14326)
|
|
7386
|
-
*
|
|
7387
|
-
*/
|
|
7388
|
-
|
|
7389
|
-
/**
|
|
7390
|
-
* @ngdoc directive
|
|
7391
|
-
* @name ngProp
|
|
7392
|
-
* @restrict A
|
|
7393
|
-
* @element ANY
|
|
7394
|
-
*
|
|
7395
|
-
* @usage
|
|
7396
|
-
*
|
|
7397
|
-
* ```html
|
|
7398
|
-
* <ANY ng-prop-propname="expression">
|
|
7399
|
-
* </ANY>
|
|
7400
|
-
* ```
|
|
7401
|
-
*
|
|
7402
|
-
* or with uppercase letters in property (e.g. "propName"):
|
|
7403
|
-
*
|
|
7404
|
-
*
|
|
7405
|
-
* ```html
|
|
7406
|
-
* <ANY ng-prop-prop_name="expression">
|
|
7407
|
-
* </ANY>
|
|
7408
|
-
* ```
|
|
7409
|
-
*
|
|
7410
|
-
*
|
|
7411
|
-
* @description
|
|
7412
|
-
* The `ngProp` directive binds an expression to a DOM element property.
|
|
7413
|
-
* `ngProp` allows writing to arbitrary properties by including
|
|
7414
|
-
* the property name in the attribute, e.g. `ng-prop-value="'my value'"` binds 'my value' to
|
|
7415
|
-
* the `value` property.
|
|
7416
|
-
*
|
|
7417
|
-
* Usually, it's not necessary to write to properties in AngularJS, as the built-in directives
|
|
7418
|
-
* handle the most common use cases (instead of the above example, you would use {@link ngValue}).
|
|
7419
|
-
*
|
|
7420
|
-
* However, [custom elements](https://developer.mozilla.org/docs/Web/Web_Components/Using_custom_elements)
|
|
7421
|
-
* often use custom properties to hold data, and `ngProp` can be used to provide input to these
|
|
7422
|
-
* custom elements.
|
|
7423
|
-
*
|
|
7424
|
-
* ## Binding to camelCase properties
|
|
7425
|
-
*
|
|
7426
|
-
* Since HTML attributes are case-insensitive, camelCase properties like `innerHTML` must be escaped.
|
|
7427
|
-
* AngularJS uses the underscore (_) in front of a character to indicate that it is uppercase, so
|
|
7428
|
-
* `innerHTML` must be written as `ng-prop-inner_h_t_m_l="expression"` (Note that this is just an
|
|
7429
|
-
* example, and for binding HTML {@link ngBindHtml} should be used.
|
|
7430
|
-
*
|
|
7431
|
-
* ## Security
|
|
7432
|
-
*
|
|
7433
|
-
* Binding expressions to arbitrary properties poses a security risk, as properties like `innerHTML`
|
|
7434
|
-
* can insert potentially dangerous HTML into the application, e.g. script tags that execute
|
|
7435
|
-
* malicious code.
|
|
7436
|
-
* For this reason, `ngProp` applies Strict Contextual Escaping with the {@link ng.$sce $sce service}.
|
|
7437
|
-
* This means vulnerable properties require their content to be "trusted", based on the
|
|
7438
|
-
* context of the property. For example, the `innerHTML` is in the `HTML` context, and the
|
|
7439
|
-
* `iframe.src` property is in the `RESOURCE_URL` context, which requires that values written to
|
|
7440
|
-
* this property are trusted as a `RESOURCE_URL`.
|
|
7441
|
-
*
|
|
7442
|
-
* This can be set explicitly by calling $sce.trustAs(type, value) on the value that is
|
|
7443
|
-
* trusted before passing it to the `ng-prop-*` directive. There are exist shorthand methods for
|
|
7444
|
-
* each context type in the form of {@link ng.$sce#trustAsResourceUrl $sce.trustAsResourceUrl()} et al.
|
|
7445
|
-
*
|
|
7446
|
-
* In some cases you can also rely upon automatic sanitization of untrusted values - see below.
|
|
7447
|
-
*
|
|
7448
|
-
* Based on the context, other options may exist to mark a value as trusted / configure the behavior
|
|
7449
|
-
* of {@link ng.$sce}. For example, to restrict the `RESOURCE_URL` context to specific origins, use
|
|
7450
|
-
* the {@link $sceDelegateProvider#trustedResourceUrlList trustedResourceUrlList()}
|
|
7451
|
-
* and {@link $sceDelegateProvider#bannedResourceUrlList bannedResourceUrlList()}.
|
|
7452
|
-
*
|
|
7453
|
-
* {@link ng.$sce#what-trusted-context-types-are-supported- Find out more about the different context types}.
|
|
7454
|
-
*
|
|
7455
|
-
* ### HTML Sanitization
|
|
7456
|
-
*
|
|
7457
|
-
* By default, `$sce` will throw an error if it detects untrusted HTML content, and will not bind the
|
|
7458
|
-
* content.
|
|
7459
|
-
* However, if you include the {@link ngSanitize ngSanitize module}, it will try to sanitize the
|
|
7460
|
-
* potentially dangerous HTML, e.g. strip non-trusted tags and attributes when binding to
|
|
7461
|
-
* `innerHTML`.
|
|
7462
|
-
*
|
|
7463
|
-
*
|
|
7464
|
-
*/
|
|
7465
|
-
|
|
7466
|
-
/** @ngdoc directive
|
|
7467
|
-
* @name ngOn
|
|
7468
|
-
* @restrict A
|
|
7469
|
-
* @element ANY
|
|
7470
|
-
*
|
|
7471
|
-
* @usage
|
|
7472
|
-
*
|
|
7473
|
-
* ```html
|
|
7474
|
-
* <ANY ng-on-eventname="expression">
|
|
7475
|
-
* </ANY>
|
|
7476
|
-
* ```
|
|
7477
|
-
*
|
|
7478
|
-
* or with uppercase letters in property (e.g. "eventName"):
|
|
7479
|
-
*
|
|
7480
|
-
*
|
|
7481
|
-
* ```html
|
|
7482
|
-
* <ANY ng-on-event_name="expression">
|
|
7483
|
-
* </ANY>
|
|
7484
|
-
* ```
|
|
7485
|
-
*
|
|
7486
|
-
* @description
|
|
7487
|
-
* The `ngOn` directive adds an event listener to a DOM element via
|
|
7488
|
-
* {@link angular.element angular.element().on()}, and evaluates an expression when the event is
|
|
7489
|
-
* fired.
|
|
7490
|
-
* `ngOn` allows adding listeners for arbitrary events by including
|
|
7491
|
-
* the event name in the attribute, e.g. `ng-on-drop="onDrop()"` executes the 'onDrop()' expression
|
|
7492
|
-
* when the `drop` event is fired.
|
|
7493
|
-
*
|
|
7494
|
-
* AngularJS provides specific directives for many events, such as {@link ngClick}, so in most
|
|
7495
|
-
* cases it is not necessary to use `ngOn`. However, AngularJS does not support all events
|
|
7496
|
-
* (e.g. the `drop` event in the example above), and new events might be introduced in later DOM
|
|
7497
|
-
* standards.
|
|
7498
|
-
*
|
|
7499
|
-
* Another use-case for `ngOn` is listening to
|
|
7500
|
-
* [custom events](https://developer.mozilla.org/docs/Web/Guide/Events/Creating_and_triggering_events)
|
|
7501
|
-
* fired by
|
|
7502
|
-
* [custom elements](https://developer.mozilla.org/docs/Web/Web_Components/Using_custom_elements).
|
|
7503
|
-
*
|
|
7504
|
-
* ## Binding to camelCase properties
|
|
7505
|
-
*
|
|
7506
|
-
* Since HTML attributes are case-insensitive, camelCase properties like `myEvent` must be escaped.
|
|
7507
|
-
* AngularJS uses the underscore (_) in front of a character to indicate that it is uppercase, so
|
|
7508
|
-
* `myEvent` must be written as `ng-on-my_event="expression"`.
|
|
7509
|
-
*
|
|
7510
|
-
*
|
|
7511
|
-
*/
|
|
7512
|
-
|
|
7513
6396
|
const $compileMinErr = minErr("$compile");
|
|
7514
6397
|
|
|
7515
6398
|
function UNINITIALIZED_VALUE() {}
|
|
@@ -8416,7 +7299,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
8416
7299
|
let nodeName;
|
|
8417
7300
|
|
|
8418
7301
|
if (booleanKey) {
|
|
8419
|
-
this.$$element
|
|
7302
|
+
this.$$element[0][key] = value;
|
|
8420
7303
|
attrName = booleanKey;
|
|
8421
7304
|
} else if (aliasedKey) {
|
|
8422
7305
|
this[aliasedKey] = value;
|
|
@@ -10544,6 +9427,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
10544
9427
|
function sanitizeSrcsetPropertyValue(value) {
|
|
10545
9428
|
return sanitizeSrcset($sce.valueOf(value), "ng-prop-srcset");
|
|
10546
9429
|
}
|
|
9430
|
+
|
|
10547
9431
|
function addPropertyDirective(node, directives, attrName, propName) {
|
|
10548
9432
|
if (EVENT_HANDLER_ATTR_REGEXP.test(propName)) {
|
|
10549
9433
|
throw $compileMinErr(
|
|
@@ -10696,9 +9580,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
10696
9580
|
* This is a special jqLite.replaceWith, which can replace items which
|
|
10697
9581
|
* have no parents, provided that the containing jqLite collection is provided.
|
|
10698
9582
|
*
|
|
10699
|
-
* @param {
|
|
9583
|
+
* @param {JQLite} $rootElement The root of the compile tree. Used so that we can replace nodes
|
|
10700
9584
|
* in the root of the tree.
|
|
10701
|
-
* @param {
|
|
9585
|
+
* @param {JQLite} elementsToRemove The jqLite element which we are going to replace. We keep
|
|
10702
9586
|
* the shell, but replace its DOM node reference.
|
|
10703
9587
|
* @param {Node} newNode The new DOM node.
|
|
10704
9588
|
*/
|
|
@@ -10750,7 +9634,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
10750
9634
|
fragment.appendChild(elementsToRemove[i]);
|
|
10751
9635
|
}
|
|
10752
9636
|
|
|
10753
|
-
if (
|
|
9637
|
+
if (CACHE.has(firstElementToRemove[EXPANDO])) {
|
|
10754
9638
|
// Copy over user data (that includes AngularJS's $scope etc.). Don't copy private
|
|
10755
9639
|
// data here because there's no public interface in jQuery to do that and copying over
|
|
10756
9640
|
// event listeners (which is the main use of private data) wouldn't work anyway.
|
|
@@ -11124,7 +10008,7 @@ function htmlAnchorDirective() {
|
|
|
11124
10008
|
|
|
11125
10009
|
// SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
|
|
11126
10010
|
const href =
|
|
11127
|
-
toString.call(element.
|
|
10011
|
+
toString.call(element[0].href) === "[object SVGAnimatedString]"
|
|
11128
10012
|
? "xlink:href"
|
|
11129
10013
|
: "href";
|
|
11130
10014
|
element.on("click", (event) => {
|
|
@@ -14760,7 +13644,7 @@ function badInputChecker(scope, element, attr, ctrl, parserName) {
|
|
|
14760
13644
|
|
|
14761
13645
|
if (nativeValidation) {
|
|
14762
13646
|
ctrl.$parsers.push((value) => {
|
|
14763
|
-
const validity = element
|
|
13647
|
+
const validity = element[0][VALIDITY_STATE_PROPERTY] || {};
|
|
14764
13648
|
if (validity.badInput || validity.typeMismatch) {
|
|
14765
13649
|
ctrl.$$parserName = parserName;
|
|
14766
13650
|
return undefined;
|
|
@@ -15417,7 +14301,7 @@ function ngValueDirective() {
|
|
|
15417
14301
|
// Support: IE9 only
|
|
15418
14302
|
// In IE9 values are converted to string (e.g. `input.value = null` results in `input.value === 'null'`).
|
|
15419
14303
|
const propValue = isDefined(value) ? value : null;
|
|
15420
|
-
element
|
|
14304
|
+
element[0]["value"] = propValue;
|
|
15421
14305
|
attr.$set("value", value);
|
|
15422
14306
|
}
|
|
15423
14307
|
|
|
@@ -15474,7 +14358,7 @@ const scriptDirective = [
|
|
|
15474
14358
|
const noopNgModelController = { $setViewValue: () => {}, $render: () => {} };
|
|
15475
14359
|
|
|
15476
14360
|
function setOptionSelectedStatus(optionEl, value) {
|
|
15477
|
-
optionEl.
|
|
14361
|
+
optionEl[0].selected = value;
|
|
15478
14362
|
/**
|
|
15479
14363
|
* When unselecting an option, setting the property to null / false should be enough
|
|
15480
14364
|
* However, screenreaders might react to the selected attribute instead, see
|
|
@@ -15741,7 +14625,7 @@ var SelectController = [
|
|
|
15741
14625
|
|
|
15742
14626
|
optionAttrs.$observe("value", (newVal) => {
|
|
15743
14627
|
let removal;
|
|
15744
|
-
const previouslySelected = optionElement.
|
|
14628
|
+
const previouslySelected = optionElement[0].selected;
|
|
15745
14629
|
|
|
15746
14630
|
if (isDefined(hashedVal)) {
|
|
15747
14631
|
self.removeOption(oldVal);
|
|
@@ -15769,7 +14653,7 @@ var SelectController = [
|
|
|
15769
14653
|
self.readValue();
|
|
15770
14654
|
|
|
15771
14655
|
let removal;
|
|
15772
|
-
const previouslySelected = optionElement.
|
|
14656
|
+
const previouslySelected = optionElement[0].selected;
|
|
15773
14657
|
|
|
15774
14658
|
if (isDefined(oldVal)) {
|
|
15775
14659
|
self.removeOption(oldVal);
|
|
@@ -15786,7 +14670,7 @@ var SelectController = [
|
|
|
15786
14670
|
// The text content is interpolated
|
|
15787
14671
|
optionScope.$watch(interpolateTextFn, (newVal, oldVal) => {
|
|
15788
14672
|
optionAttrs.$set("value", newVal);
|
|
15789
|
-
const previouslySelected = optionElement.
|
|
14673
|
+
const previouslySelected = optionElement[0].selected;
|
|
15790
14674
|
if (oldVal !== newVal) {
|
|
15791
14675
|
self.removeOption(oldVal);
|
|
15792
14676
|
}
|
|
@@ -15805,7 +14689,7 @@ var SelectController = [
|
|
|
15805
14689
|
// Since model updates will also select disabled options (like ngOptions),
|
|
15806
14690
|
// we only have to handle options becoming disabled, not enabled
|
|
15807
14691
|
|
|
15808
|
-
if (newVal === "true" || (newVal && optionElement.
|
|
14692
|
+
if (newVal === "true" || (newVal && optionElement[0].selected)) {
|
|
15809
14693
|
if (self.multiple) {
|
|
15810
14694
|
scheduleViewValueUpdate(true);
|
|
15811
14695
|
} else {
|
|
@@ -19093,7 +17977,7 @@ forEach(["src", "srcset", "href"], (attrName) => {
|
|
|
19093
17977
|
|
|
19094
17978
|
if (
|
|
19095
17979
|
attrName === "href" &&
|
|
19096
|
-
toString.call(element.
|
|
17980
|
+
toString.call(element[0].href) === "[object SVGAnimatedString]"
|
|
19097
17981
|
) {
|
|
19098
17982
|
name = "xlinkHref";
|
|
19099
17983
|
attr.$attr[name] = "xlink:href";
|
|
@@ -23541,31 +22425,6 @@ function $$IntervalFactoryProvider() {
|
|
|
23541
22425
|
];
|
|
23542
22426
|
}
|
|
23543
22427
|
|
|
23544
|
-
function $$ForceReflowProvider() {
|
|
23545
|
-
this.$get = [
|
|
23546
|
-
"$document",
|
|
23547
|
-
($document) =>
|
|
23548
|
-
function (domNode) {
|
|
23549
|
-
// the line below will force the browser to perform a repaint so
|
|
23550
|
-
// that all the animated elements within the animation frame will
|
|
23551
|
-
// be properly updated and drawn on screen. This is required to
|
|
23552
|
-
// ensure that the preparation animation is properly flushed so that
|
|
23553
|
-
// the active state picks up from there. DO NOT REMOVE THIS LINE.
|
|
23554
|
-
// DO NOT OPTIMIZE THIS LINE. THE MINIFIER WILL REMOVE IT OTHERWISE WHICH
|
|
23555
|
-
// WILL RESULT IN AN UNPREDICTABLE BUG THAT IS VERY HARD TO TRACK DOWN AND
|
|
23556
|
-
// WILL TAKE YEARS AWAY FROM YOUR LIFE.
|
|
23557
|
-
if (domNode) {
|
|
23558
|
-
if (!domNode.nodeType && domNode instanceof jqLite) {
|
|
23559
|
-
domNode = domNode[0];
|
|
23560
|
-
}
|
|
23561
|
-
} else {
|
|
23562
|
-
domNode = $document[0].body;
|
|
23563
|
-
}
|
|
23564
|
-
return domNode.offsetWidth + 1;
|
|
23565
|
-
},
|
|
23566
|
-
];
|
|
23567
|
-
}
|
|
23568
|
-
|
|
23569
22428
|
const APPLICATION_JSON = "application/json";
|
|
23570
22429
|
const CONTENT_TYPE_APPLICATION_JSON = {
|
|
23571
22430
|
"Content-Type": `${APPLICATION_JSON};charset=utf-8`,
|
|
@@ -26205,7 +25064,7 @@ function $LocationProvider() {
|
|
|
26205
25064
|
if (isString(rewriteLinks) && isUndefined(elm.attr(rewriteLinks)))
|
|
26206
25065
|
return;
|
|
26207
25066
|
|
|
26208
|
-
let absHref = elm.
|
|
25067
|
+
let absHref = elm[0].href;
|
|
26209
25068
|
// get the actual href attribute - see
|
|
26210
25069
|
// http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
|
|
26211
25070
|
const relHref = elm.attr("href") || elm.attr("xlink:href");
|
|
@@ -26350,52 +25209,6 @@ function $LocationProvider() {
|
|
|
26350
25209
|
];
|
|
26351
25210
|
}
|
|
26352
25211
|
|
|
26353
|
-
/**
|
|
26354
|
-
* @ngdoc service
|
|
26355
|
-
* @name $log
|
|
26356
|
-
*
|
|
26357
|
-
* @description
|
|
26358
|
-
* Simple service for logging. Default implementation safely writes the message
|
|
26359
|
-
* into the browser's console (if present).
|
|
26360
|
-
*
|
|
26361
|
-
* The main purpose of this service is to simplify debugging and troubleshooting.
|
|
26362
|
-
*
|
|
26363
|
-
* To reveal the location of the calls to `$log` in the JavaScript console,
|
|
26364
|
-
* you can "blackbox" the AngularJS source in your browser:
|
|
26365
|
-
*
|
|
26366
|
-
* [Mozilla description of blackboxing](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Black_box_a_source).
|
|
26367
|
-
* [Chrome description of blackboxing](https://developer.chrome.com/devtools/docs/blackboxing).
|
|
26368
|
-
*
|
|
26369
|
-
* Note: Not all browsers support blackboxing.
|
|
26370
|
-
*
|
|
26371
|
-
* The default is to log `debug` messages. You can use
|
|
26372
|
-
* {@link ng.$logProvider ng.$logProvider#debugEnabled} to change this.
|
|
26373
|
-
*
|
|
26374
|
-
* @example
|
|
26375
|
-
<example module="logExample" name="log-service">
|
|
26376
|
-
<file name="script.js">
|
|
26377
|
-
angular.module('logExample', [])
|
|
26378
|
-
.controller('LogController', ['$scope', '$log', function($scope, $log) {
|
|
26379
|
-
$scope.$log = $log;
|
|
26380
|
-
$scope.message = 'Hello World!';
|
|
26381
|
-
}]);
|
|
26382
|
-
</file>
|
|
26383
|
-
<file name="index.html">
|
|
26384
|
-
<div ng-controller="LogController">
|
|
26385
|
-
<p>Reload this page with open console, enter text and hit the log button...</p>
|
|
26386
|
-
<label>Message:
|
|
26387
|
-
<input type="text" ng-model="message" /></label>
|
|
26388
|
-
<button ng-click="$log.log(message)">log</button>
|
|
26389
|
-
<button ng-click="$log.warn(message)">warn</button>
|
|
26390
|
-
<button ng-click="$log.info(message)">info</button>
|
|
26391
|
-
<button ng-click="$log.error(message)">error</button>
|
|
26392
|
-
<button ng-click="$log.debug(message)">debug</button>
|
|
26393
|
-
</div>
|
|
26394
|
-
</file>
|
|
26395
|
-
</example>
|
|
26396
|
-
*/
|
|
26397
|
-
|
|
26398
|
-
|
|
26399
25212
|
/**
|
|
26400
25213
|
* @ngdoc provider
|
|
26401
25214
|
* @name $logProvider
|
|
@@ -26404,9 +25217,10 @@ function $LocationProvider() {
|
|
|
26404
25217
|
* @description
|
|
26405
25218
|
* Use the `$logProvider` to configure how the application logs messages
|
|
26406
25219
|
*/
|
|
26407
|
-
|
|
26408
|
-
|
|
26409
|
-
|
|
25220
|
+
class $LogProvider {
|
|
25221
|
+
constructor() {
|
|
25222
|
+
this.debug = true;
|
|
25223
|
+
}
|
|
26410
25224
|
|
|
26411
25225
|
/**
|
|
26412
25226
|
* @ngdoc method
|
|
@@ -26415,15 +25229,15 @@ function $LogProvider() {
|
|
|
26415
25229
|
* @param {boolean=} flag enable or disable debug level messages
|
|
26416
25230
|
* @returns {*} current value if used as getter or itself (chaining) if used as setter
|
|
26417
25231
|
*/
|
|
26418
|
-
|
|
26419
|
-
if (
|
|
26420
|
-
debug = flag;
|
|
25232
|
+
debugEnabled(flag) {
|
|
25233
|
+
if (typeof flag !== "undefined") {
|
|
25234
|
+
this.debug = flag;
|
|
26421
25235
|
return this;
|
|
26422
25236
|
}
|
|
26423
|
-
return debug;
|
|
26424
|
-
}
|
|
25237
|
+
return this.debug;
|
|
25238
|
+
}
|
|
26425
25239
|
|
|
26426
|
-
|
|
25240
|
+
formatError(arg) {
|
|
26427
25241
|
if (isError(arg)) {
|
|
26428
25242
|
if (arg.stack) {
|
|
26429
25243
|
arg =
|
|
@@ -26437,77 +25251,71 @@ function $LogProvider() {
|
|
|
26437
25251
|
return arg;
|
|
26438
25252
|
}
|
|
26439
25253
|
|
|
26440
|
-
|
|
25254
|
+
consoleLog(type) {
|
|
26441
25255
|
const console = window.console || {};
|
|
26442
25256
|
const logFn = console[type] || console.log || (() => {});
|
|
26443
25257
|
|
|
26444
|
-
return
|
|
26445
|
-
|
|
26446
|
-
|
|
26447
|
-
args.push(formatError(arg));
|
|
26448
|
-
});
|
|
26449
|
-
return logFn.apply(console, args);
|
|
25258
|
+
return (...args) => {
|
|
25259
|
+
const formattedArgs = args.map((arg) => this.formatError(arg));
|
|
25260
|
+
return logFn.apply(console, formattedArgs);
|
|
26450
25261
|
};
|
|
26451
25262
|
}
|
|
26452
25263
|
|
|
26453
|
-
|
|
26454
|
-
|
|
26455
|
-
|
|
26456
|
-
|
|
26457
|
-
|
|
26458
|
-
|
|
26459
|
-
|
|
26460
|
-
|
|
26461
|
-
|
|
26462
|
-
|
|
26463
|
-
log: consoleLog("log"),
|
|
26464
|
-
|
|
26465
|
-
/**
|
|
26466
|
-
* @ngdoc method
|
|
26467
|
-
* @name $log#info
|
|
26468
|
-
*
|
|
26469
|
-
* @description
|
|
26470
|
-
* Write an information message
|
|
26471
|
-
*/
|
|
26472
|
-
info: consoleLog("info"),
|
|
25264
|
+
$get() {
|
|
25265
|
+
return {
|
|
25266
|
+
/**
|
|
25267
|
+
* @ngdoc method
|
|
25268
|
+
* @name $log#log
|
|
25269
|
+
*
|
|
25270
|
+
* @description
|
|
25271
|
+
* Write a log message
|
|
25272
|
+
*/
|
|
25273
|
+
log: this.consoleLog("log"),
|
|
26473
25274
|
|
|
26474
|
-
|
|
26475
|
-
|
|
26476
|
-
|
|
26477
|
-
|
|
26478
|
-
|
|
26479
|
-
|
|
26480
|
-
|
|
26481
|
-
|
|
25275
|
+
/**
|
|
25276
|
+
* @ngdoc method
|
|
25277
|
+
* @name $log#info
|
|
25278
|
+
*
|
|
25279
|
+
* @description
|
|
25280
|
+
* Write an information message
|
|
25281
|
+
*/
|
|
25282
|
+
info: this.consoleLog("info"),
|
|
26482
25283
|
|
|
26483
|
-
|
|
26484
|
-
|
|
26485
|
-
|
|
26486
|
-
|
|
26487
|
-
|
|
26488
|
-
|
|
26489
|
-
|
|
26490
|
-
|
|
25284
|
+
/**
|
|
25285
|
+
* @ngdoc method
|
|
25286
|
+
* @name $log#warn
|
|
25287
|
+
*
|
|
25288
|
+
* @description
|
|
25289
|
+
* Write a warning message
|
|
25290
|
+
*/
|
|
25291
|
+
warn: this.consoleLog("warn"),
|
|
26491
25292
|
|
|
26492
|
-
|
|
26493
|
-
|
|
26494
|
-
|
|
26495
|
-
|
|
26496
|
-
|
|
26497
|
-
|
|
26498
|
-
|
|
26499
|
-
|
|
26500
|
-
const fn = consoleLog("debug");
|
|
25293
|
+
/**
|
|
25294
|
+
* @ngdoc method
|
|
25295
|
+
* @name $log#error
|
|
25296
|
+
*
|
|
25297
|
+
* @description
|
|
25298
|
+
* Write an error message
|
|
25299
|
+
*/
|
|
25300
|
+
error: this.consoleLog("error"),
|
|
26501
25301
|
|
|
26502
|
-
|
|
26503
|
-
|
|
26504
|
-
|
|
26505
|
-
|
|
26506
|
-
|
|
26507
|
-
|
|
26508
|
-
|
|
26509
|
-
|
|
26510
|
-
|
|
25302
|
+
/**
|
|
25303
|
+
* @ngdoc method
|
|
25304
|
+
* @name $log#debug
|
|
25305
|
+
*
|
|
25306
|
+
* @description
|
|
25307
|
+
* Write a debug message
|
|
25308
|
+
*/
|
|
25309
|
+
debug: (() => {
|
|
25310
|
+
const fn = this.consoleLog("debug");
|
|
25311
|
+
return (...args) => {
|
|
25312
|
+
if (this.debug) {
|
|
25313
|
+
fn.apply(this, args);
|
|
25314
|
+
}
|
|
25315
|
+
};
|
|
25316
|
+
})(),
|
|
25317
|
+
};
|
|
25318
|
+
}
|
|
26511
25319
|
}
|
|
26512
25320
|
|
|
26513
25321
|
const $parseMinErr = minErr("$parse");
|
|
@@ -31208,501 +30016,498 @@ const $$AnimateChildrenDirective = [
|
|
|
31208
30016
|
},
|
|
31209
30017
|
];
|
|
31210
30018
|
|
|
31211
|
-
|
|
31212
|
-
"
|
|
31213
|
-
function ($animateProvider) {
|
|
31214
|
-
const NG_ANIMATE_REF_ATTR = "ng-animate-ref";
|
|
31215
|
-
|
|
31216
|
-
const drivers = (this.drivers = []);
|
|
30019
|
+
function $$AnimationProvider() {
|
|
30020
|
+
const NG_ANIMATE_REF_ATTR = "ng-animate-ref";
|
|
31217
30021
|
|
|
31218
|
-
|
|
31219
|
-
const PREPARE_CLASSES_KEY = "$$animatePrepareClasses";
|
|
30022
|
+
const drivers = (this.drivers = []);
|
|
31220
30023
|
|
|
31221
|
-
|
|
31222
|
-
|
|
31223
|
-
}
|
|
30024
|
+
const RUNNER_STORAGE_KEY = "$$animationRunner";
|
|
30025
|
+
const PREPARE_CLASSES_KEY = "$$animatePrepareClasses";
|
|
31224
30026
|
|
|
31225
|
-
|
|
31226
|
-
|
|
31227
|
-
|
|
30027
|
+
function setRunner(element, runner) {
|
|
30028
|
+
element.data(RUNNER_STORAGE_KEY, runner);
|
|
30029
|
+
}
|
|
31228
30030
|
|
|
31229
|
-
|
|
31230
|
-
|
|
31231
|
-
|
|
30031
|
+
function removeRunner(element) {
|
|
30032
|
+
element.removeData(RUNNER_STORAGE_KEY);
|
|
30033
|
+
}
|
|
31232
30034
|
|
|
31233
|
-
|
|
31234
|
-
|
|
31235
|
-
|
|
31236
|
-
"$$AnimateRunner",
|
|
31237
|
-
"$$rAFScheduler",
|
|
31238
|
-
"$$animateCache",
|
|
31239
|
-
function (
|
|
31240
|
-
$rootScope,
|
|
31241
|
-
$injector,
|
|
31242
|
-
$$AnimateRunner,
|
|
31243
|
-
$$rAFScheduler,
|
|
31244
|
-
$$animateCache,
|
|
31245
|
-
) {
|
|
31246
|
-
const animationQueue = [];
|
|
31247
|
-
const applyAnimationClasses = applyAnimationClassesFactory();
|
|
30035
|
+
function getRunner(element) {
|
|
30036
|
+
return element.data(RUNNER_STORAGE_KEY);
|
|
30037
|
+
}
|
|
31248
30038
|
|
|
31249
|
-
|
|
31250
|
-
|
|
31251
|
-
|
|
31252
|
-
|
|
30039
|
+
this.$get = [
|
|
30040
|
+
"$rootScope",
|
|
30041
|
+
"$injector",
|
|
30042
|
+
"$$AnimateRunner",
|
|
30043
|
+
"$$rAFScheduler",
|
|
30044
|
+
"$$animateCache",
|
|
30045
|
+
function (
|
|
30046
|
+
$rootScope,
|
|
30047
|
+
$injector,
|
|
30048
|
+
$$AnimateRunner,
|
|
30049
|
+
$$rAFScheduler,
|
|
30050
|
+
$$animateCache,
|
|
30051
|
+
) {
|
|
30052
|
+
const animationQueue = [];
|
|
30053
|
+
const applyAnimationClasses = applyAnimationClassesFactory();
|
|
31253
30054
|
|
|
31254
|
-
|
|
31255
|
-
|
|
31256
|
-
|
|
31257
|
-
|
|
31258
|
-
|
|
31259
|
-
|
|
31260
|
-
|
|
31261
|
-
|
|
31262
|
-
|
|
31263
|
-
|
|
31264
|
-
|
|
31265
|
-
|
|
31266
|
-
|
|
31267
|
-
|
|
31268
|
-
|
|
30055
|
+
function sortAnimations(animations) {
|
|
30056
|
+
const tree = { children: [] };
|
|
30057
|
+
let i;
|
|
30058
|
+
const lookup = new Map();
|
|
30059
|
+
|
|
30060
|
+
// this is done first beforehand so that the map
|
|
30061
|
+
// is filled with a list of the elements that will be animated
|
|
30062
|
+
// eslint-disable-next-line no-plusplus
|
|
30063
|
+
for (i = 0; i < animations.length; i++) {
|
|
30064
|
+
const animation = animations[i];
|
|
30065
|
+
lookup.set(
|
|
30066
|
+
animation.domNode,
|
|
30067
|
+
(animations[i] = {
|
|
30068
|
+
domNode: animation.domNode,
|
|
30069
|
+
element: animation.element,
|
|
30070
|
+
fn: animation.fn,
|
|
30071
|
+
children: [],
|
|
30072
|
+
}),
|
|
30073
|
+
);
|
|
30074
|
+
}
|
|
31269
30075
|
|
|
31270
|
-
|
|
31271
|
-
|
|
31272
|
-
|
|
30076
|
+
for (i = 0; i < animations.length; i++) {
|
|
30077
|
+
processNode(animations[i]);
|
|
30078
|
+
}
|
|
31273
30079
|
|
|
31274
|
-
|
|
30080
|
+
return flatten(tree);
|
|
31275
30081
|
|
|
31276
|
-
|
|
31277
|
-
|
|
31278
|
-
|
|
30082
|
+
function processNode(entry) {
|
|
30083
|
+
if (entry.processed) return entry;
|
|
30084
|
+
entry.processed = true;
|
|
31279
30085
|
|
|
31280
|
-
|
|
31281
|
-
|
|
31282
|
-
|
|
30086
|
+
const elementNode = entry.domNode;
|
|
30087
|
+
let { parentNode } = elementNode;
|
|
30088
|
+
lookup.set(elementNode, entry);
|
|
31283
30089
|
|
|
31284
|
-
|
|
31285
|
-
|
|
31286
|
-
|
|
31287
|
-
|
|
31288
|
-
|
|
31289
|
-
|
|
31290
|
-
}
|
|
31291
|
-
break;
|
|
30090
|
+
let parentEntry;
|
|
30091
|
+
while (parentNode) {
|
|
30092
|
+
parentEntry = lookup.get(parentNode);
|
|
30093
|
+
if (parentEntry) {
|
|
30094
|
+
if (!parentEntry.processed) {
|
|
30095
|
+
parentEntry = processNode(parentEntry);
|
|
31292
30096
|
}
|
|
31293
|
-
|
|
30097
|
+
break;
|
|
31294
30098
|
}
|
|
31295
|
-
|
|
31296
|
-
(parentEntry || tree).children.push(entry);
|
|
31297
|
-
return entry;
|
|
30099
|
+
parentNode = parentNode.parentNode;
|
|
31298
30100
|
}
|
|
31299
30101
|
|
|
31300
|
-
|
|
31301
|
-
|
|
31302
|
-
|
|
31303
|
-
let i;
|
|
30102
|
+
(parentEntry || tree).children.push(entry);
|
|
30103
|
+
return entry;
|
|
30104
|
+
}
|
|
31304
30105
|
|
|
31305
|
-
|
|
31306
|
-
|
|
31307
|
-
|
|
30106
|
+
function flatten(tree) {
|
|
30107
|
+
const result = [];
|
|
30108
|
+
const queue = [];
|
|
30109
|
+
let i;
|
|
31308
30110
|
|
|
31309
|
-
|
|
31310
|
-
|
|
31311
|
-
|
|
31312
|
-
|
|
31313
|
-
for (i = 0; i < queue.length; i++) {
|
|
31314
|
-
const entry = queue[i];
|
|
31315
|
-
if (remainingLevelEntries <= 0) {
|
|
31316
|
-
remainingLevelEntries = nextLevelEntries;
|
|
31317
|
-
nextLevelEntries = 0;
|
|
31318
|
-
result.push(row);
|
|
31319
|
-
row = [];
|
|
31320
|
-
}
|
|
31321
|
-
row.push(entry);
|
|
31322
|
-
entry.children.forEach((childEntry) => {
|
|
31323
|
-
nextLevelEntries++;
|
|
31324
|
-
queue.push(childEntry);
|
|
31325
|
-
});
|
|
31326
|
-
remainingLevelEntries--;
|
|
31327
|
-
}
|
|
30111
|
+
for (i = 0; i < tree.children.length; i++) {
|
|
30112
|
+
queue.push(tree.children[i]);
|
|
30113
|
+
}
|
|
31328
30114
|
|
|
31329
|
-
|
|
30115
|
+
let remainingLevelEntries = queue.length;
|
|
30116
|
+
let nextLevelEntries = 0;
|
|
30117
|
+
let row = [];
|
|
30118
|
+
|
|
30119
|
+
for (i = 0; i < queue.length; i++) {
|
|
30120
|
+
const entry = queue[i];
|
|
30121
|
+
if (remainingLevelEntries <= 0) {
|
|
30122
|
+
remainingLevelEntries = nextLevelEntries;
|
|
30123
|
+
nextLevelEntries = 0;
|
|
31330
30124
|
result.push(row);
|
|
30125
|
+
row = [];
|
|
31331
30126
|
}
|
|
30127
|
+
row.push(entry);
|
|
30128
|
+
entry.children.forEach((childEntry) => {
|
|
30129
|
+
nextLevelEntries++;
|
|
30130
|
+
queue.push(childEntry);
|
|
30131
|
+
});
|
|
30132
|
+
remainingLevelEntries--;
|
|
30133
|
+
}
|
|
31332
30134
|
|
|
31333
|
-
|
|
30135
|
+
if (row.length) {
|
|
30136
|
+
result.push(row);
|
|
31334
30137
|
}
|
|
31335
|
-
}
|
|
31336
30138
|
|
|
31337
|
-
|
|
31338
|
-
|
|
31339
|
-
|
|
31340
|
-
const isStructural = ["enter", "move", "leave"].indexOf(event) >= 0;
|
|
30139
|
+
return result;
|
|
30140
|
+
}
|
|
30141
|
+
}
|
|
31341
30142
|
|
|
31342
|
-
|
|
31343
|
-
|
|
31344
|
-
|
|
31345
|
-
|
|
31346
|
-
const runner = new $$AnimateRunner({
|
|
31347
|
-
end() {
|
|
31348
|
-
close();
|
|
31349
|
-
},
|
|
31350
|
-
cancel() {
|
|
31351
|
-
close(true);
|
|
31352
|
-
},
|
|
31353
|
-
});
|
|
30143
|
+
// TODO(matsko): document the signature in a better way
|
|
30144
|
+
return function (element, event, options) {
|
|
30145
|
+
options = prepareAnimationOptions(options);
|
|
30146
|
+
const isStructural = ["enter", "move", "leave"].indexOf(event) >= 0;
|
|
31354
30147
|
|
|
31355
|
-
|
|
30148
|
+
// there is no animation at the current moment, however
|
|
30149
|
+
// these runner methods will get later updated with the
|
|
30150
|
+
// methods leading into the driver's end/cancel methods
|
|
30151
|
+
// for now they just stop the animation from starting
|
|
30152
|
+
const runner = new $$AnimateRunner({
|
|
30153
|
+
end() {
|
|
31356
30154
|
close();
|
|
31357
|
-
|
|
31358
|
-
|
|
31359
|
-
|
|
31360
|
-
|
|
31361
|
-
|
|
31362
|
-
mergeClasses$1(options.addClass, options.removeClass),
|
|
31363
|
-
);
|
|
31364
|
-
let { tempClasses } = options;
|
|
31365
|
-
if (tempClasses) {
|
|
31366
|
-
classes += ` ${tempClasses}`;
|
|
31367
|
-
options.tempClasses = null;
|
|
31368
|
-
}
|
|
30155
|
+
},
|
|
30156
|
+
cancel() {
|
|
30157
|
+
close(true);
|
|
30158
|
+
},
|
|
30159
|
+
});
|
|
31369
30160
|
|
|
31370
|
-
|
|
31371
|
-
|
|
31372
|
-
|
|
31373
|
-
|
|
31374
|
-
);
|
|
31375
|
-
}
|
|
30161
|
+
if (!drivers.length) {
|
|
30162
|
+
close();
|
|
30163
|
+
return runner;
|
|
30164
|
+
}
|
|
31376
30165
|
|
|
31377
|
-
|
|
30166
|
+
let classes = mergeClasses$1(
|
|
30167
|
+
element.attr("class"),
|
|
30168
|
+
mergeClasses$1(options.addClass, options.removeClass),
|
|
30169
|
+
);
|
|
30170
|
+
let { tempClasses } = options;
|
|
30171
|
+
if (tempClasses) {
|
|
30172
|
+
classes += ` ${tempClasses}`;
|
|
30173
|
+
options.tempClasses = null;
|
|
30174
|
+
}
|
|
31378
30175
|
|
|
31379
|
-
|
|
31380
|
-
|
|
31381
|
-
|
|
31382
|
-
|
|
31383
|
-
|
|
31384
|
-
|
|
31385
|
-
structural: isStructural,
|
|
31386
|
-
options,
|
|
31387
|
-
beforeStart,
|
|
31388
|
-
close,
|
|
31389
|
-
});
|
|
30176
|
+
if (isStructural) {
|
|
30177
|
+
element.data(
|
|
30178
|
+
PREPARE_CLASSES_KEY,
|
|
30179
|
+
`ng-${event}${PREPARE_CLASS_SUFFIX}`,
|
|
30180
|
+
);
|
|
30181
|
+
}
|
|
31390
30182
|
|
|
31391
|
-
|
|
30183
|
+
setRunner(element, runner);
|
|
31392
30184
|
|
|
31393
|
-
|
|
31394
|
-
//
|
|
31395
|
-
//
|
|
31396
|
-
|
|
30185
|
+
animationQueue.push({
|
|
30186
|
+
// this data is used by the postDigest code and passed into
|
|
30187
|
+
// the driver step function
|
|
30188
|
+
element,
|
|
30189
|
+
classes,
|
|
30190
|
+
event,
|
|
30191
|
+
structural: isStructural,
|
|
30192
|
+
options,
|
|
30193
|
+
beforeStart,
|
|
30194
|
+
close,
|
|
30195
|
+
});
|
|
31397
30196
|
|
|
31398
|
-
|
|
31399
|
-
|
|
31400
|
-
|
|
31401
|
-
|
|
31402
|
-
|
|
31403
|
-
|
|
31404
|
-
|
|
31405
|
-
|
|
31406
|
-
|
|
31407
|
-
|
|
31408
|
-
|
|
31409
|
-
|
|
30197
|
+
element.on("$destroy", handleDestroyedElement);
|
|
30198
|
+
|
|
30199
|
+
// we only want there to be one function called within the post digest
|
|
30200
|
+
// block. This way we can group animations for all the animations that
|
|
30201
|
+
// were apart of the same postDigest flush call.
|
|
30202
|
+
if (animationQueue.length > 1) return runner;
|
|
30203
|
+
|
|
30204
|
+
$rootScope.$$postDigest(() => {
|
|
30205
|
+
const animations = [];
|
|
30206
|
+
forEach(animationQueue, (entry) => {
|
|
30207
|
+
// the element was destroyed early on which removed the runner
|
|
30208
|
+
// form its storage. This means we can't animate this element
|
|
30209
|
+
// at all and it already has been closed due to destruction.
|
|
30210
|
+
if (getRunner(entry.element)) {
|
|
30211
|
+
animations.push(entry);
|
|
30212
|
+
} else {
|
|
30213
|
+
entry.close();
|
|
30214
|
+
}
|
|
30215
|
+
});
|
|
31410
30216
|
|
|
31411
|
-
|
|
31412
|
-
|
|
30217
|
+
// now any future animations will be in another postDigest
|
|
30218
|
+
animationQueue.length = 0;
|
|
31413
30219
|
|
|
31414
|
-
|
|
31415
|
-
|
|
30220
|
+
const groupedAnimations = groupAnimations(animations);
|
|
30221
|
+
const toBeSortedAnimations = [];
|
|
31416
30222
|
|
|
31417
|
-
|
|
31418
|
-
|
|
31419
|
-
|
|
31420
|
-
|
|
31421
|
-
|
|
30223
|
+
forEach(groupedAnimations, (animationEntry) => {
|
|
30224
|
+
const element = animationEntry.from
|
|
30225
|
+
? animationEntry.from.element
|
|
30226
|
+
: animationEntry.element;
|
|
30227
|
+
let extraClasses = options.addClass;
|
|
31422
30228
|
|
|
31423
|
-
|
|
31424
|
-
|
|
31425
|
-
|
|
31426
|
-
|
|
31427
|
-
|
|
31428
|
-
|
|
31429
|
-
|
|
31430
|
-
|
|
30229
|
+
extraClasses =
|
|
30230
|
+
(extraClasses ? `${extraClasses} ` : "") + NG_ANIMATE_CLASSNAME;
|
|
30231
|
+
const cacheKey = $$animateCache.cacheKey(
|
|
30232
|
+
element[0],
|
|
30233
|
+
animationEntry.event,
|
|
30234
|
+
extraClasses,
|
|
30235
|
+
options.removeClass,
|
|
30236
|
+
);
|
|
31431
30237
|
|
|
31432
|
-
|
|
31433
|
-
|
|
31434
|
-
|
|
31435
|
-
|
|
31436
|
-
|
|
31437
|
-
|
|
31438
|
-
|
|
31439
|
-
|
|
31440
|
-
|
|
31441
|
-
|
|
31442
|
-
|
|
31443
|
-
|
|
31444
|
-
|
|
31445
|
-
|
|
31446
|
-
|
|
31447
|
-
|
|
31448
|
-
|
|
31449
|
-
|
|
30238
|
+
toBeSortedAnimations.push({
|
|
30239
|
+
element,
|
|
30240
|
+
domNode: getDomNode(element),
|
|
30241
|
+
fn: function triggerAnimationStart() {
|
|
30242
|
+
let startAnimationFn;
|
|
30243
|
+
const closeFn = animationEntry.close;
|
|
30244
|
+
|
|
30245
|
+
// in the event that we've cached the animation status for this element
|
|
30246
|
+
// and it's in fact an invalid animation (something that has duration = 0)
|
|
30247
|
+
// then we should skip all the heavy work from here on
|
|
30248
|
+
if (
|
|
30249
|
+
$$animateCache.containsCachedAnimationWithoutDuration(
|
|
30250
|
+
cacheKey,
|
|
30251
|
+
)
|
|
30252
|
+
) {
|
|
30253
|
+
closeFn();
|
|
30254
|
+
return;
|
|
30255
|
+
}
|
|
31450
30256
|
|
|
31451
|
-
|
|
31452
|
-
|
|
31453
|
-
|
|
31454
|
-
|
|
31455
|
-
|
|
31456
|
-
|
|
31457
|
-
|
|
31458
|
-
|
|
31459
|
-
|
|
31460
|
-
|
|
31461
|
-
|
|
31462
|
-
|
|
31463
|
-
|
|
31464
|
-
|
|
31465
|
-
|
|
31466
|
-
}
|
|
30257
|
+
// it's important that we apply the `ng-animate` CSS class and the
|
|
30258
|
+
// temporary classes before we do any driver invoking since these
|
|
30259
|
+
// CSS classes may be required for proper CSS detection.
|
|
30260
|
+
animationEntry.beforeStart();
|
|
30261
|
+
|
|
30262
|
+
// in the event that the element was removed before the digest runs or
|
|
30263
|
+
// during the RAF sequencing then we should not trigger the animation.
|
|
30264
|
+
const targetElement = animationEntry.anchors
|
|
30265
|
+
? animationEntry.from.element || animationEntry.to.element
|
|
30266
|
+
: animationEntry.element;
|
|
30267
|
+
|
|
30268
|
+
if (getRunner(targetElement)) {
|
|
30269
|
+
const operation = invokeFirstDriver(animationEntry);
|
|
30270
|
+
if (operation) {
|
|
30271
|
+
startAnimationFn = operation.start;
|
|
31467
30272
|
}
|
|
30273
|
+
}
|
|
31468
30274
|
|
|
31469
|
-
|
|
31470
|
-
|
|
31471
|
-
|
|
31472
|
-
|
|
31473
|
-
|
|
31474
|
-
|
|
31475
|
-
|
|
31476
|
-
|
|
31477
|
-
|
|
31478
|
-
|
|
31479
|
-
});
|
|
30275
|
+
if (!startAnimationFn) {
|
|
30276
|
+
closeFn();
|
|
30277
|
+
} else {
|
|
30278
|
+
const animationRunner = startAnimationFn();
|
|
30279
|
+
animationRunner.done((status) => {
|
|
30280
|
+
closeFn(!status);
|
|
30281
|
+
});
|
|
30282
|
+
updateAnimationRunners(animationEntry, animationRunner);
|
|
30283
|
+
}
|
|
30284
|
+
},
|
|
31480
30285
|
});
|
|
30286
|
+
});
|
|
31481
30287
|
|
|
31482
|
-
|
|
31483
|
-
|
|
31484
|
-
|
|
31485
|
-
|
|
31486
|
-
|
|
31487
|
-
|
|
31488
|
-
|
|
31489
|
-
|
|
31490
|
-
|
|
31491
|
-
|
|
31492
|
-
|
|
31493
|
-
|
|
31494
|
-
|
|
31495
|
-
|
|
31496
|
-
|
|
31497
|
-
|
|
31498
|
-
|
|
31499
|
-
|
|
31500
|
-
|
|
31501
|
-
|
|
30288
|
+
// we need to sort each of the animations in order of parent to child
|
|
30289
|
+
// relationships. This ensures that the child classes are applied at the
|
|
30290
|
+
// right time.
|
|
30291
|
+
const finalAnimations = sortAnimations(toBeSortedAnimations);
|
|
30292
|
+
for (let i = 0; i < finalAnimations.length; i++) {
|
|
30293
|
+
const innerArray = finalAnimations[i];
|
|
30294
|
+
for (let j = 0; j < innerArray.length; j++) {
|
|
30295
|
+
const entry = innerArray[j];
|
|
30296
|
+
const { element } = entry;
|
|
30297
|
+
|
|
30298
|
+
// the RAFScheduler code only uses functions
|
|
30299
|
+
finalAnimations[i][j] = entry.fn;
|
|
30300
|
+
|
|
30301
|
+
// the first row of elements shouldn't have a prepare-class added to them
|
|
30302
|
+
// since the elements are at the top of the animation hierarchy and they
|
|
30303
|
+
// will be applied without a RAF having to pass...
|
|
30304
|
+
if (i === 0) {
|
|
30305
|
+
element.removeData(PREPARE_CLASSES_KEY);
|
|
30306
|
+
continue;
|
|
30307
|
+
}
|
|
31502
30308
|
|
|
31503
|
-
|
|
31504
|
-
|
|
31505
|
-
|
|
31506
|
-
}
|
|
30309
|
+
const prepareClassName = element.data(PREPARE_CLASSES_KEY);
|
|
30310
|
+
if (prepareClassName) {
|
|
30311
|
+
element[0].classList.add(prepareClassName);
|
|
31507
30312
|
}
|
|
31508
30313
|
}
|
|
30314
|
+
}
|
|
31509
30315
|
|
|
31510
|
-
|
|
30316
|
+
$$rAFScheduler(finalAnimations);
|
|
30317
|
+
});
|
|
30318
|
+
|
|
30319
|
+
return runner;
|
|
30320
|
+
|
|
30321
|
+
// TODO(matsko): change to reference nodes
|
|
30322
|
+
function getAnchorNodes(node) {
|
|
30323
|
+
const SELECTOR = `[${NG_ANIMATE_REF_ATTR}]`;
|
|
30324
|
+
const items = node.hasAttribute(NG_ANIMATE_REF_ATTR)
|
|
30325
|
+
? [node]
|
|
30326
|
+
: node.querySelectorAll(SELECTOR);
|
|
30327
|
+
const anchors = [];
|
|
30328
|
+
forEach(items, (node) => {
|
|
30329
|
+
const attr = node.getAttribute(NG_ANIMATE_REF_ATTR);
|
|
30330
|
+
if (attr && attr.length) {
|
|
30331
|
+
anchors.push(node);
|
|
30332
|
+
}
|
|
31511
30333
|
});
|
|
30334
|
+
return anchors;
|
|
30335
|
+
}
|
|
30336
|
+
|
|
30337
|
+
function groupAnimations(animations) {
|
|
30338
|
+
const preparedAnimations = [];
|
|
30339
|
+
const refLookup = {};
|
|
30340
|
+
forEach(animations, (animation, index) => {
|
|
30341
|
+
const { element } = animation;
|
|
30342
|
+
const node = getDomNode(element);
|
|
30343
|
+
const { event } = animation;
|
|
30344
|
+
const enterOrMove = ["enter", "move"].indexOf(event) >= 0;
|
|
30345
|
+
const anchorNodes = animation.structural
|
|
30346
|
+
? getAnchorNodes(node)
|
|
30347
|
+
: [];
|
|
31512
30348
|
|
|
31513
|
-
|
|
30349
|
+
if (anchorNodes.length) {
|
|
30350
|
+
const direction = enterOrMove ? "to" : "from";
|
|
31514
30351
|
|
|
31515
|
-
|
|
31516
|
-
|
|
31517
|
-
|
|
31518
|
-
|
|
31519
|
-
|
|
31520
|
-
|
|
31521
|
-
|
|
31522
|
-
|
|
31523
|
-
|
|
31524
|
-
|
|
31525
|
-
|
|
31526
|
-
|
|
31527
|
-
});
|
|
31528
|
-
return anchors;
|
|
31529
|
-
}
|
|
31530
|
-
|
|
31531
|
-
function groupAnimations(animations) {
|
|
31532
|
-
const preparedAnimations = [];
|
|
31533
|
-
const refLookup = {};
|
|
31534
|
-
forEach(animations, (animation, index) => {
|
|
31535
|
-
const { element } = animation;
|
|
31536
|
-
const node = getDomNode(element);
|
|
31537
|
-
const { event } = animation;
|
|
31538
|
-
const enterOrMove = ["enter", "move"].indexOf(event) >= 0;
|
|
31539
|
-
const anchorNodes = animation.structural
|
|
31540
|
-
? getAnchorNodes(node)
|
|
31541
|
-
: [];
|
|
31542
|
-
|
|
31543
|
-
if (anchorNodes.length) {
|
|
31544
|
-
const direction = enterOrMove ? "to" : "from";
|
|
31545
|
-
|
|
31546
|
-
forEach(anchorNodes, (anchor) => {
|
|
31547
|
-
const key = anchor.getAttribute(NG_ANIMATE_REF_ATTR);
|
|
31548
|
-
refLookup[key] = refLookup[key] || {};
|
|
31549
|
-
refLookup[key][direction] = {
|
|
31550
|
-
animationID: index,
|
|
31551
|
-
element: jqLite(anchor),
|
|
31552
|
-
};
|
|
31553
|
-
});
|
|
31554
|
-
} else {
|
|
31555
|
-
preparedAnimations.push(animation);
|
|
31556
|
-
}
|
|
31557
|
-
});
|
|
30352
|
+
forEach(anchorNodes, (anchor) => {
|
|
30353
|
+
const key = anchor.getAttribute(NG_ANIMATE_REF_ATTR);
|
|
30354
|
+
refLookup[key] = refLookup[key] || {};
|
|
30355
|
+
refLookup[key][direction] = {
|
|
30356
|
+
animationID: index,
|
|
30357
|
+
element: jqLite(anchor),
|
|
30358
|
+
};
|
|
30359
|
+
});
|
|
30360
|
+
} else {
|
|
30361
|
+
preparedAnimations.push(animation);
|
|
30362
|
+
}
|
|
30363
|
+
});
|
|
31558
30364
|
|
|
31559
|
-
|
|
31560
|
-
|
|
31561
|
-
|
|
31562
|
-
|
|
31563
|
-
|
|
31564
|
-
|
|
31565
|
-
|
|
31566
|
-
|
|
31567
|
-
|
|
31568
|
-
|
|
31569
|
-
|
|
31570
|
-
|
|
31571
|
-
|
|
31572
|
-
|
|
31573
|
-
}
|
|
31574
|
-
return;
|
|
30365
|
+
const usedIndicesLookup = {};
|
|
30366
|
+
const anchorGroups = {};
|
|
30367
|
+
Object.values(refLookup).forEach((operations) => {
|
|
30368
|
+
const { from } = operations;
|
|
30369
|
+
const { to } = operations;
|
|
30370
|
+
|
|
30371
|
+
if (!from || !to) {
|
|
30372
|
+
// only one of these is set therefore we can't have an
|
|
30373
|
+
// anchor animation since all three pieces are required
|
|
30374
|
+
const index = from ? from.animationID : to.animationID;
|
|
30375
|
+
const indexKey = index.toString();
|
|
30376
|
+
if (!usedIndicesLookup[indexKey]) {
|
|
30377
|
+
usedIndicesLookup[indexKey] = true;
|
|
30378
|
+
preparedAnimations.push(animations[index]);
|
|
31575
30379
|
}
|
|
30380
|
+
return;
|
|
30381
|
+
}
|
|
31576
30382
|
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
|
|
31581
|
-
|
|
31582
|
-
|
|
31583
|
-
|
|
31584
|
-
|
|
31585
|
-
|
|
31586
|
-
|
|
31587
|
-
|
|
31588
|
-
|
|
31589
|
-
|
|
31590
|
-
|
|
31591
|
-
|
|
31592
|
-
|
|
31593
|
-
|
|
31594
|
-
|
|
31595
|
-
|
|
31596
|
-
|
|
31597
|
-
|
|
31598
|
-
|
|
30383
|
+
const fromAnimation = animations[from.animationID];
|
|
30384
|
+
const toAnimation = animations[to.animationID];
|
|
30385
|
+
const lookupKey = from.animationID.toString();
|
|
30386
|
+
if (!anchorGroups[lookupKey]) {
|
|
30387
|
+
const group = (anchorGroups[lookupKey] = {
|
|
30388
|
+
structural: true,
|
|
30389
|
+
beforeStart() {
|
|
30390
|
+
fromAnimation.beforeStart();
|
|
30391
|
+
toAnimation.beforeStart();
|
|
30392
|
+
},
|
|
30393
|
+
close() {
|
|
30394
|
+
fromAnimation.close();
|
|
30395
|
+
toAnimation.close();
|
|
30396
|
+
},
|
|
30397
|
+
classes: cssClassesIntersection(
|
|
30398
|
+
fromAnimation.classes,
|
|
30399
|
+
toAnimation.classes,
|
|
30400
|
+
),
|
|
30401
|
+
from: fromAnimation,
|
|
30402
|
+
to: toAnimation,
|
|
30403
|
+
anchors: [], // TODO(matsko): change to reference nodes
|
|
30404
|
+
});
|
|
31599
30405
|
|
|
31600
|
-
|
|
31601
|
-
|
|
31602
|
-
|
|
31603
|
-
|
|
31604
|
-
|
|
31605
|
-
|
|
31606
|
-
|
|
31607
|
-
|
|
31608
|
-
}
|
|
30406
|
+
// the anchor animations require that the from and to elements both have at least
|
|
30407
|
+
// one shared CSS class which effectively marries the two elements together to use
|
|
30408
|
+
// the same animation driver and to properly sequence the anchor animation.
|
|
30409
|
+
if (group.classes.length) {
|
|
30410
|
+
preparedAnimations.push(group);
|
|
30411
|
+
} else {
|
|
30412
|
+
preparedAnimations.push(fromAnimation);
|
|
30413
|
+
preparedAnimations.push(toAnimation);
|
|
31609
30414
|
}
|
|
30415
|
+
}
|
|
31610
30416
|
|
|
31611
|
-
|
|
31612
|
-
|
|
31613
|
-
|
|
31614
|
-
});
|
|
30417
|
+
anchorGroups[lookupKey].anchors.push({
|
|
30418
|
+
out: from.element,
|
|
30419
|
+
in: to.element,
|
|
31615
30420
|
});
|
|
30421
|
+
});
|
|
31616
30422
|
|
|
31617
|
-
|
|
31618
|
-
|
|
30423
|
+
return preparedAnimations;
|
|
30424
|
+
}
|
|
31619
30425
|
|
|
31620
|
-
|
|
31621
|
-
|
|
31622
|
-
|
|
31623
|
-
|
|
30426
|
+
function cssClassesIntersection(a, b) {
|
|
30427
|
+
a = a.split(" ");
|
|
30428
|
+
b = b.split(" ");
|
|
30429
|
+
const matches = [];
|
|
31624
30430
|
|
|
31625
|
-
|
|
31626
|
-
|
|
31627
|
-
|
|
30431
|
+
for (let i = 0; i < a.length; i++) {
|
|
30432
|
+
const aa = a[i];
|
|
30433
|
+
if (aa.substring(0, 3) === "ng-") continue;
|
|
31628
30434
|
|
|
31629
|
-
|
|
31630
|
-
|
|
31631
|
-
|
|
31632
|
-
|
|
31633
|
-
}
|
|
30435
|
+
for (let j = 0; j < b.length; j++) {
|
|
30436
|
+
if (aa === b[j]) {
|
|
30437
|
+
matches.push(aa);
|
|
30438
|
+
break;
|
|
31634
30439
|
}
|
|
31635
30440
|
}
|
|
31636
|
-
|
|
31637
|
-
return matches.join(" ");
|
|
31638
30441
|
}
|
|
31639
30442
|
|
|
31640
|
-
|
|
31641
|
-
|
|
31642
|
-
// may attempt more elements, but custom drivers are more particular
|
|
31643
|
-
for (let i = drivers.length - 1; i >= 0; i--) {
|
|
31644
|
-
const driverName = drivers[i];
|
|
31645
|
-
const factory = $injector.get(driverName);
|
|
31646
|
-
const driver = factory(animationDetails);
|
|
31647
|
-
if (driver) {
|
|
31648
|
-
return driver;
|
|
31649
|
-
}
|
|
31650
|
-
}
|
|
31651
|
-
}
|
|
30443
|
+
return matches.join(" ");
|
|
30444
|
+
}
|
|
31652
30445
|
|
|
31653
|
-
|
|
31654
|
-
|
|
31655
|
-
|
|
31656
|
-
|
|
31657
|
-
|
|
31658
|
-
|
|
31659
|
-
|
|
31660
|
-
|
|
30446
|
+
function invokeFirstDriver(animationDetails) {
|
|
30447
|
+
// we loop in reverse order since the more general drivers (like CSS and JS)
|
|
30448
|
+
// may attempt more elements, but custom drivers are more particular
|
|
30449
|
+
for (let i = drivers.length - 1; i >= 0; i--) {
|
|
30450
|
+
const driverName = drivers[i];
|
|
30451
|
+
const factory = $injector.get(driverName);
|
|
30452
|
+
const driver = factory(animationDetails);
|
|
30453
|
+
if (driver) {
|
|
30454
|
+
return driver;
|
|
31661
30455
|
}
|
|
31662
30456
|
}
|
|
30457
|
+
}
|
|
31663
30458
|
|
|
31664
|
-
|
|
31665
|
-
|
|
31666
|
-
|
|
31667
|
-
|
|
31668
|
-
|
|
31669
|
-
|
|
31670
|
-
|
|
30459
|
+
function beforeStart() {
|
|
30460
|
+
tempClasses =
|
|
30461
|
+
(tempClasses ? `${tempClasses} ` : "") + NG_ANIMATE_CLASSNAME;
|
|
30462
|
+
element.className += ` ${tempClasses}`;
|
|
30463
|
+
let prepareClassName = element.data(PREPARE_CLASSES_KEY);
|
|
30464
|
+
if (prepareClassName) {
|
|
30465
|
+
element[0].classList.remove(prepareClassName);
|
|
30466
|
+
prepareClassName = null;
|
|
30467
|
+
}
|
|
30468
|
+
}
|
|
31671
30469
|
|
|
31672
|
-
|
|
31673
|
-
|
|
31674
|
-
|
|
31675
|
-
|
|
30470
|
+
function updateAnimationRunners(animation, newRunner) {
|
|
30471
|
+
if (animation.from && animation.to) {
|
|
30472
|
+
update(animation.from.element);
|
|
30473
|
+
update(animation.to.element);
|
|
30474
|
+
} else {
|
|
30475
|
+
update(animation.element);
|
|
31676
30476
|
}
|
|
31677
30477
|
|
|
31678
|
-
function
|
|
30478
|
+
function update(element) {
|
|
31679
30479
|
const runner = getRunner(element);
|
|
31680
|
-
if (runner
|
|
31681
|
-
runner.end();
|
|
31682
|
-
}
|
|
30480
|
+
if (runner) runner.setHost(newRunner);
|
|
31683
30481
|
}
|
|
30482
|
+
}
|
|
31684
30483
|
|
|
31685
|
-
|
|
31686
|
-
|
|
31687
|
-
|
|
30484
|
+
function handleDestroyedElement() {
|
|
30485
|
+
const runner = getRunner(element);
|
|
30486
|
+
if (runner && (event !== "leave" || !options.$$domOperationFired)) {
|
|
30487
|
+
runner.end();
|
|
30488
|
+
}
|
|
30489
|
+
}
|
|
31688
30490
|
|
|
31689
|
-
|
|
31690
|
-
|
|
31691
|
-
|
|
30491
|
+
function close(rejected) {
|
|
30492
|
+
element.off("$destroy", handleDestroyedElement);
|
|
30493
|
+
removeRunner(element);
|
|
31692
30494
|
|
|
31693
|
-
|
|
31694
|
-
|
|
31695
|
-
|
|
31696
|
-
.forEach((cls) => element[0].classList.remove(cls));
|
|
31697
|
-
}
|
|
30495
|
+
applyAnimationClasses(element, options);
|
|
30496
|
+
applyAnimationStyles(element, options);
|
|
30497
|
+
options.domOperation();
|
|
31698
30498
|
|
|
31699
|
-
|
|
30499
|
+
if (tempClasses) {
|
|
30500
|
+
tempClasses
|
|
30501
|
+
.split(" ")
|
|
30502
|
+
.forEach((cls) => element[0].classList.remove(cls));
|
|
31700
30503
|
}
|
|
31701
|
-
|
|
31702
|
-
|
|
31703
|
-
|
|
31704
|
-
|
|
31705
|
-
|
|
30504
|
+
|
|
30505
|
+
runner.complete(!rejected);
|
|
30506
|
+
}
|
|
30507
|
+
};
|
|
30508
|
+
},
|
|
30509
|
+
];
|
|
30510
|
+
}
|
|
31706
30511
|
|
|
31707
30512
|
const $$rAFSchedulerFactory = [
|
|
31708
30513
|
() => {
|
|
@@ -33069,14 +31874,12 @@ const $AnimateCssProvider = [
|
|
|
33069
31874
|
"$$AnimateRunner",
|
|
33070
31875
|
"$timeout",
|
|
33071
31876
|
"$$animateCache",
|
|
33072
|
-
"$$forceReflow",
|
|
33073
31877
|
"$$rAFScheduler",
|
|
33074
31878
|
"$$animateQueue",
|
|
33075
31879
|
function (
|
|
33076
31880
|
$$AnimateRunner,
|
|
33077
31881
|
$timeout,
|
|
33078
31882
|
$$animateCache,
|
|
33079
|
-
$$forceReflow,
|
|
33080
31883
|
$$rAFScheduler,
|
|
33081
31884
|
$$animateQueue,
|
|
33082
31885
|
) {
|
|
@@ -33159,8 +31962,16 @@ const $AnimateCssProvider = [
|
|
|
33159
31962
|
$$animateCache.flush();
|
|
33160
31963
|
|
|
33161
31964
|
// DO NOT REMOVE THIS LINE OR REFACTOR OUT THE `pageWidth` variable.
|
|
33162
|
-
//
|
|
33163
|
-
|
|
31965
|
+
// the line below will force the browser to perform a repaint so
|
|
31966
|
+
// that all the animated elements within the animation frame will
|
|
31967
|
+
// be properly updated and drawn on screen. This is required to
|
|
31968
|
+
// ensure that the preparation animation is properly flushed so that
|
|
31969
|
+
// the active state picks up from there. DO NOT REMOVE THIS LINE.
|
|
31970
|
+
// DO NOT OPTIMIZE THIS LINE. THE MINIFIER WILL REMOVE IT OTHERWISE WHICH
|
|
31971
|
+
// WILL RESULT IN AN UNPREDICTABLE BUG THAT IS VERY HARD TO TRACK DOWN AND
|
|
31972
|
+
// WILL TAKE YEARS AWAY FROM YOUR LIFE.
|
|
31973
|
+
|
|
31974
|
+
const pageWidth = document.body.offsetWidth + 1;
|
|
33164
31975
|
|
|
33165
31976
|
// we use a for loop to ensure that if the queue is changed
|
|
33166
31977
|
// during this looping then it will consider new requests
|
|
@@ -36797,7 +35608,6 @@ function publishExternalAPI() {
|
|
|
36797
35608
|
$$isDocumentHidden: $$IsDocumentHiddenProvider,
|
|
36798
35609
|
$exceptionHandler: $ExceptionHandlerProvider,
|
|
36799
35610
|
$filter: $FilterProvider,
|
|
36800
|
-
$$forceReflow: $$ForceReflowProvider,
|
|
36801
35611
|
$interpolate: $InterpolateProvider,
|
|
36802
35612
|
$interval: $IntervalProvider,
|
|
36803
35613
|
$$intervalFactory: $$IntervalFactoryProvider,
|