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