Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f61145475 | |||
| 8c618d896b | |||
| 68d4dc5b71 | |||
| 03a4a96cf9 | |||
| 655c52a621 | |||
| fa3ddba5f2 | |||
| c4a1b6124e | |||
| e52d731bfd | |||
| 9b72843018 | |||
| 9c1f8ea70b | |||
| 9fde5648e4 | |||
| ea829620b2 | |||
| 1731d091f8 | |||
| 9d3704ca46 | |||
| 215dff34dd | |||
| fa8c399fad | |||
| 7295c60ffb | |||
| fa01571036 | |||
| dbc698517f | |||
| a7f3761eda | |||
| 5a98e806ef | |||
| 808f984ec0 | |||
| 698af191de | |||
| 7a413df5e4 | |||
| 4994acd26e | |||
| 4dd10fd964 | |||
| 26119c09d1 | |||
| 927ebd9986 | |||
| f5536ab43c | |||
| 9e6a9b9922 | |||
| bfa66a90c2 | |||
| cdd1227a30 | |||
| 19ecdb54bf | |||
| 30aa3eff4c | |||
| 8d39bd8abf | |||
| 472d076cca | |||
| 1ae0be13c2 | |||
| 159efdd429 | |||
| 4755a35b7d | |||
| b2f8b0b875 | |||
| 24cd70058d | |||
| e46ab43422 | |||
| 8a62a8c7f0 | |||
| b6c2f8b854 | |||
| 00ee090f4f | |||
| 544001f5a3 | |||
| 7175d0d0e3 | |||
| 010d9b6853 | |||
| 122ab074ca | |||
| e22bf9ac78 | |||
| 324cb6b358 | |||
| 80a2176e20 | |||
| 681affef59 | |||
| 0ca8b1df20 | |||
| 20fb626b78 | |||
| 7ea2c7f36e | |||
| 912cbdd468 | |||
| 0202663e93 | |||
| 159bbf11ac | |||
| 9d2cc8341c | |||
| 38520a1a73 | |||
| 470eb37d29 | |||
| 4baf25b3ce | |||
| eb193686a5 | |||
| 4bebe7830b | |||
| 146cbf7eaa | |||
| b8e356191f | |||
| f48244ce5e | |||
| ebba426c0c | |||
| aa11dfc162 | |||
| c6110e8b08 | |||
| 290b5049c2 | |||
| f8a07dd9fe | |||
| 6f39f10827 | |||
| c3a654b7c8 | |||
| e7293daf2a | |||
| c71d414a95 | |||
| 06d4e18cda | |||
| 966e01cf26 | |||
| 67afd9dc63 | |||
| 4175860af1 | |||
| 6fb90bda9a | |||
| 770dd2dcfd | |||
| 0ff7bba2e3 | |||
| 82b0929e4e | |||
| 7d2c6eeef8 | |||
| 6d8c1950a0 | |||
| 1a5ea22079 | |||
| 4f9eb2c6e4 | |||
| 43769fb676 | |||
| 170cd96646 |
+2
-1
@@ -48,7 +48,7 @@ install:
|
||||
- npm config set loglevel http
|
||||
- npm install -g npm@2.5
|
||||
# Instal npm dependecies and ensure that npm cache is not stale
|
||||
- scripts/npm/install-dependencies.sh
|
||||
- npm install
|
||||
|
||||
before_script:
|
||||
- mkdir -p $LOGS_DIR
|
||||
@@ -61,6 +61,7 @@ script:
|
||||
- ./scripts/travis/build.sh
|
||||
|
||||
after_script:
|
||||
- ./scripts/travis/tear_down_browser_provider.sh
|
||||
- ./scripts/travis/print_logs.sh
|
||||
|
||||
notifications:
|
||||
|
||||
+258
@@ -1,3 +1,229 @@
|
||||
<a name="1.4.7"></a>
|
||||
# 1.4.7 dark-luminescence (2015-09-29)
|
||||
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **$compile:** use createMap() for $$observe listeners when initialized from attr interpolation
|
||||
([5a98e806](https://github.com/angular/angular.js/commit/5a98e806ef3c59916bb4668268125610b11effe8),
|
||||
[#10446](https://github.com/angular/angular.js/issues/10446))
|
||||
- **$parse:**
|
||||
- block assigning to fields of a constructor
|
||||
([a7f3761e](https://github.com/angular/angular.js/commit/a7f3761eda5309f76b73c6fb1d3173a270112899),
|
||||
[#12860](https://github.com/angular/angular.js/issues/12860))
|
||||
- do not convert to string computed properties multiple times
|
||||
([698af191](https://github.com/angular/angular.js/commit/698af191ded2465ca4e0f97959b75fede5a531ab))
|
||||
- **filters:** ensure `formatNumber` observes i18n decimal separators
|
||||
([4994acd2](https://github.com/angular/angular.js/commit/4994acd26e582eec8a92b139bfc09ca79a9b8835),
|
||||
[#10342](https://github.com/angular/angular.js/issues/10342), [#12850](https://github.com/angular/angular.js/issues/12850))
|
||||
- **jqLite:** properly handle dash-delimited node names in `jqLiteBuildFragment`
|
||||
([cdd1227a](https://github.com/angular/angular.js/commit/cdd1227a308edd34d31b67f338083b6e0c4c0db9),
|
||||
[#10617](https://github.com/angular/angular.js/issues/10617), [#12759](https://github.com/angular/angular.js/issues/12759))
|
||||
- **ngAnimate:**
|
||||
- ensure anchoring uses body as a container when needed
|
||||
([9d3704ca](https://github.com/angular/angular.js/commit/9d3704ca467081f16b71b011eb50c53d5cdb2f34),
|
||||
[#12872](https://github.com/angular/angular.js/issues/12872))
|
||||
- callback detection should only use RAF when necessary
|
||||
([fa8c399f](https://github.com/angular/angular.js/commit/fa8c399fadc30b78710868fe59d2930fdc17c7a5))
|
||||
- **ngMessages:** prevent race condition with ngAnimate
|
||||
([7295c60f](https://github.com/angular/angular.js/commit/7295c60ffb9f2e4f32043c538ace740b187f565a),
|
||||
[#12856](https://github.com/angular/angular.js/issues/12856), [#12903](https://github.com/angular/angular.js/issues/12903))
|
||||
- **ngOptions:**
|
||||
- skip comments when looking for option elements
|
||||
([68d4dc5b](https://github.com/angular/angular.js/commit/68d4dc5b71b23e4c7c2650e6da3d7200de99f1ae),
|
||||
[#12190](https://github.com/angular/angular.js/issues/12190))
|
||||
- prevent frozen select ui in IE
|
||||
([dbc69851](https://github.com/angular/angular.js/commit/dbc698517ff620b3a6279f65d4a9b6e3c15087b9),
|
||||
[#11314](https://github.com/angular/angular.js/issues/11314), [#11795](https://github.com/angular/angular.js/issues/11795))
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- **$animateCss:** add support for temporary styles via `cleanupStyles`
|
||||
([e52d731b](https://github.com/angular/angular.js/commit/e52d731bfd1fbb6c616125fbde2fb365722254b7),
|
||||
[#12930](https://github.com/angular/angular.js/issues/12930))
|
||||
- **$http:** add `$xhrFactory` service to enable creation of custom xhr objects
|
||||
([7a413df5](https://github.com/angular/angular.js/commit/7a413df5e47e04e20a1c93d35922050bbcbfb492),
|
||||
[#2318](https://github.com/angular/angular.js/issues/2318), [#9319](https://github.com/angular/angular.js/issues/9319), [#12159](https://github.com/angular/angular.js/issues/12159))
|
||||
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
|
||||
<a name="1.4.6"></a>
|
||||
# 1.4.6 multiplicative-elevation (2015-09-17)
|
||||
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **$animate:** invalid CSS class names should not break subsequent elements
|
||||
([c3a654b7](https://github.com/angular/angular.js/commit/c3a654b7c8e585b8fb9f90ece10ef54d19fd74c8),
|
||||
[#12674](https://github.com/angular/angular.js/issues/12674), [#12725](https://github.com/angular/angular.js/issues/12725))
|
||||
- **$browser:** handle async updates to location
|
||||
([8d39bd8a](https://github.com/angular/angular.js/commit/8d39bd8abf423517b5bff70137c2a29e32bff76d),
|
||||
[#12241](https://github.com/angular/angular.js/issues/12241), [#12819](https://github.com/angular/angular.js/issues/12819))
|
||||
- **$http:** propagate status -1 for timed out requests
|
||||
([38520a1a](https://github.com/angular/angular.js/commit/38520a1a73fffb6cfeffc7edfcab5be33e1619eb),
|
||||
[#4491](https://github.com/angular/angular.js/issues/4491), [#8756](https://github.com/angular/angular.js/issues/8756))
|
||||
- **$httpBackend:** send `null` when post-data is undefined
|
||||
([6f39f108](https://github.com/angular/angular.js/commit/6f39f1082773921e79b48a78aa6cd8a7d1921da7),
|
||||
[#12141](https://github.com/angular/angular.js/issues/12141), [#12739](https://github.com/angular/angular.js/issues/12739))
|
||||
- **$parse:**
|
||||
- throw error when accessing a restricted property indirectly
|
||||
([b2f8b0b8](https://github.com/angular/angular.js/commit/b2f8b0b875dbabf7bba0ba6e9bd553c7a8b910d0),
|
||||
[#12833](https://github.com/angular/angular.js/issues/12833))
|
||||
- `assign` returns the new value
|
||||
([7d2c6eee](https://github.com/angular/angular.js/commit/7d2c6eeef8ad61690737b6298c94f066082eff58),
|
||||
[#12675](https://github.com/angular/angular.js/issues/12675), [#12708](https://github.com/angular/angular.js/issues/12708))
|
||||
- **angular.copy:** support copying XML nodes
|
||||
([122ab074](https://github.com/angular/angular.js/commit/122ab074cac6401ecded51fa031af139360f40aa),
|
||||
[#5429](https://github.com/angular/angular.js/issues/5429), [#12786](https://github.com/angular/angular.js/issues/12786))
|
||||
- **form, ngModel:** correctly notify parent form when children are added
|
||||
([c6110e8b](https://github.com/angular/angular.js/commit/c6110e8b08c7e9bb2b7da5ecc5c42d1a834ea92d))
|
||||
- **input:** ignore min/max if they are empty on all input types
|
||||
([544001f5](https://github.com/angular/angular.js/commit/544001f5a331de06961c0201d69ecc92893abd0b),
|
||||
[#12363](https://github.com/angular/angular.js/issues/12363), [#12785](https://github.com/angular/angular.js/issues/12785))
|
||||
- **ngAnimateMock:** $animate.flush should work for looping animations
|
||||
([472d076c](https://github.com/angular/angular.js/commit/472d076cca2ffb99bd87d3c026ef69afc713268d))
|
||||
- **ngAria:** clean up tabindex usage
|
||||
([f48244ce](https://github.com/angular/angular.js/commit/f48244ce5e6d11637aab97af1aff3430bda12429),
|
||||
[#11500](https://github.com/angular/angular.js/issues/11500))
|
||||
- **ngJq:** properly detect when `ng-jq` is empty
|
||||
([19ecdb54](https://github.com/angular/angular.js/commit/19ecdb54bf85fc4e7bd3cde453aa6843f869a1ab),
|
||||
[#12741](https://github.com/angular/angular.js/issues/12741))
|
||||
- **ngModel:**
|
||||
- remove reference to parentForm from removed control
|
||||
([290b5049](https://github.com/angular/angular.js/commit/290b5049c2de4aa0d6ba8eea624bc6dce027b197),
|
||||
[#12263](https://github.com/angular/angular.js/issues/12263))
|
||||
- let aliased validator directives work on any element
|
||||
([43769fb6](https://github.com/angular/angular.js/commit/43769fb676ae904852582a2c88a5523f0b9f58fc),
|
||||
[#12158](https://github.com/angular/angular.js/issues/12158), [#12658](https://github.com/angular/angular.js/issues/12658))
|
||||
- **ngRepeat:** add support to iterate an object's properties even if it does not inherit from Object
|
||||
([7ea2c7f3](https://github.com/angular/angular.js/commit/7ea2c7f36ef854391df3f6b127ad42a2d5cbf1a3),
|
||||
[#9964](https://github.com/angular/angular.js/issues/9964))
|
||||
- **rootScope:** add support for watchCollection to watch an object which does not inherit from Object
|
||||
([20fb626b](https://github.com/angular/angular.js/commit/20fb626b78ed8fbd02f59f5b26df9387a2a6ea0e),
|
||||
[#9964](https://github.com/angular/angular.js/issues/9964))
|
||||
- **select:** update option if interpolated value attribute changes
|
||||
([82b0929e](https://github.com/angular/angular.js/commit/82b0929e4ea0ae087f766f2ee26f9570c8a3c8ac),
|
||||
[#12005](https://github.com/angular/angular.js/issues/12005), [#12582](https://github.com/angular/angular.js/issues/12582))
|
||||
- **toDebugString:** change replacement string
|
||||
([0ca8b1df](https://github.com/angular/angular.js/commit/0ca8b1df201044019596db7173d784aeebdea0a7),
|
||||
[#10103](https://github.com/angular/angular.js/issues/10103))
|
||||
|
||||
|
||||
## Performance Improvements
|
||||
|
||||
- **Angular:** only create new collection in getBlockNodes if the block has changed
|
||||
([0202663e](https://github.com/angular/angular.js/commit/0202663e938a477cd86145bb158bf7a02efd8fb5),
|
||||
[#9899](https://github.com/angular/angular.js/issues/9899))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.3.19"></a>
|
||||
# 1.3.19 glutinous-shriek (2015-09-15)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **$http:** propagate status -1 for timed out requests
|
||||
([f13055a0](https://github.com/angular/angular.js/commit/f13055a0a53a39b160448713a5617edee6042801),
|
||||
[#4491](https://github.com/angular/angular.js/issues/4491), [#8756](https://github.com/angular/angular.js/issues/8756))
|
||||
- **$location:** don't crash if navigating outside the app base
|
||||
([623ce1ad](https://github.com/angular/angular.js/commit/623ce1ad2cf68024719c5cae5d682d00195df30c),
|
||||
[#11667](https://github.com/angular/angular.js/issues/11667))
|
||||
- **$parse:** throw error when accessing a restricted property indirectly
|
||||
([ec98c94c](https://github.com/angular/angular.js/commit/ec98c94ccbfc97b655447956738d5f6ff98b2f33),
|
||||
[#12833](https://github.com/angular/angular.js/issues/12833))
|
||||
- **ngModel:** validate pattern against the viewValue
|
||||
([274e9353](https://github.com/angular/angular.js/commit/274e93537ed4e95aefeacea48909eb334894f0ac),
|
||||
[#12344](https://github.com/angular/angular.js/issues/12344))
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- **ngAnimate:** introduce `$animate.flush` for unit testing
|
||||
([f98e0384](https://github.com/angular/angular.js/commit/f98e038418f7367b2373adcf4887f64a8e8bdcb0))
|
||||
|
||||
|
||||
## Possible Breaking Changes
|
||||
|
||||
- **ngModel:** due to [274e9353](https://github.com/angular/angular.js/commit/274e93537ed4e95aefeacea48909eb334894f0ac),
|
||||
|
||||
|
||||
The `ngPattern` and `pattern` directives will validate the regex
|
||||
against the `viewValue` of `ngModel`, i.e. the value of the model
|
||||
before the $parsers are applied. Previously, the modelValue
|
||||
(the result of the $parsers) was validated.
|
||||
|
||||
This fixes issues where `input[date]` and `input[number]` cannot
|
||||
be validated because the viewValue string is parsed into
|
||||
`Date` and `Number` respectively (starting with Angular 1.3).
|
||||
It also brings the directives in line with HTML5 constraint
|
||||
validation, which validates against the input value.
|
||||
|
||||
This change is unlikely to cause applications to fail, because even
|
||||
in Angular 1.2, the value that was validated by pattern could have
|
||||
been manipulated by the $parsers, as all validation was done
|
||||
inside this pipeline.
|
||||
|
||||
If you rely on the pattern being validated against the modelValue,
|
||||
you must create your own validator directive that overwrites
|
||||
the built-in pattern validator:
|
||||
|
||||
```
|
||||
.directive('patternModelOverwrite', function patternModelOverwriteDirective() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: '?ngModel',
|
||||
priority: 1,
|
||||
compile: function() {
|
||||
var regexp, patternExp;
|
||||
|
||||
return {
|
||||
pre: function(scope, elm, attr, ctrl) {
|
||||
if (!ctrl) return;
|
||||
|
||||
attr.$observe('pattern', function(regex) {
|
||||
/**
|
||||
* The built-in directive will call our overwritten validator
|
||||
* (see below). We just need to update the regex.
|
||||
* The preLink fn guaranetees our observer is called first.
|
||||
*/
|
||||
if (isString(regex) && regex.length > 0) {
|
||||
regex = new RegExp('^' + regex + '$');
|
||||
}
|
||||
|
||||
if (regex && !regex.test) {
|
||||
//The built-in validator will throw at this point
|
||||
return;
|
||||
}
|
||||
|
||||
regexp = regex || undefined;
|
||||
});
|
||||
|
||||
},
|
||||
post: function(scope, elm, attr, ctrl) {
|
||||
if (!ctrl) return;
|
||||
|
||||
regexp, patternExp = attr.ngPattern || attr.pattern;
|
||||
|
||||
//The postLink fn guarantees we overwrite the built-in pattern validator
|
||||
ctrl.$validators.pattern = function(value) {
|
||||
return ctrl.$isEmpty(value) ||
|
||||
isUndefined(regexp) ||
|
||||
regexp.test(value);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.4.5"></a>
|
||||
# 1.4.5 permanent-internship (2015-08-28)
|
||||
|
||||
@@ -257,6 +483,38 @@ and/or `beforeRemoveClass` then the CSS classes will not be applied
|
||||
in time for the children (and the parent class-based animation will not
|
||||
be cancelled by any child animations).
|
||||
|
||||
- **$q** due to [6838c979](https://github.com/angular/angular.js/commit/6838c979451c109d959a15035177ccee715ccf19),
|
||||
When writing tests, there is no need to call `$timeout.flush()` to resolve a call to `$q.when` with a value.
|
||||
|
||||
The previous behavior involved creating an extra promise that needed to be resolved. This is no longer needed when
|
||||
`$q.when` is called with a value. In the case that the test is not aware if `$q.when` is called with a value or
|
||||
another promise, it is possible to replace `$timeout.flush();` with `$timeout.flush(0);`.
|
||||
|
||||
```js
|
||||
describe('$q.when', function() {
|
||||
it('should not need a call to $timeout.flush() to resolve already resolved promises',
|
||||
inject(function($q, $timeout) {
|
||||
$q.when('foo');
|
||||
// In Angular 1.4.3 a call to `$timeout.flush();` was needed
|
||||
$timeout.verifyNoPendingTasks();
|
||||
}));
|
||||
|
||||
it('should accept $timeout.flush(0) when not sure if $q.when was called with a value or a promise',
|
||||
inject(function($q, $timeout) {
|
||||
$q.when('foo');
|
||||
$timeout.flush(0);
|
||||
$timeout.verifyNoPendingTasks();
|
||||
}));
|
||||
|
||||
it('should need a call to $timeout.flush() to resolve $q.when when called with a promise',
|
||||
inject(function($q, $timeout) {
|
||||
$q.when($q.when('foo'));
|
||||
$timeout.flush();
|
||||
$timeout.verifyNoPendingTasks();
|
||||
}));
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
<a name="1.4.3"></a>
|
||||
# 1.4.3 foam-acceleration (2015-07-15)
|
||||
|
||||
+2
-1
@@ -19,7 +19,7 @@ Help us keep Angular open and inclusive. Please read and follow our [Code of Con
|
||||
## <a name="question"></a> Got a Question or Problem?
|
||||
|
||||
If you have questions about how to use AngularJS, please direct these to the [Google Group][groups]
|
||||
discussion list or [StackOverflow][stackoverflow]. We are also available on [IRC][irc].
|
||||
discussion list or [StackOverflow][stackoverflow]. We are also available on [IRC][irc] and [Gitter][gitter].
|
||||
|
||||
## <a name="issue"></a> Found an Issue?
|
||||
If you find a bug in the source code or a mistake in the documentation, you can help us by
|
||||
@@ -268,6 +268,7 @@ You can find out more detailed information about contributing in the
|
||||
[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html
|
||||
[dev-doc]: https://docs.angularjs.org/guide
|
||||
[github]: https://github.com/angular/angular.js
|
||||
[gitter]: https://gitter.im/angular/angular.js
|
||||
[groups]: https://groups.google.com/forum/?fromgroups#!forum/angular
|
||||
[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html
|
||||
[irc]: http://webchat.freenode.net/?channels=angularjs&uio=d4
|
||||
|
||||
+1
-1
@@ -305,7 +305,7 @@ module.exports = function(grunt) {
|
||||
|
||||
shell: {
|
||||
"npm-install": {
|
||||
command: path.normalize('scripts/npm/install-dependencies.sh')
|
||||
command: 'node scripts/npm/check-node-modules.js'
|
||||
},
|
||||
|
||||
"promises-aplus-tests": {
|
||||
|
||||
Vendored
-1
@@ -92,7 +92,6 @@ var angularFiles = {
|
||||
'angularModules': {
|
||||
'ngAnimate': [
|
||||
'src/ngAnimate/shared.js',
|
||||
'src/ngAnimate/body.js',
|
||||
'src/ngAnimate/rafScheduler.js',
|
||||
'src/ngAnimate/animateChildrenDirective.js',
|
||||
'src/ngAnimate/animateCss.js',
|
||||
|
||||
@@ -44,7 +44,7 @@ var noArgs = function (fn) {
|
||||
|
||||
var identity = function (i) { return i; };
|
||||
|
||||
// like Q.all, but runs the comands in series
|
||||
// like Q.all, but runs the commands in series
|
||||
// useful for ensuring env state (like which branch is checked out)
|
||||
var allInSeries = function (fn) {
|
||||
return function (args) {
|
||||
|
||||
@@ -56,7 +56,7 @@ li.doc-example-live {
|
||||
}
|
||||
|
||||
div.syntaxhighlighter {
|
||||
padding-bottom: 1px !important; /* fix to remove unnecessary scrollbars http://is.gd/gSMgC */
|
||||
padding-bottom: 1px !important; /* fix to remove unnecessary scrollbars */
|
||||
}
|
||||
|
||||
/* TABS - tutorial environment navigation */
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<li class="disabled"><a href="http://angularjs.org/">Why AngularJS?</a></li>
|
||||
<li><a href="http://www.youtube.com/user/angularjs">Watch</a></li>
|
||||
<li><a href="tutorial">Tutorial</a></li>
|
||||
<li><a href="http://builtwith.angularjs.org/">Case Studies</a></li>
|
||||
<li><a href="https://www.madewithangular.com/">Case Studies</a></li>
|
||||
<li><a href="https://github.com/angular/angular-seed">Seed App project template</a></li>
|
||||
<li><a href="misc/faq">FAQ</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -301,7 +301,7 @@ it('should show example', inject(
|
||||
### Fallback for legacy browsers
|
||||
|
||||
For browsers that support the HTML5 history API, `$location` uses the HTML5 history API to write
|
||||
path and search. If the history API is not supported by a browser, `$location` supplies a Hasbang
|
||||
path and search. If the history API is not supported by a browser, `$location` supplies a Hashbang
|
||||
URL. This frees you from having to worry about whether the browser viewing your app supports the
|
||||
history API or not; the `$location` service makes this transparent to you.
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ angular.module('myApp', ['ngAria'])...
|
||||
###Using ngAria
|
||||
Most of what ngAria does is only visible "under the hood". To see the module in action, once you've
|
||||
added it as a dependency, you can test a few things:
|
||||
* Using your favorite element inspector, look for ngAria attributes in your own code.
|
||||
* Using your favorite element inspector, look for attributes added by ngAria in your own code.
|
||||
* Test using your keyboard to ensure `tabindex` is used correctly.
|
||||
* Fire up a screen reader such as VoiceOver to listen for ARIA support.
|
||||
* Fire up a screen reader such as VoiceOver or NVDA to check for ARIA support.
|
||||
[Helpful screen reader tips.](http://webaim.org/articles/screenreader_testing/)
|
||||
|
||||
##Supported directives
|
||||
@@ -41,8 +41,8 @@ Currently, ngAria interfaces with the following directives:
|
||||
|
||||
<h2 id="ngmodel">ngModel</h2>
|
||||
|
||||
Most of ngAria's heavy lifting happens in the {@link ngModel ngModel}
|
||||
directive. For elements using ngModel, special attention is paid by ngAria if that element also
|
||||
Much of ngAria's heavy lifting happens in the {@link ngModel ngModel}
|
||||
directive. For elements using ngModel, special attention is paid by ngAria if that element also
|
||||
has a role or type of `checkbox`, `radio`, `range` or `textbox`.
|
||||
|
||||
For those elements using ngModel, ngAria will dynamically bind and update the following ARIA
|
||||
@@ -134,10 +134,8 @@ attributes (if they have not been explicitly specified by the developer):
|
||||
|
||||
ngAria will also add `tabIndex`, ensuring custom elements with these roles will be reachable from
|
||||
the keyboard. It is still up to **you** as a developer to **ensure custom controls will be
|
||||
operable** from the keybard. Think of `ng-click` on a `<div>` or `<md-checkbox>`: you still need
|
||||
to bind `ng-keypress` to make it fully operable from the keyboard. As a rule, any time you create
|
||||
a widget involving user interaction, be sure to test it with your keyboard and at least one mobile
|
||||
and desktop screen reader (preferably more).
|
||||
accessible**. As a rule, any time you create a widget involving user interaction, be sure to test
|
||||
it with your keyboard and at least one mobile and desktop screen reader.
|
||||
|
||||
<h2 id="ngdisabled">ngDisabled</h2>
|
||||
|
||||
@@ -160,7 +158,7 @@ Becomes:
|
||||
```
|
||||
|
||||
>You can check whether a control is legitimately disabled for a screen reader by visiting
|
||||
[chrome://accessibility](chrome://accessibility).
|
||||
[chrome://accessibility](chrome://accessibility) and inspecting [the accessibility tree](http://www.paciellogroup.com/blog/2015/01/the-browser-accessibility-tree/).
|
||||
|
||||
<h2 id="ngshow">ngShow</h2>
|
||||
|
||||
@@ -210,16 +208,25 @@ The default CSS for `ngHide`, the inverse method to `ngShow`, makes ngAria redun
|
||||
`display: none`. See explanation for {@link guide/accessibility#ngshow ngShow} when overriding the default CSS.
|
||||
|
||||
<h2><span id="ngclick">ngClick</span> and <span id="ngdblclick">ngDblclick</span></h2>
|
||||
If `ng-click` or `ng-dblclick` is encountered, ngAria will add `tabindex="0"` if it isn't there
|
||||
already.
|
||||
If `ng-click` or `ng-dblclick` is encountered, ngAria will add `tabindex="0"` to any element not in
|
||||
a node blacklist:
|
||||
|
||||
To fix widespread accessibility problems with `ng-click` on div elements, ngAria will dynamically
|
||||
bind keypress by default as long as the element isn't an anchor, button, input or textarea.
|
||||
You can turn this functionality on or off with the `bindKeypress` configuration option. ngAria
|
||||
will also add the `button` role to communicate to users of assistive technologies.
|
||||
* Button
|
||||
* Anchor
|
||||
* Input
|
||||
* Textarea
|
||||
* Select
|
||||
* Details/Summary
|
||||
|
||||
For `ng-dblclick`, you must still manually add `ng-keypress` and role to non-interactive elements such
|
||||
as `div` or `taco-button` to enable keyboard access.
|
||||
To fix widespread accessibility problems with `ng-click` on `div` elements, ngAria will
|
||||
dynamically bind a keypress event by default as long as the element isn't in the node blacklist.
|
||||
You can turn this functionality on or off with the `bindKeypress` configuration option.
|
||||
|
||||
ngAria will also add the `button` role to communicate to users of assistive technologies. This can
|
||||
be disabled with the `bindRoleForClick` configuration option.
|
||||
|
||||
For `ng-dblclick`, you must still manually add `ng-keypress` and a role to non-interactive elements
|
||||
such as `div` or `taco-button` to enable keyboard access.
|
||||
|
||||
<h3>Example</h3>
|
||||
```html
|
||||
@@ -260,62 +267,18 @@ The attribute magic of ngAria may not work for every scenario. To disable indivi
|
||||
you can use the {@link ngAria.$ariaProvider#config config} method. Just keep in mind this will
|
||||
tell ngAria to ignore the attribute globally.
|
||||
|
||||
<example module="ngAria_ngDisabledExample" deps="angular-aria.js">
|
||||
<example module="ngAria_ngClickExample" deps="angular-aria.js">
|
||||
<file name="index.html">
|
||||
<style>
|
||||
[role=checkbox] {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
}
|
||||
[role=checkbox] .icon:before {
|
||||
content: '\2610';
|
||||
display: inline-block;
|
||||
font-size: 2em;
|
||||
line-height: 1;
|
||||
vertical-align: middle;
|
||||
speak: none;
|
||||
}
|
||||
[role=checkbox].active .icon:before {
|
||||
content: '\2611';
|
||||
}
|
||||
</style>
|
||||
<form ng-controller="formsController">
|
||||
<div ng-model="someModel" show-attrs>
|
||||
Div with ngModel and aria-invalid disabled
|
||||
<div ng-click="someFunction" show-attrs>
|
||||
<div> with ng-click and bindRoleForClick, tabindex set to false
|
||||
</div>
|
||||
<div role="checkbox" ng-model="checked" ng-class="{active: checked}"
|
||||
aria-label="Custom Checkbox" ng-click="toggleCheckbox()" some-checkbox show-attrs>
|
||||
<span class="icon" aria-hidden="true"></span>
|
||||
Custom Checkbox for comparison
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
angular.module('ngAria_ngDisabledExample', ['ngAria'], function config($ariaProvider) {
|
||||
angular.module('ngAria_ngClickExample', ['ngAria'], function config($ariaProvider) {
|
||||
$ariaProvider.config({
|
||||
ariaInvalid: false,
|
||||
tabindex: true
|
||||
bindRoleForClick: false,
|
||||
tabindex: false
|
||||
});
|
||||
})
|
||||
.controller('formsController', function($scope){
|
||||
$scope.checked = false;
|
||||
$scope.toggleCheckbox = function(){
|
||||
$scope.checked = !$scope.checked;
|
||||
}
|
||||
})
|
||||
.directive('someCheckbox', function(){
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function($scope, $el, $attrs) {
|
||||
$el.on('keypress', function(event){
|
||||
event.preventDefault();
|
||||
if(event.keyCode === 32 || event.keyCode === 13){
|
||||
$scope.toggleCheckbox();
|
||||
$scope.$apply();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.directive('showAttrs', function() {
|
||||
return function(scope, el, attrs) {
|
||||
var pre = document.createElement('pre');
|
||||
|
||||
@@ -8,22 +8,22 @@
|
||||
This section briefly touches on all of the important parts of AngularJS using a simple example.
|
||||
For a more in-depth explanation, see the {@link tutorial/ tutorial}.
|
||||
|
||||
| Concept | Description |
|
||||
|------------------|------------------------------------------|
|
||||
|{@link concepts#template Template} | HTML with additional markup |
|
||||
|{@link concepts#directive Directives} | extend HTML with custom attributes and elements |
|
||||
|{@link concepts#model Model} | the data shown to the user in the view and with which the user interacts |
|
||||
|{@link concepts#scope Scope} | context where the model is stored so that controllers, directives and expressions can access it |
|
||||
|{@link concepts#expression Expressions} | access variables and functions from the scope |
|
||||
|{@link concepts#compiler Compiler} | parses the template and instantiates directives and expressions |
|
||||
|{@link concepts#filter Filter} | formats the value of an expression for display to the user |
|
||||
|{@link concepts#view View} | what the user sees (the DOM) |
|
||||
|{@link concepts#databinding Data Binding} | sync data between the model and the view |
|
||||
|{@link concepts#controller Controller} | the business logic behind views |
|
||||
|{@link concepts#di Dependency Injection} | Creates and wires objects and functions |
|
||||
|{@link concepts#injector Injector} | dependency injection container |
|
||||
|{@link concepts#module Module} | a container for the different parts of an app including controllers, services, filters, directives which configures the Injector |
|
||||
|{@link concepts#service Service} | reusable business logic independent of views |
|
||||
| Concept | Description |
|
||||
|--------------------------------------------|--------------------------------------------------------------------------|
|
||||
|{@link concepts#template Template} | HTML with additional markup |
|
||||
|{@link concepts#directive Directives} | extend HTML with custom attributes and elements |
|
||||
|{@link concepts#model Model} | the data shown to the user in the view and with which the user interacts |
|
||||
|{@link concepts#scope Scope} | context where the model is stored so that controllers, directives and expressions can access it |
|
||||
|{@link concepts#expression Expressions} | access variables and functions from the scope |
|
||||
|{@link concepts#compiler Compiler} | parses the template and instantiates directives and expressions |
|
||||
|{@link concepts#filter Filter} | formats the value of an expression for display to the user |
|
||||
|{@link concepts#view View} | what the user sees (the DOM) |
|
||||
|{@link concepts#databinding Data Binding} | sync data between the model and the view |
|
||||
|{@link concepts#controller Controller} | the business logic behind views |
|
||||
|{@link concepts#di Dependency Injection} | Creates and wires objects and functions |
|
||||
|{@link concepts#injector Injector} | dependency injection container |
|
||||
|{@link concepts#module Module} | a container for the different parts of an app including controllers, services, filters, directives which configures the Injector |
|
||||
|{@link concepts#service Service} | reusable business logic independent of views |
|
||||
|
||||
|
||||
## A first example: Data binding
|
||||
|
||||
@@ -19,8 +19,9 @@ how to implement them.
|
||||
## What are Directives?
|
||||
|
||||
At a high level, directives are markers on a DOM element (such as an attribute, element
|
||||
name, comment or CSS class) that tell AngularJS's **HTML compiler** ({@link ng.$compile `$compile`}) to
|
||||
attach a specified behavior to that DOM element or even transform the DOM element and its children.
|
||||
name, comment or CSS class) that tell AngularJS's **HTML compiler** ({@link ng.$compile `$compile`})
|
||||
to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform
|
||||
the DOM element and its children.
|
||||
|
||||
Angular comes with a set of these directives built-in, like `ngBind`, `ngModel`, and `ngClass`.
|
||||
Much like you create controllers and services, you can create your own directives for Angular to use.
|
||||
@@ -30,7 +31,7 @@ When Angular {@link guide/bootstrap bootstraps} your application, the
|
||||
<div class="alert alert-info">
|
||||
**What does it mean to "compile" an HTML template?**
|
||||
|
||||
For AngularJS, "compilation" means attaching event listeners to the HTML to make it interactive.
|
||||
For AngularJS, "compilation" means attaching directives to the HTML to make it interactive.
|
||||
The reason we use the term "compile" is that the recursive process of attaching directives
|
||||
mirrors the process of compiling source code in
|
||||
[compiled programming languages](http://en.wikipedia.org/wiki/Compiled_languages).
|
||||
@@ -42,18 +43,27 @@ mirrors the process of compiling source code in
|
||||
Before we can write a directive, we need to know how Angular's {@link guide/compiler HTML compiler}
|
||||
determines when to use a given directive.
|
||||
|
||||
In the following example, we say that the `<input>` element **matches** the `ngModel` directive.
|
||||
Similar to the terminology used when an [element **matches** a selector](https://developer.mozilla.org/en-US/docs/Web/API/Element.matches), we say an element **matches** a
|
||||
directive when the directive is part of its declaration.
|
||||
|
||||
In the following example, we say that the `<input>` element **matches** the `ngModel` directive
|
||||
|
||||
```html
|
||||
<input ng-model="foo">
|
||||
```
|
||||
|
||||
The following also **matches** `ngModel`:
|
||||
The following `<input>` element also **matches** `ngModel`:
|
||||
|
||||
```html
|
||||
<input data-ng-model="foo">
|
||||
```
|
||||
|
||||
And the following <person> element **matches** the `person` directive:
|
||||
|
||||
```html
|
||||
<person>{{name}}</person>
|
||||
```
|
||||
|
||||
### Normalization
|
||||
|
||||
Angular **normalizes** an element's tag and attribute name to determine which elements match which
|
||||
@@ -892,7 +902,7 @@ to which tab is active.
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
scope: {},
|
||||
controller: function($scope) {
|
||||
controller: ['$scope', function($scope) {
|
||||
var panes = $scope.panes = [];
|
||||
|
||||
$scope.select = function(pane) {
|
||||
@@ -908,7 +918,7 @@ to which tab is active.
|
||||
}
|
||||
panes.push(pane);
|
||||
};
|
||||
},
|
||||
}],
|
||||
templateUrl: 'my-tabs.html'
|
||||
};
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@ for other directives to augment its behavior.
|
||||
<input type="button" ng-click="reset()" value="Reset" />
|
||||
<input type="submit" ng-click="update(user)" value="Save" />
|
||||
</form>
|
||||
<pre>form = {{user | json}}</pre>
|
||||
<pre>user = {{user | json}}</pre>
|
||||
<pre>master = {{master | json}}</pre>
|
||||
</div>
|
||||
|
||||
@@ -95,7 +95,7 @@ and failing to satisfy its validity.
|
||||
<input type="button" ng-click="reset()" value="Reset" />
|
||||
<input type="submit" ng-click="update(user)" value="Save" />
|
||||
</form>
|
||||
<pre>form = {{user | json}}</pre>
|
||||
<pre>user = {{user | json}}</pre>
|
||||
<pre>master = {{master | json}}</pre>
|
||||
</div>
|
||||
|
||||
@@ -185,7 +185,7 @@ didn't interact with a control
|
||||
<input type="button" ng-click="reset(form)" value="Reset" />
|
||||
<input type="submit" ng-click="update(user)" value="Save" />
|
||||
</form>
|
||||
<pre>form = {{user | json}}</pre>
|
||||
<pre>user = {{user | json}}</pre>
|
||||
<pre>master = {{master | json}}</pre>
|
||||
</div>
|
||||
</file>
|
||||
|
||||
@@ -156,8 +156,94 @@ The syntax extension is based on a subset of the ICU MessageFormat syntax that c
|
||||
gender selections. Please refer to the links in the “Further Reading” section at the bottom of this
|
||||
section.
|
||||
|
||||
You may find it helpful to play with our [Plnkr Example](http://plnkr.co/edit/QBVRQ70dvKZDWmHW9RyR?p=preview)
|
||||
as you read the examples below.
|
||||
You may find it helpful to play with the following example as you read the explanations below:
|
||||
|
||||
<example name="message-format-example" module="messageFormatExample" deps="angular-message-format.js">
|
||||
<file name="index.html">
|
||||
<div ng-controller="ckCtrl">
|
||||
<b>Set number of recipients</b>
|
||||
<button ng-click="setNumRecipients(0)">None</button>
|
||||
<button ng-click="setNumRecipients(1)">One</button>
|
||||
<button ng-click="setNumRecipients(2)">Two</button>
|
||||
<button ng-click="setNumRecipients(3)">Three</button>
|
||||
|
||||
|
||||
<br><br>
|
||||
<b>Sender's</b> name: <input ng-model="sender.name">
|
||||
|
||||
<br><br><b>Recipients</b><br>
|
||||
<div ng-repeat="recipient in recipients">
|
||||
Name: <input ng-model="recipient.name">
|
||||
Gender: <button ng-click="setGender(recipient, 'male')">male</button>
|
||||
<button ng-click="setGender(recipient, 'female')">female</button>
|
||||
<button ng-click="setGender(recipient, 'other')">other</button>
|
||||
</div>
|
||||
|
||||
<br><br><b>Message</b><br>
|
||||
{{recipients.length, plural, offset:1
|
||||
=0 {You ({{sender.name}}) gave no gifts}
|
||||
=1 { {{ recipients[0].gender, select,
|
||||
male {You ({{sender.name}}) gave him ({{recipients[0].name}}) a gift.}
|
||||
female {You ({{sender.name}}) gave her ({{recipients[0].name}}) a gift.}
|
||||
other {You ({{sender.name}}) gave them ({{recipients[0].name}}) a gift.}
|
||||
}}
|
||||
}
|
||||
one { {{ recipients[0].gender, select,
|
||||
male {You ({{sender.name}}) gave him ({{recipients[0].name}}) and one other person a gift.}
|
||||
female {You ({{sender.name}}) gave her ({{recipients[0].name}}) and one other person a gift.}
|
||||
other {You ({{sender.name}}) gave them ({{recipients[0].name}}) and one other person a gift.}
|
||||
}}
|
||||
}
|
||||
other {You ({{sender.name}}) gave {{recipients.length}} people gifts. }
|
||||
}}
|
||||
|
||||
<br><br><b>In an attribute</b><br>
|
||||
<div attrib="{{recipients.length, plural, offset:1
|
||||
=0 {You ({{sender.name}}) gave no gifts}
|
||||
=1 { {{ recipients[0].gender, select,
|
||||
male {You ({{sender.name}}) gave him ({{recipients[0].name}}) a gift.}
|
||||
female {You ({{sender.name}}) gave her ({{recipients[0].name}}) a gift.}
|
||||
other {You ({{sender.name}}) gave them ({{recipients[0].name}}) a gift.}
|
||||
}}
|
||||
}
|
||||
one { {{ recipients[0].gender, select,
|
||||
male {You ({{sender.name}}) gave him ({{recipients[0].name}}) and one other person a gift.}
|
||||
female {You ({{sender.name}}) gave her ({{recipients[0].name}}) and one other person a gift.}
|
||||
other {You ({{sender.name}}) gave them ({{recipients[0].name}}) and one other person a gift.}
|
||||
}}
|
||||
}
|
||||
other {You ({{sender.name}}) gave {{recipients.length}} people gifts. }
|
||||
}}">
|
||||
This div has an attribute interpolated with messageformat. Use the DOM inspector to check it out.
|
||||
</div>
|
||||
</div>
|
||||
</file>
|
||||
<file name="app.js">
|
||||
function Person(name, gender) {
|
||||
this.name = name;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
angular.module('messageFormatExample', ['ngMessageFormat'])
|
||||
.controller('ckCtrl', function ($scope, $injector, $parse) {
|
||||
var people = [ new Person("Alice", "female"),
|
||||
new Person("Bob", "male"),
|
||||
new Person("Charlie", "male") ];
|
||||
|
||||
$scope.sender = new Person("Harry Potter", "male");
|
||||
$scope.recipients = people.slice();
|
||||
|
||||
$scope.setNumRecipients = function(n) {
|
||||
n = n > people.length ? people.length : n;
|
||||
$scope.recipients = people.slice(0, n);
|
||||
};
|
||||
|
||||
$scope.setGender = function(person, gender) {
|
||||
person.gender = gender;
|
||||
};
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
|
||||
### Plural Syntax
|
||||
|
||||
@@ -333,9 +419,9 @@ allows you to nest plural and gender expressions in any order.
|
||||
Please note that if these are intended to reach a translator and be translated, it is recommended
|
||||
that the messages appear as a whole and not be split up.
|
||||
|
||||
### More complex example that demonstrates nesting
|
||||
### Demonstration of nesting
|
||||
|
||||
This is taken from the [plunker example](http://plnkr.co/edit/QBVRQ70dvKZDWmHW9RyR?p=preview) linked to earlier.
|
||||
This is taken from the above example.
|
||||
|
||||
```text
|
||||
{{recipients.length, plural, offset:1
|
||||
|
||||
@@ -15,14 +15,14 @@ development.
|
||||
production.
|
||||
|
||||
To point your code to an angular script on the Google CDN server, use the following template. This
|
||||
example points to the minified version 1.3.14:
|
||||
example points to the minified version 1.4.5:
|
||||
|
||||
```
|
||||
<!doctype html>
|
||||
<html ng-app>
|
||||
<head>
|
||||
<title>My Angular App</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
|
||||
@@ -86,9 +86,15 @@ Yes. See instructions in {@link downloading}.
|
||||
|
||||
### What browsers does Angular work with?
|
||||
|
||||
We run our extensive test suite against the following browsers: Safari, Chrome, Firefox, Opera 15,
|
||||
IE9 and mobile browsers (Android, Chrome Mobile, iOS Safari). See {@link guide/ie Internet
|
||||
Explorer Compatibility} for more details on supporting legacy IE browsers.
|
||||
We run our extensive test suite against the following browsers: the latest versions of Chrome,
|
||||
Firefox, Safari, and Safari for iOs, as well as Internet Explorer versions 9-11. See {@link guide/ie
|
||||
Internet Explorer Compatibility} for more details on supporting legacy IE browsers.
|
||||
|
||||
If a browser is untested, it doesn't mean it won't work; for example, older Android (2.3.x)
|
||||
is supported in the sense that we avoid the dot notation for reserved words as property names,
|
||||
but we don't actively test changes against it. You can also expect browsers to work that share
|
||||
a large part of their codebase with a browser we test, such as Opera > version 12
|
||||
(uses the Blink engine), or the various Firefox derivatives.
|
||||
|
||||
|
||||
### What's Angular's performance like?
|
||||
|
||||
@@ -173,7 +173,7 @@ function request(method, url, options, response) {
|
||||
res.on('error', function (e) { console.log(e); });
|
||||
break;
|
||||
case 401:
|
||||
console.log('Eror: Login credentials expired! Please login.');
|
||||
console.log('Error: Login credentials expired! Please login.');
|
||||
break;
|
||||
default:
|
||||
data = [];
|
||||
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
|
||||
echo "Shutting down Browserstack tunnel"
|
||||
echo "TODO: implement me"
|
||||
exit 1
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
|
||||
echo "Shutting down Sauce Connect tunnel"
|
||||
|
||||
killall sc
|
||||
|
||||
while [[ -n `ps -ef | grep "sauce-connect-" | grep -v "grep"` ]]; do
|
||||
printf "."
|
||||
sleep .5
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Sauce Connect tunnel has been shut down"
|
||||
@@ -3,6 +3,7 @@
|
||||
"license": "MIT",
|
||||
"branchVersion": "^1.4.0-beta.0",
|
||||
"branchPattern": "1.4.*",
|
||||
"distTag": "latest",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/angular/angular.js.git"
|
||||
@@ -12,6 +13,10 @@
|
||||
"npm": "~2.5"
|
||||
},
|
||||
"engineStrict": true,
|
||||
"scripts": {
|
||||
"preinstall": "node scripts/npm/check-node-modules.js --purge",
|
||||
"postinstall": "node scripts/npm/copy-npm-shrinkwrap.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"angular-benchpress": "0.x.x",
|
||||
"benchmark": "1.x.x",
|
||||
|
||||
@@ -14,6 +14,8 @@ function init {
|
||||
TMP_DIR=$(resolveDir ../../tmp)
|
||||
BUILD_DIR=$(resolveDir ../../build)
|
||||
NEW_VERSION=$(cat $BUILD_DIR/version.txt)
|
||||
# get the npm dist-tag from a custom property (distTag) in package.json
|
||||
DIST_TAG=$(readJsonProp "package.json" "distTag")
|
||||
}
|
||||
|
||||
|
||||
@@ -95,19 +97,8 @@ function publish {
|
||||
|
||||
# don't publish every build to npm
|
||||
if [ "${NEW_VERSION/+sha}" = "$NEW_VERSION" ] ; then
|
||||
if [ "${NEW_VERSION/-}" = "$NEW_VERSION" ] ; then
|
||||
if [[ $NEW_VERSION =~ ^1\.2\.[0-9]+$ ]] ; then
|
||||
# publish 1.2.x releases with the appropriate tag
|
||||
# this ensures that `npm install` by default will not grab `1.2.x` releases
|
||||
npm publish --tag=old
|
||||
else
|
||||
# publish releases as "latest"
|
||||
npm publish
|
||||
fi
|
||||
else
|
||||
# publish prerelease builds with the beta tag
|
||||
npm publish --tag=beta
|
||||
fi
|
||||
echo "-- Publishing to npm as $DIST_TAG"
|
||||
npm publish --tag=$DIST_TAG
|
||||
fi
|
||||
|
||||
cd $SCRIPT_DIR
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
// Implementation based on:
|
||||
// https://github.com/angular/angular/blob/3b9c08676a4c921bbfa847802e08566fb601ba7a/tools/npm/check-node-modules.js
|
||||
'use strict';
|
||||
|
||||
// Imports
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
// Constants
|
||||
var PROJECT_ROOT = path.join(__dirname, '../../');
|
||||
var NODE_MODULES_DIR = 'node_modules';
|
||||
var NPM_SHRINKWRAP_FILE = 'npm-shrinkwrap.json';
|
||||
var NPM_SHRINKWRAP_CACHED_FILE = NODE_MODULES_DIR + '/npm-shrinkwrap.cached.json';
|
||||
|
||||
// Run
|
||||
_main();
|
||||
|
||||
// Functions - Definitions
|
||||
function _main() {
|
||||
var purgeIfStale = process.argv.indexOf('--purge') !== -1;
|
||||
|
||||
process.chdir(PROJECT_ROOT);
|
||||
checkNodeModules(purgeIfStale);
|
||||
}
|
||||
|
||||
function checkNodeModules(purgeIfStale) {
|
||||
var nodeModulesOk = compareMarkerFiles(NPM_SHRINKWRAP_FILE, NPM_SHRINKWRAP_CACHED_FILE);
|
||||
|
||||
if (nodeModulesOk) {
|
||||
console.log(':-) npm dependencies are looking good!');
|
||||
} else if (purgeIfStale) {
|
||||
console.log(':-( npm dependencies are stale or in an unknown state!');
|
||||
console.log(' Purging \'' + NODE_MODULES_DIR + '\'...');
|
||||
deleteDirSync(NODE_MODULES_DIR);
|
||||
} else {
|
||||
var separator = new Array(81).join('!');
|
||||
|
||||
console.warn(separator);
|
||||
console.warn(':-( npm dependencies are stale or in an unknown state!');
|
||||
console.warn('You can rebuild the dependencies by running `npm install`.');
|
||||
console.warn(separator);
|
||||
}
|
||||
|
||||
return nodeModulesOk;
|
||||
}
|
||||
|
||||
function compareMarkerFiles(markerFilePath, cachedMarkerFilePath) {
|
||||
if (!fs.existsSync(cachedMarkerFilePath)) return false;
|
||||
|
||||
var opts = {encoding: 'utf-8'};
|
||||
var markerContent = fs.readFileSync(markerFilePath, opts);
|
||||
var cachedMarkerContent = fs.readFileSync(cachedMarkerFilePath, opts);
|
||||
|
||||
return markerContent === cachedMarkerContent;
|
||||
}
|
||||
|
||||
// Custom implementation of `rm -rf` that works consistently across OSes
|
||||
function deleteDirSync(path) {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.readdirSync(path).forEach(deleteDirOrFileSync);
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
|
||||
// Helpers
|
||||
function deleteDirOrFileSync(subpath) {
|
||||
var curPath = path + '/' + subpath;
|
||||
|
||||
if (fs.lstatSync(curPath).isDirectory()) {
|
||||
deleteDirSync(curPath);
|
||||
} else {
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
// Imports
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
// Constants
|
||||
var PROJECT_ROOT = path.join(__dirname, '../../');
|
||||
var NODE_MODULES_DIR = 'node_modules';
|
||||
var NPM_SHRINKWRAP_FILE = 'npm-shrinkwrap.json';
|
||||
var NPM_SHRINKWRAP_CACHED_FILE = NODE_MODULES_DIR + '/npm-shrinkwrap.cached.json';
|
||||
|
||||
// Run
|
||||
_main();
|
||||
|
||||
// Functions - Definitions
|
||||
function _main() {
|
||||
process.chdir(PROJECT_ROOT);
|
||||
copyFile(NPM_SHRINKWRAP_FILE, NPM_SHRINKWRAP_CACHED_FILE, onCopied);
|
||||
}
|
||||
|
||||
// Implementation based on:
|
||||
// https://stackoverflow.com/questions/11293857/fastest-way-to-copy-file-in-node-js#answer-21995878
|
||||
function copyFile(srcPath, dstPath, callback) {
|
||||
var callbackCalled = false;
|
||||
|
||||
if (!fs.existsSync(srcPath)) {
|
||||
done(new Error('Missing source file: ' + srcPath));
|
||||
return;
|
||||
}
|
||||
|
||||
var rs = fs.createReadStream(srcPath);
|
||||
rs.on('error', done);
|
||||
|
||||
var ws = fs.createWriteStream(dstPath);
|
||||
ws.on('error', done);
|
||||
ws.on('finish', done);
|
||||
|
||||
rs.pipe(ws);
|
||||
|
||||
// Helpers
|
||||
function done(err) {
|
||||
if (callback && !callbackCalled) {
|
||||
callbackCalled = true;
|
||||
callback(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onCopied(err) {
|
||||
if (err) {
|
||||
var separator = new Array(81).join('!');
|
||||
|
||||
console.error(separator);
|
||||
console.error(
|
||||
'Failed to copy `' + NPM_SHRINKWRAP_FILE + '` to `' + NPM_SHRINKWRAP_CACHED_FILE + '`:');
|
||||
console.error(err);
|
||||
console.error(separator);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SHRINKWRAP_FILE=npm-shrinkwrap.json
|
||||
SHRINKWRAP_CACHED_FILE=node_modules/npm-shrinkwrap.cached.json
|
||||
|
||||
if diff -q $SHRINKWRAP_FILE $SHRINKWRAP_CACHED_FILE; then
|
||||
echo 'No shrinkwrap changes detected. npm install will be skipped...';
|
||||
else
|
||||
echo 'Blowing away node_modules and reinstalling npm dependencies...'
|
||||
rm -rf node_modules
|
||||
npm install
|
||||
cp $SHRINKWRAP_FILE $SHRINKWRAP_CACHED_FILE
|
||||
echo 'npm install successful!'
|
||||
fi
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Has to be run from project root directory.
|
||||
|
||||
./lib/${BROWSER_PROVIDER}/teardown_tunnel.sh
|
||||
+18
-15
@@ -825,6 +825,8 @@ function copy(source, destination, stackSource, stackDest) {
|
||||
} else if (isRegExp(source)) {
|
||||
destination = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]);
|
||||
destination.lastIndex = source.lastIndex;
|
||||
} else if (isFunction(source.cloneNode)) {
|
||||
destination = source.cloneNode(true);
|
||||
} else {
|
||||
var emptyObject = Object.create(getPrototypeOf(source));
|
||||
return copy(source, emptyObject, stackSource, stackDest);
|
||||
@@ -975,7 +977,7 @@ function equals(o1, o2) {
|
||||
for (key in o2) {
|
||||
if (!(key in keySet) &&
|
||||
key.charAt(0) !== '$' &&
|
||||
o2[key] !== undefined &&
|
||||
isDefined(o2[key]) &&
|
||||
!isFunction(o2[key])) return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1671,10 +1673,9 @@ function bindJQuery() {
|
||||
|
||||
// bind to jQuery if present;
|
||||
var jqName = jq();
|
||||
jQuery = window.jQuery; // use default jQuery.
|
||||
if (isDefined(jqName)) { // `ngJq` present
|
||||
jQuery = jqName === null ? undefined : window[jqName]; // if empty; use jqLite. if not empty, use jQuery specified by `ngJq`.
|
||||
}
|
||||
jQuery = isUndefined(jqName) ? window.jQuery : // use jQuery (if present)
|
||||
!jqName ? undefined : // use jqLite
|
||||
window[jqName]; // use jQuery specified by `ngJq`
|
||||
|
||||
// Use jQuery if it exists with proper functionality, otherwise default to us.
|
||||
// Angular 1.2+ requires jQuery 1.7+ for on()/off() support.
|
||||
@@ -1779,22 +1780,24 @@ function getter(obj, path, bindFnToScope) {
|
||||
/**
|
||||
* Return the DOM siblings between the first and last node in the given array.
|
||||
* @param {Array} array like object
|
||||
* @returns {jqLite} jqLite collection containing the nodes
|
||||
* @returns {Array} the inputted object or a jqLite collection containing the nodes
|
||||
*/
|
||||
function getBlockNodes(nodes) {
|
||||
// TODO(perf): just check if all items in `nodes` are siblings and if they are return the original
|
||||
// collection, otherwise update the original collection.
|
||||
// TODO(perf): update `nodes` instead of creating a new object?
|
||||
var node = nodes[0];
|
||||
var endNode = nodes[nodes.length - 1];
|
||||
var blockNodes = [node];
|
||||
var blockNodes;
|
||||
|
||||
do {
|
||||
node = node.nextSibling;
|
||||
if (!node) break;
|
||||
blockNodes.push(node);
|
||||
} while (node !== endNode);
|
||||
for (var i = 1; node !== endNode && (node = node.nextSibling); i++) {
|
||||
if (blockNodes || nodes[i] !== node) {
|
||||
if (!blockNodes) {
|
||||
blockNodes = jqLite(slice.call(nodes, 0, i));
|
||||
}
|
||||
blockNodes.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
return jqLite(blockNodes);
|
||||
return blockNodes || nodes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
$HttpParamSerializerProvider,
|
||||
$HttpParamSerializerJQLikeProvider,
|
||||
$HttpBackendProvider,
|
||||
$xhrFactoryProvider,
|
||||
$LocationProvider,
|
||||
$LogProvider,
|
||||
$ParseProvider,
|
||||
@@ -98,8 +99,9 @@
|
||||
* @name angular.version
|
||||
* @module ng
|
||||
* @description
|
||||
* An object that contains information about the current AngularJS version. This object has the
|
||||
* following properties:
|
||||
* An object that contains information about the current AngularJS version.
|
||||
*
|
||||
* This object has the following properties:
|
||||
*
|
||||
* - `full` – `{string}` – Full version string, such as "0.9.18".
|
||||
* - `major` – `{number}` – Major version number, such as "0".
|
||||
@@ -229,6 +231,7 @@ function publishExternalAPI(angular) {
|
||||
$httpParamSerializer: $HttpParamSerializerProvider,
|
||||
$httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider,
|
||||
$httpBackend: $HttpBackendProvider,
|
||||
$xhrFactory: $xhrFactoryProvider,
|
||||
$location: $LocationProvider,
|
||||
$log: $LogProvider,
|
||||
$parse: $ParseProvider,
|
||||
|
||||
+8
-9
@@ -151,10 +151,10 @@ function camelCase(name) {
|
||||
replace(MOZ_HACK_REGEXP, 'Moz$1');
|
||||
}
|
||||
|
||||
var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/;
|
||||
var SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/;
|
||||
var HTML_REGEXP = /<|&#?\w+;/;
|
||||
var TAG_NAME_REGEXP = /<([\w:]+)/;
|
||||
var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi;
|
||||
var TAG_NAME_REGEXP = /<([\w:-]+)/;
|
||||
var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi;
|
||||
|
||||
var wrapMap = {
|
||||
'option': [1, '<select multiple="multiple">', '</select>'],
|
||||
@@ -450,7 +450,7 @@ function jqLiteInheritedData(element, name, value) {
|
||||
|
||||
while (element) {
|
||||
for (var i = 0, ii = names.length; i < ii; i++) {
|
||||
if ((value = jqLite.data(element, names[i])) !== undefined) return value;
|
||||
if (isDefined(value = jqLite.data(element, names[i]))) return value;
|
||||
}
|
||||
|
||||
// If dealing with a document fragment node with a host element, and no parent, use the host
|
||||
@@ -556,9 +556,8 @@ function getBooleanAttrName(element, name) {
|
||||
return booleanAttr && BOOLEAN_ELEMENTS[nodeName_(element)] && booleanAttr;
|
||||
}
|
||||
|
||||
function getAliasedAttrName(element, name) {
|
||||
var nodeName = element.nodeName;
|
||||
return (nodeName === 'INPUT' || nodeName === 'TEXTAREA') && ALIASED_ATTR[name];
|
||||
function getAliasedAttrName(name) {
|
||||
return ALIASED_ATTR[name];
|
||||
}
|
||||
|
||||
forEach({
|
||||
@@ -695,7 +694,7 @@ forEach({
|
||||
// in a way that survives minification.
|
||||
// jqLiteEmpty takes no arguments but is a setter.
|
||||
if (fn !== jqLiteEmpty &&
|
||||
(((fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController)) ? arg1 : arg2) === undefined)) {
|
||||
(isUndefined((fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController)) ? arg1 : arg2))) {
|
||||
if (isObject(arg1)) {
|
||||
|
||||
// we are a write, but the object properties are the key/values
|
||||
@@ -716,7 +715,7 @@ forEach({
|
||||
// TODO: do we still need this?
|
||||
var value = fn.$dv;
|
||||
// Only if we have $dv do we iterate over all, otherwise it is just the first element.
|
||||
var jj = (value === undefined) ? Math.min(nodeCount, 1) : nodeCount;
|
||||
var jj = (isUndefined(value)) ? Math.min(nodeCount, 1) : nodeCount;
|
||||
for (var j = 0; j < jj; j++) {
|
||||
var nodeValue = fn(this[j], arg1, arg2);
|
||||
value = value ? value + nodeValue : nodeValue;
|
||||
|
||||
+55
-50
@@ -105,61 +105,66 @@ var $$CoreAnimateQueueProvider = function() {
|
||||
}
|
||||
};
|
||||
|
||||
function addRemoveClassesPostDigest(element, add, remove) {
|
||||
var classVal, data = postDigestQueue.get(element);
|
||||
|
||||
if (!data) {
|
||||
postDigestQueue.put(element, data = {});
|
||||
postDigestElements.push(element);
|
||||
}
|
||||
|
||||
var updateData = function(classes, value) {
|
||||
var changed = false;
|
||||
if (classes) {
|
||||
classes = isString(classes) ? classes.split(' ') :
|
||||
isArray(classes) ? classes : [];
|
||||
forEach(classes, function(className) {
|
||||
if (className) {
|
||||
changed = true;
|
||||
data[className] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
return changed;
|
||||
};
|
||||
|
||||
var classesAdded = updateData(add, true);
|
||||
var classesRemoved = updateData(remove, false);
|
||||
if ((!classesAdded && !classesRemoved) || postDigestElements.length > 1) return;
|
||||
|
||||
$rootScope.$$postDigest(function() {
|
||||
forEach(postDigestElements, function(element) {
|
||||
var data = postDigestQueue.get(element);
|
||||
if (data) {
|
||||
var existing = splitClasses(element.attr('class'));
|
||||
var toAdd = '';
|
||||
var toRemove = '';
|
||||
forEach(data, function(status, className) {
|
||||
var hasClass = !!existing[className];
|
||||
if (status !== hasClass) {
|
||||
if (status) {
|
||||
toAdd += (toAdd.length ? ' ' : '') + className;
|
||||
} else {
|
||||
toRemove += (toRemove.length ? ' ' : '') + className;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
forEach(element, function(elm) {
|
||||
toAdd && jqLiteAddClass(elm, toAdd);
|
||||
toRemove && jqLiteRemoveClass(elm, toRemove);
|
||||
});
|
||||
postDigestQueue.remove(element);
|
||||
function updateData(data, classes, value) {
|
||||
var changed = false;
|
||||
if (classes) {
|
||||
classes = isString(classes) ? classes.split(' ') :
|
||||
isArray(classes) ? classes : [];
|
||||
forEach(classes, function(className) {
|
||||
if (className) {
|
||||
changed = true;
|
||||
data[className] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
postDigestElements.length = 0;
|
||||
function handleCSSClassChanges() {
|
||||
forEach(postDigestElements, function(element) {
|
||||
var data = postDigestQueue.get(element);
|
||||
if (data) {
|
||||
var existing = splitClasses(element.attr('class'));
|
||||
var toAdd = '';
|
||||
var toRemove = '';
|
||||
forEach(data, function(status, className) {
|
||||
var hasClass = !!existing[className];
|
||||
if (status !== hasClass) {
|
||||
if (status) {
|
||||
toAdd += (toAdd.length ? ' ' : '') + className;
|
||||
} else {
|
||||
toRemove += (toRemove.length ? ' ' : '') + className;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
forEach(element, function(elm) {
|
||||
toAdd && jqLiteAddClass(elm, toAdd);
|
||||
toRemove && jqLiteRemoveClass(elm, toRemove);
|
||||
});
|
||||
postDigestQueue.remove(element);
|
||||
}
|
||||
});
|
||||
postDigestElements.length = 0;
|
||||
}
|
||||
|
||||
|
||||
function addRemoveClassesPostDigest(element, add, remove) {
|
||||
var data = postDigestQueue.get(element) || {};
|
||||
|
||||
var classesAdded = updateData(data, add, true);
|
||||
var classesRemoved = updateData(data, remove, false);
|
||||
|
||||
if (classesAdded || classesRemoved) {
|
||||
|
||||
postDigestQueue.put(element, data);
|
||||
postDigestElements.push(element);
|
||||
|
||||
if (postDigestElements.length === 1) {
|
||||
$rootScope.$$postDigest(handleCSSClassChanges);
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
};
|
||||
|
||||
@@ -43,6 +43,13 @@ var $CoreAnimateCssProvider = function() {
|
||||
};
|
||||
|
||||
return function(element, options) {
|
||||
// there is no point in applying the styles since
|
||||
// there is no animation that goes on at all in
|
||||
// this version of $animateCss.
|
||||
if (options.cleanupStyles) {
|
||||
options.from = options.to = null;
|
||||
}
|
||||
|
||||
if (options.from) {
|
||||
element.css(options.from);
|
||||
options.from = null;
|
||||
|
||||
+11
-6
@@ -87,7 +87,7 @@ function Browser(window, document, $log, $sniffer) {
|
||||
var cachedState, lastHistoryState,
|
||||
lastBrowserUrl = location.href,
|
||||
baseElement = document.find('base'),
|
||||
reloadLocation = null;
|
||||
pendingLocation = null;
|
||||
|
||||
cacheState();
|
||||
lastHistoryState = cachedState;
|
||||
@@ -147,8 +147,8 @@ function Browser(window, document, $log, $sniffer) {
|
||||
// Do the assignment again so that those two variables are referentially identical.
|
||||
lastHistoryState = cachedState;
|
||||
} else {
|
||||
if (!sameBase || reloadLocation) {
|
||||
reloadLocation = url;
|
||||
if (!sameBase || pendingLocation) {
|
||||
pendingLocation = url;
|
||||
}
|
||||
if (replace) {
|
||||
location.replace(url);
|
||||
@@ -157,14 +157,18 @@ function Browser(window, document, $log, $sniffer) {
|
||||
} else {
|
||||
location.hash = getHash(url);
|
||||
}
|
||||
if (location.href !== url) {
|
||||
pendingLocation = url;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
// getter
|
||||
} else {
|
||||
// - reloadLocation is needed as browsers don't allow to read out
|
||||
// the new location.href if a reload happened.
|
||||
// - pendingLocation is needed as browsers don't allow to read out
|
||||
// the new location.href if a reload happened or if there is a bug like in iOS 9 (see
|
||||
// https://openradar.appspot.com/22186109).
|
||||
// - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172
|
||||
return reloadLocation || location.href.replace(/%27/g,"'");
|
||||
return pendingLocation || location.href.replace(/%27/g,"'");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -186,6 +190,7 @@ function Browser(window, document, $log, $sniffer) {
|
||||
urlChangeInit = false;
|
||||
|
||||
function cacheStateAndFireUrlChange() {
|
||||
pendingLocation = null;
|
||||
cacheState();
|
||||
fireUrlChange();
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@
|
||||
$scope.keys = [];
|
||||
$scope.cache = $cacheFactory('cacheId');
|
||||
$scope.put = function(key, value) {
|
||||
if ($scope.cache.get(key) === undefined) {
|
||||
if (angular.isUndefined($scope.cache.get(key))) {
|
||||
$scope.keys.push(key);
|
||||
}
|
||||
$scope.cache.put(key, value === undefined ? null : value);
|
||||
$scope.cache.put(key, angular.isUndefined(value) ? null : value);
|
||||
};
|
||||
}]);
|
||||
</file>
|
||||
|
||||
+39
-18
@@ -146,18 +146,24 @@
|
||||
* and other directives used in the directive's template will also be excluded from execution.
|
||||
*
|
||||
* #### `scope`
|
||||
* **If set to `true`,** then a new scope will be created for this directive. If multiple directives on the
|
||||
* same element request a new scope, only one new scope is created. The new scope rule does not
|
||||
* apply for the root of the template since the root of the template always gets a new scope.
|
||||
* The scope property can be `true`, an object or a falsy value:
|
||||
*
|
||||
* **If set to `{}` (object hash),** then a new "isolate" scope is created. The 'isolate' scope differs from
|
||||
* normal scope in that it does not prototypically inherit from the parent scope. This is useful
|
||||
* when creating reusable components, which should not accidentally read or modify data in the
|
||||
* parent scope.
|
||||
* * **falsy:** No scope will be created for the directive. The directive will use its parent's scope.
|
||||
*
|
||||
* The 'isolate' scope takes an object hash which defines a set of local scope properties
|
||||
* derived from the parent scope. These local properties are useful for aliasing values for
|
||||
* templates. Locals definition is a hash of local scope property to its source:
|
||||
* * **`true`:** A new child scope that prototypically inherits from its parent will be created for
|
||||
* the directive's element. If multiple directives on the same element request a new scope,
|
||||
* only one new scope is created. The new scope rule does not apply for the root of the template
|
||||
* since the root of the template always gets a new scope.
|
||||
*
|
||||
* * **`{...}` (an object hash):** A new "isolate" scope is created for the directive's element. The
|
||||
* 'isolate' scope differs from normal scope in that it does not prototypically inherit from its parent
|
||||
* scope. This is useful when creating reusable components, which should not accidentally read or modify
|
||||
* data in the parent scope.
|
||||
*
|
||||
* The 'isolate' scope object hash defines a set of local scope properties derived from attributes on the
|
||||
* directive's element. These local properties are useful for aliasing values for templates. The keys in
|
||||
* the object hash map to the name of the property on the isolate scope; the values define how the property
|
||||
* is bound to the parent scope, via matching attributes on the directive's element:
|
||||
*
|
||||
* * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is
|
||||
* always a string since DOM attributes are strings. If no `attr` name is specified then the
|
||||
@@ -190,6 +196,20 @@
|
||||
* For example, if the expression is `increment(amount)` then we can specify the amount value
|
||||
* by calling the `localFn` as `localFn({amount: 22})`.
|
||||
*
|
||||
* In general it's possible to apply more than one directive to one element, but there might be limitations
|
||||
* depending on the type of scope required by the directives. The following points will help explain these limitations.
|
||||
* For simplicity only two directives are taken into account, but it is also applicable for several directives:
|
||||
*
|
||||
* * **no scope** + **no scope** => Two directives which don't require their own scope will use their parent's scope
|
||||
* * **child scope** + **no scope** => Both directives will share one single child scope
|
||||
* * **child scope** + **child scope** => Both directives will share one single child scope
|
||||
* * **isolated scope** + **no scope** => The isolated directive will use it's own created isolated scope. The other directive will use
|
||||
* its parent's scope
|
||||
* * **isolated scope** + **child scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives cannot
|
||||
* be applied to the same element.
|
||||
* * **isolated scope** + **isolated scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives
|
||||
* cannot be applied to the same element.
|
||||
*
|
||||
*
|
||||
* #### `bindToController`
|
||||
* When an isolate scope is used for a component (see above), and `controllerAs` is used, `bindToController: true` will
|
||||
@@ -198,7 +218,7 @@
|
||||
*
|
||||
* #### `controller`
|
||||
* Controller constructor function. The controller is instantiated before the
|
||||
* pre-linking phase and it is shared with other directives (see
|
||||
* pre-linking phase and can be accessed by other directives (see
|
||||
* `require` attribute). This allows the directives to communicate with each other and augment
|
||||
* each other's behavior. The controller is injectable (and supports bracket notation) with the following locals:
|
||||
*
|
||||
@@ -238,9 +258,10 @@
|
||||
*
|
||||
* #### `controllerAs`
|
||||
* Identifier name for a reference to the controller in the directive's scope.
|
||||
* This allows the controller to be referenced from the directive template. The directive
|
||||
* needs to define a scope for this configuration to be used. Useful in the case when
|
||||
* directive is used as component.
|
||||
* This allows the controller to be referenced from the directive template. This is especially
|
||||
* useful when a directive is used as component, i.e. with an `isolate` scope. It's also possible
|
||||
* to use it in a directive without an `isolate` / `new` scope, but you need to be aware that the
|
||||
* `controllerAs` reference might overwrite a property that already exists on the parent scope.
|
||||
*
|
||||
*
|
||||
* #### `restrict`
|
||||
@@ -1077,7 +1098,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
|
||||
var node = this.$$element[0],
|
||||
booleanKey = getBooleanAttrName(node, key),
|
||||
aliasedKey = getAliasedAttrName(node, key),
|
||||
aliasedKey = getAliasedAttrName(key),
|
||||
observer = key,
|
||||
nodeName;
|
||||
|
||||
@@ -1144,7 +1165,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
}
|
||||
|
||||
if (writeAttr !== false) {
|
||||
if (value === null || value === undefined) {
|
||||
if (value === null || isUndefined(value)) {
|
||||
this.$$element.removeAttr(attrName);
|
||||
} else {
|
||||
this.$$element.attr(attrName, value);
|
||||
@@ -2110,7 +2131,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
i = 0, ii = directives.length; i < ii; i++) {
|
||||
try {
|
||||
directive = directives[i];
|
||||
if ((maxPriority === undefined || maxPriority > directive.priority) &&
|
||||
if ((isUndefined(maxPriority) || maxPriority > directive.priority) &&
|
||||
directive.restrict.indexOf(location) != -1) {
|
||||
if (startAttrName) {
|
||||
directive = inherit(directive, {$$start: startAttrName, $$end: endAttrName});
|
||||
@@ -2406,7 +2427,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
compile: function() {
|
||||
return {
|
||||
pre: function attrInterpolatePreLinkFn(scope, element, attr) {
|
||||
var $$observers = (attr.$$observers || (attr.$$observers = {}));
|
||||
var $$observers = (attr.$$observers || (attr.$$observers = createMap()));
|
||||
|
||||
if (EVENT_HANDLER_ATTR_REGEXP.test(name)) {
|
||||
throw $compileMinErr('nodomevents',
|
||||
|
||||
@@ -39,7 +39,7 @@ function $$CookieReader($document) {
|
||||
// the first value that is seen for a cookie is the most
|
||||
// specific one. values for the same cookie name that
|
||||
// follow are for less specific paths.
|
||||
if (lastCookies[name] === undefined) {
|
||||
if (isUndefined(lastCookies[name])) {
|
||||
lastCookies[name] = safeDecodeURIComponent(cookie.substring(index + 1));
|
||||
}
|
||||
}
|
||||
|
||||
+38
-13
@@ -25,6 +25,7 @@ function nullFormRenameControl(control, name) {
|
||||
* @property {boolean} $dirty True if user has already interacted with the form.
|
||||
* @property {boolean} $valid True if all of the containing forms and controls are valid.
|
||||
* @property {boolean} $invalid True if at least one containing control or form is invalid.
|
||||
* @property {boolean} $pending True if at least one containing control or form is pending.
|
||||
* @property {boolean} $submitted True if user has submitted the form even if its invalid.
|
||||
*
|
||||
* @property {Object} $error Is an object hash, containing references to controls or
|
||||
@@ -64,8 +65,6 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
var form = this,
|
||||
controls = [];
|
||||
|
||||
var parentForm = form.$$parentForm = element.parent().controller('form') || nullFormCtrl;
|
||||
|
||||
// init state
|
||||
form.$error = {};
|
||||
form.$$success = {};
|
||||
@@ -76,8 +75,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
form.$valid = true;
|
||||
form.$invalid = false;
|
||||
form.$submitted = false;
|
||||
|
||||
parentForm.$addControl(form);
|
||||
form.$$parentForm = nullFormCtrl;
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
@@ -116,11 +114,23 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name form.FormController#$addControl
|
||||
* @param {object} control control object, either a {@link form.FormController} or an
|
||||
* {@link ngModel.NgModelController}
|
||||
*
|
||||
* @description
|
||||
* Register a control with the form.
|
||||
* Register a control with the form. Input elements using ngModelController do this automatically
|
||||
* when they are linked.
|
||||
*
|
||||
* Input elements using ngModelController do this automatically when they are linked.
|
||||
* Note that the current state of the control will not be reflected on the new parent form. This
|
||||
* is not an issue with normal use, as freshly compiled and linked controls are in a `$pristine`
|
||||
* state.
|
||||
*
|
||||
* However, if the method is used programmatically, for example by adding dynamically created controls,
|
||||
* or controls that have been previously removed without destroying their corresponding DOM element,
|
||||
* it's the developers responsiblity to make sure the current state propagates to the parent form.
|
||||
*
|
||||
* For example, if an input control is added that is already `$dirty` and has `$error` properties,
|
||||
* calling `$setDirty()` and `$validate()` afterwards will propagate the state to the parent form.
|
||||
*/
|
||||
form.$addControl = function(control) {
|
||||
// Breaking change - before, inputs whose name was "hasOwnProperty" were quietly ignored
|
||||
@@ -131,6 +141,8 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
if (control.$name) {
|
||||
form[control.$name] = control;
|
||||
}
|
||||
|
||||
control.$$parentForm = form;
|
||||
};
|
||||
|
||||
// Private API: rename a form control
|
||||
@@ -147,11 +159,18 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name form.FormController#$removeControl
|
||||
* @param {object} control control object, either a {@link form.FormController} or an
|
||||
* {@link ngModel.NgModelController}
|
||||
*
|
||||
* @description
|
||||
* Deregister a control from the form.
|
||||
*
|
||||
* Input elements using ngModelController do this automatically when they are destroyed.
|
||||
*
|
||||
* Note that only the removed control's validation state (`$errors`etc.) will be removed from the
|
||||
* form. `$dirty`, `$submitted` states will not be changed, because the expected behavior can be
|
||||
* different from case to case. For example, removing the only `$dirty` control from a form may or
|
||||
* may not mean that the form is still `$dirty`.
|
||||
*/
|
||||
form.$removeControl = function(control) {
|
||||
if (control.$name && form[control.$name] === control) {
|
||||
@@ -168,6 +187,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
});
|
||||
|
||||
arrayRemove(controls, control);
|
||||
control.$$parentForm = nullFormCtrl;
|
||||
};
|
||||
|
||||
|
||||
@@ -204,7 +224,6 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
delete object[property];
|
||||
}
|
||||
},
|
||||
parentForm: parentForm,
|
||||
$animate: $animate
|
||||
});
|
||||
|
||||
@@ -223,7 +242,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
$animate.addClass(element, DIRTY_CLASS);
|
||||
form.$dirty = true;
|
||||
form.$pristine = false;
|
||||
parentForm.$setDirty();
|
||||
form.$$parentForm.$setDirty();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -279,7 +298,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
form.$setSubmitted = function() {
|
||||
$animate.addClass(element, SUBMITTED_CLASS);
|
||||
form.$submitted = true;
|
||||
parentForm.$setSubmitted();
|
||||
form.$$parentForm.$setSubmitted();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -329,6 +348,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
|
||||
* # CSS classes
|
||||
* - `ng-valid` is set if the form is valid.
|
||||
* - `ng-invalid` is set if the form is invalid.
|
||||
* - `ng-pending` is set if the form is pending.
|
||||
* - `ng-pristine` is set if the form is pristine.
|
||||
* - `ng-dirty` is set if the form is dirty.
|
||||
* - `ng-submitted` is set if the form was submitted.
|
||||
@@ -452,6 +472,7 @@ var formDirectiveFactory = function(isNgForm) {
|
||||
var formDirective = {
|
||||
name: 'form',
|
||||
restrict: isNgForm ? 'EAC' : 'E',
|
||||
require: ['form', '^^?form'], //first is the form's own ctrl, second is an optional parent form
|
||||
controller: FormController,
|
||||
compile: function ngFormCompile(formElement, attr) {
|
||||
// Setup initial state of the control
|
||||
@@ -460,7 +481,9 @@ var formDirectiveFactory = function(isNgForm) {
|
||||
var nameAttr = attr.name ? 'name' : (isNgForm && attr.ngForm ? 'ngForm' : false);
|
||||
|
||||
return {
|
||||
pre: function ngFormPreLink(scope, formElement, attr, controller) {
|
||||
pre: function ngFormPreLink(scope, formElement, attr, ctrls) {
|
||||
var controller = ctrls[0];
|
||||
|
||||
// if `action` attr is not present on the form, prevent the default action (submission)
|
||||
if (!('action' in attr)) {
|
||||
// we can't use jq events because if a form is destroyed during submission the default
|
||||
@@ -489,7 +512,9 @@ var formDirectiveFactory = function(isNgForm) {
|
||||
});
|
||||
}
|
||||
|
||||
var parentFormCtrl = controller.$$parentForm;
|
||||
var parentFormCtrl = ctrls[1] || controller.$$parentForm;
|
||||
parentFormCtrl.$addControl(controller);
|
||||
|
||||
var setter = nameAttr ? getSetter(controller.$name) : noop;
|
||||
|
||||
if (nameAttr) {
|
||||
@@ -497,13 +522,13 @@ var formDirectiveFactory = function(isNgForm) {
|
||||
attr.$observe(nameAttr, function(newValue) {
|
||||
if (controller.$name === newValue) return;
|
||||
setter(scope, undefined);
|
||||
parentFormCtrl.$$renameControl(controller, newValue);
|
||||
controller.$$parentForm.$$renameControl(controller, newValue);
|
||||
setter = getSetter(controller.$name);
|
||||
setter(scope, controller);
|
||||
});
|
||||
}
|
||||
formElement.on('$destroy', function() {
|
||||
parentFormCtrl.$removeControl(controller);
|
||||
controller.$$parentForm.$removeControl(controller);
|
||||
setter(scope, undefined);
|
||||
extend(controller, nullFormCtrl); //stop propagating child destruction handlers upwards
|
||||
});
|
||||
|
||||
+60
-19
@@ -138,9 +138,17 @@ var inputType = {
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a
|
||||
* valid ISO date string (yyyy-MM-dd).
|
||||
* valid ISO date string (yyyy-MM-dd). You can also use interpolation inside this attribute
|
||||
* (e.g. `min="{{minDate | date:'yyyy-MM-dd'}}"`). Note that `min` will also add native HTML5
|
||||
* constraint validation.
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be
|
||||
* a valid ISO date string (yyyy-MM-dd).
|
||||
* a valid ISO date string (yyyy-MM-dd). You can also use interpolation inside this attribute
|
||||
* (e.g. `max="{{maxDate | date:'yyyy-MM-dd'}}"`). Note that `max` will also add native HTML5
|
||||
* constraint validation.
|
||||
* @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO date string
|
||||
* the `ngMin` expression evaluates to. Note that it does not set the `min` attribute.
|
||||
* @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO date string
|
||||
* the `ngMax` expression evaluates to. Note that it does not set the `max` attribute.
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
@@ -232,10 +240,18 @@ var inputType = {
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a
|
||||
* valid ISO datetime format (yyyy-MM-ddTHH:mm:ss).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be
|
||||
* a valid ISO datetime format (yyyy-MM-ddTHH:mm:ss).
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.
|
||||
* This must be a valid ISO datetime format (yyyy-MM-ddTHH:mm:ss). You can also use interpolation
|
||||
* inside this attribute (e.g. `min="{{minDatetimeLocal | date:'yyyy-MM-ddTHH:mm:ss'}}"`).
|
||||
* Note that `min` will also add native HTML5 constraint validation.
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.
|
||||
* This must be a valid ISO datetime format (yyyy-MM-ddTHH:mm:ss). You can also use interpolation
|
||||
* inside this attribute (e.g. `max="{{maxDatetimeLocal | date:'yyyy-MM-ddTHH:mm:ss'}}"`).
|
||||
* Note that `max` will also add native HTML5 constraint validation.
|
||||
* @param {(date|string)=} ngMin Sets the `min` validation error key to the Date / ISO datetime string
|
||||
* the `ngMin` expression evaluates to. Note that it does not set the `min` attribute.
|
||||
* @param {(date|string)=} ngMax Sets the `max` validation error key to the Date / ISO datetime string
|
||||
* the `ngMax` expression evaluates to. Note that it does not set the `max` attribute.
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
@@ -328,10 +344,18 @@ var inputType = {
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a
|
||||
* valid ISO time format (HH:mm:ss).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be a
|
||||
* valid ISO time format (HH:mm:ss).
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.
|
||||
* This must be a valid ISO time format (HH:mm:ss). You can also use interpolation inside this
|
||||
* attribute (e.g. `min="{{minTime | date:'HH:mm:ss'}}"`). Note that `min` will also add
|
||||
* native HTML5 constraint validation.
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.
|
||||
* This must be a valid ISO time format (HH:mm:ss). You can also use interpolation inside this
|
||||
* attribute (e.g. `max="{{maxTime | date:'HH:mm:ss'}}"`). Note that `max` will also add
|
||||
* native HTML5 constraint validation.
|
||||
* @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO time string the
|
||||
* `ngMin` expression evaluates to. Note that it does not set the `min` attribute.
|
||||
* @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO time string the
|
||||
* `ngMax` expression evaluates to. Note that it does not set the `max` attribute.
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
@@ -423,10 +447,18 @@ var inputType = {
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a
|
||||
* valid ISO week format (yyyy-W##).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be
|
||||
* a valid ISO week format (yyyy-W##).
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.
|
||||
* This must be a valid ISO week format (yyyy-W##). You can also use interpolation inside this
|
||||
* attribute (e.g. `min="{{minWeek | date:'yyyy-Www'}}"`). Note that `min` will also add
|
||||
* native HTML5 constraint validation.
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.
|
||||
* This must be a valid ISO week format (yyyy-W##). You can also use interpolation inside this
|
||||
* attribute (e.g. `max="{{maxWeek | date:'yyyy-Www'}}"`). Note that `max` will also add
|
||||
* native HTML5 constraint validation.
|
||||
* @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO week string
|
||||
* the `ngMin` expression evaluates to. Note that it does not set the `min` attribute.
|
||||
* @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO week string
|
||||
* the `ngMax` expression evaluates to. Note that it does not set the `max` attribute.
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
@@ -520,10 +552,19 @@ var inputType = {
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be
|
||||
* a valid ISO month format (yyyy-MM).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must
|
||||
* be a valid ISO month format (yyyy-MM).
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.
|
||||
* This must be a valid ISO month format (yyyy-MM). You can also use interpolation inside this
|
||||
* attribute (e.g. `min="{{minMonth | date:'yyyy-MM'}}"`). Note that `min` will also add
|
||||
* native HTML5 constraint validation.
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.
|
||||
* This must be a valid ISO month format (yyyy-MM). You can also use interpolation inside this
|
||||
* attribute (e.g. `max="{{maxMonth | date:'yyyy-MM'}}"`). Note that `max` will also add
|
||||
* native HTML5 constraint validation.
|
||||
* @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO week string
|
||||
* the `ngMin` expression evaluates to. Note that it does not set the `min` attribute.
|
||||
* @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO week string
|
||||
* the `ngMax` expression evaluates to. Note that it does not set the `max` attribute.
|
||||
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
@@ -1285,7 +1326,7 @@ function createDateInputType(type, regexp, parseDate, format) {
|
||||
}
|
||||
|
||||
function parseObservedDateValue(val) {
|
||||
return isDefined(val) ? (isDate(val) ? val : parseDate(val)) : undefined;
|
||||
return isDefined(val) && !isDate(val) ? parseDate(val) || undefined : val;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ var ngBindDirective = ['$compile', function($compile) {
|
||||
$compile.$$addBindingInfo(element, attr.ngBind);
|
||||
element = element[0];
|
||||
scope.$watch(attr.ngBind, function ngBindWatchAction(value) {
|
||||
element.textContent = value === undefined ? '' : value;
|
||||
element.textContent = isUndefined(value) ? '' : value;
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -128,7 +128,7 @@ var ngBindTemplateDirective = ['$interpolate', '$compile', function($interpolate
|
||||
$compile.$$addBindingInfo(element, interpolateFn.expressions);
|
||||
element = element[0];
|
||||
attr.$observe('ngBindTemplate', function(value) {
|
||||
element.textContent = value === undefined ? '' : value;
|
||||
element.textContent = isUndefined(value) ? '' : value;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,16 +10,18 @@
|
||||
* current scope.
|
||||
*
|
||||
* <div class="alert alert-danger">
|
||||
* The only appropriate use of `ngInit` is for aliasing special properties of
|
||||
* {@link ng.directive:ngRepeat `ngRepeat`}, as seen in the demo below. Besides this case, you
|
||||
* should use {@link guide/controller controllers} rather than `ngInit`
|
||||
* to initialize values on a scope.
|
||||
* This directive can be abused to add unnecessary amounts of logic into your templates.
|
||||
* There are only a few appropriate uses of `ngInit`, such as for aliasing special properties of
|
||||
* {@link ng.directive:ngRepeat `ngRepeat`}, as seen in the demo below; and for injecting data via
|
||||
* server side scripting. Besides these few cases, you should use {@link guide/controller controllers}
|
||||
* rather than `ngInit` to initialize values on a scope.
|
||||
* </div>
|
||||
*
|
||||
* <div class="alert alert-warning">
|
||||
* **Note**: If you have assignment in `ngInit` along with {@link ng.$filter `$filter`}, make
|
||||
* sure you have parenthesis for correct precedence:
|
||||
* **Note**: If you have assignment in `ngInit` along with a {@link ng.$filter `filter`}, make
|
||||
* sure you have parentheses to ensure correct operator precedence:
|
||||
* <pre class="prettyprint">
|
||||
* `<div ng-init="test1 = (data | orderBy:'name')"></div>`
|
||||
* `<div ng-init="test1 = ($index | toString)"></div>`
|
||||
* </pre>
|
||||
* </div>
|
||||
*
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
* </file>
|
||||
* </example>
|
||||
*
|
||||
* ### Example - splitting on whitespace
|
||||
* ### Example - splitting on newline
|
||||
* <example name="ngList-directive-newlines">
|
||||
* <file name="index.html">
|
||||
* <textarea ng-model="list" ng-list=" " ng-trim="false"></textarea>
|
||||
|
||||
+43
-34
@@ -22,7 +22,9 @@ var ngModelMinErr = minErr('ngModel');
|
||||
* @ngdoc type
|
||||
* @name ngModel.NgModelController
|
||||
*
|
||||
* @property {string} $viewValue Actual string value in the view.
|
||||
* @property {*} $viewValue The actual value from the control's view. For `input` elements, this is a
|
||||
* String. See {@link ngModel.NgModelController#$setViewValue} for information about when the $viewValue
|
||||
* is set.
|
||||
* @property {*} $modelValue The value in the model that the control is bound to.
|
||||
* @property {Array.<Function>} $parsers Array of functions to execute, as a pipeline, whenever
|
||||
the control reads value from the DOM. The functions are called in array order, each passing
|
||||
@@ -236,7 +238,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
|
||||
this.$$success = {}; // keep valid keys here
|
||||
this.$pending = undefined; // keep pending keys here
|
||||
this.$name = $interpolate($attr.name || '', false)($scope);
|
||||
|
||||
this.$$parentForm = nullFormCtrl;
|
||||
|
||||
var parsedNgModel = $parse($attr.ngModel),
|
||||
parsedNgModelAssign = parsedNgModel.assign,
|
||||
@@ -316,8 +318,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
|
||||
return isUndefined(value) || value === '' || value === null || value !== value;
|
||||
};
|
||||
|
||||
var parentForm = $element.inheritedData('$formController') || nullFormCtrl,
|
||||
currentValidationRunId = 0;
|
||||
var currentValidationRunId = 0;
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
@@ -350,7 +351,6 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
|
||||
unset: function(object, property) {
|
||||
delete object[property];
|
||||
},
|
||||
parentForm: parentForm,
|
||||
$animate: $animate
|
||||
});
|
||||
|
||||
@@ -388,7 +388,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
|
||||
ctrl.$pristine = false;
|
||||
$animate.removeClass($element, PRISTINE_CLASS);
|
||||
$animate.addClass($element, DIRTY_CLASS);
|
||||
parentForm.$setDirty();
|
||||
ctrl.$$parentForm.$setDirty();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -558,7 +558,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
|
||||
|
||||
function processParseErrors() {
|
||||
var errorKey = ctrl.$$parserName || 'parse';
|
||||
if (parserValid === undefined) {
|
||||
if (isUndefined(parserValid)) {
|
||||
setValidity(errorKey, null);
|
||||
} else {
|
||||
if (!parserValid) {
|
||||
@@ -728,37 +728,47 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
|
||||
* @description
|
||||
* Update the view value.
|
||||
*
|
||||
* This method should be called when an input directive want to change the view value; typically,
|
||||
* this is done from within a DOM event handler.
|
||||
* This method should be called when a control wants to change the view value; typically,
|
||||
* this is done from within a DOM event handler. For example, the {@link ng.directive:input input}
|
||||
* directive calls it when the value of the input changes and {@link ng.directive:select select}
|
||||
* calls it when an option is selected.
|
||||
*
|
||||
* For example {@link ng.directive:input input} calls it when the value of the input changes and
|
||||
* {@link ng.directive:select select} calls it when an option is selected.
|
||||
*
|
||||
* If the new `value` is an object (rather than a string or a number), we should make a copy of the
|
||||
* object before passing it to `$setViewValue`. This is because `ngModel` does not perform a deep
|
||||
* watch of objects, it only looks for a change of identity. If you only change the property of
|
||||
* the object then ngModel will not realise that the object has changed and will not invoke the
|
||||
* `$parsers` and `$validators` pipelines.
|
||||
*
|
||||
* For this reason, you should not change properties of the copy once it has been passed to
|
||||
* `$setViewValue`. Otherwise you may cause the model value on the scope to change incorrectly.
|
||||
*
|
||||
* When this method is called, the new `value` will be staged for committing through the `$parsers`
|
||||
* When `$setViewValue` is called, the new `value` will be staged for committing through the `$parsers`
|
||||
* and `$validators` pipelines. If there are no special {@link ngModelOptions} specified then the staged
|
||||
* value sent directly for processing, finally to be applied to `$modelValue` and then the
|
||||
* **expression** specified in the `ng-model` attribute.
|
||||
*
|
||||
* Lastly, all the registered change listeners, in the `$viewChangeListeners` list, are called.
|
||||
* **expression** specified in the `ng-model` attribute. Lastly, all the registered change listeners,
|
||||
* in the `$viewChangeListeners` list, are called.
|
||||
*
|
||||
* In case the {@link ng.directive:ngModelOptions ngModelOptions} directive is used with `updateOn`
|
||||
* and the `default` trigger is not listed, all those actions will remain pending until one of the
|
||||
* `updateOn` events is triggered on the DOM element.
|
||||
* All these actions will be debounced if the {@link ng.directive:ngModelOptions ngModelOptions}
|
||||
* directive is used with a custom debounce for this particular event.
|
||||
* Note that a `$digest` is only triggered once the `updateOn` events are fired, or if `debounce`
|
||||
* is specified, once the timer runs out.
|
||||
*
|
||||
* Note that calling this function does not trigger a `$digest`.
|
||||
* When used with standard inputs, the view value will always be a string (which is in some cases
|
||||
* parsed into another type, such as a `Date` object for `input[date]`.)
|
||||
* However, custom controls might also pass objects to this method. In this case, we should make
|
||||
* a copy of the object before passing it to `$setViewValue`. This is because `ngModel` does not
|
||||
* perform a deep watch of objects, it only looks for a change of identity. If you only change
|
||||
* the property of the object then ngModel will not realise that the object has changed and
|
||||
* will not invoke the `$parsers` and `$validators` pipelines. For this reason, you should
|
||||
* not change properties of the copy once it has been passed to `$setViewValue`.
|
||||
* Otherwise you may cause the model value on the scope to change incorrectly.
|
||||
*
|
||||
* @param {string} value Value from the view.
|
||||
* <div class="alert alert-info">
|
||||
* In any case, the value passed to the method should always reflect the current value
|
||||
* of the control. For example, if you are calling `$setViewValue` for an input element,
|
||||
* you should pass the input DOM value. Otherwise, the control and the scope model become
|
||||
* out of sync. It's also important to note that `$setViewValue` does not call `$render` or change
|
||||
* the control's DOM value in any way. If we want to change the control's DOM value
|
||||
* programmatically, we should update the `ngModel` scope expression. Its new value will be
|
||||
* picked up by the model controller, which will run it through the `$formatters`, `$render` it
|
||||
* to update the DOM, and finally call `$validate` on it.
|
||||
* </div>
|
||||
*
|
||||
* @param {*} value value from the view.
|
||||
* @param {string} trigger Event that triggered the update.
|
||||
*/
|
||||
this.$setViewValue = function(value, trigger) {
|
||||
@@ -1021,7 +1031,7 @@ var ngModelDirective = ['$rootScope', function($rootScope) {
|
||||
return {
|
||||
pre: function ngModelPreLink(scope, element, attr, ctrls) {
|
||||
var modelCtrl = ctrls[0],
|
||||
formCtrl = ctrls[1] || nullFormCtrl;
|
||||
formCtrl = ctrls[1] || modelCtrl.$$parentForm;
|
||||
|
||||
modelCtrl.$$setOptions(ctrls[2] && ctrls[2].$options);
|
||||
|
||||
@@ -1030,12 +1040,12 @@ var ngModelDirective = ['$rootScope', function($rootScope) {
|
||||
|
||||
attr.$observe('name', function(newValue) {
|
||||
if (modelCtrl.$name !== newValue) {
|
||||
formCtrl.$$renameControl(modelCtrl, newValue);
|
||||
modelCtrl.$$parentForm.$$renameControl(modelCtrl, newValue);
|
||||
}
|
||||
});
|
||||
|
||||
scope.$on('$destroy', function() {
|
||||
formCtrl.$removeControl(modelCtrl);
|
||||
modelCtrl.$$parentForm.$removeControl(modelCtrl);
|
||||
});
|
||||
},
|
||||
post: function ngModelPostLink(scope, element, attr, ctrls) {
|
||||
@@ -1234,7 +1244,7 @@ var ngModelOptionsDirective = function() {
|
||||
var that = this;
|
||||
this.$options = copy($scope.$eval($attrs.ngModelOptions));
|
||||
// Allow adding/overriding bound events
|
||||
if (this.$options.updateOn !== undefined) {
|
||||
if (isDefined(this.$options.updateOn)) {
|
||||
this.$options.updateOnDefault = false;
|
||||
// extract "default" pseudo-event from list of events that can trigger a model update
|
||||
this.$options.updateOn = trim(this.$options.updateOn.replace(DEFAULT_REGEXP, function() {
|
||||
@@ -1257,7 +1267,6 @@ function addSetValidityMethod(context) {
|
||||
classCache = {},
|
||||
set = context.set,
|
||||
unset = context.unset,
|
||||
parentForm = context.parentForm,
|
||||
$animate = context.$animate;
|
||||
|
||||
classCache[INVALID_CLASS] = !(classCache[VALID_CLASS] = $element.hasClass(VALID_CLASS));
|
||||
@@ -1265,7 +1274,7 @@ function addSetValidityMethod(context) {
|
||||
ctrl.$setValidity = setValidity;
|
||||
|
||||
function setValidity(validationErrorKey, state, controller) {
|
||||
if (state === undefined) {
|
||||
if (isUndefined(state)) {
|
||||
createAndSet('$pending', validationErrorKey, controller);
|
||||
} else {
|
||||
unsetAndCleanup('$pending', validationErrorKey, controller);
|
||||
@@ -1309,7 +1318,7 @@ function addSetValidityMethod(context) {
|
||||
}
|
||||
|
||||
toggleValidationCss(validationErrorKey, combinedState);
|
||||
parentForm.$setValidity(validationErrorKey, combinedState, ctrl);
|
||||
ctrl.$$parentForm.$setValidity(validationErrorKey, combinedState, ctrl);
|
||||
}
|
||||
|
||||
function createAndSet(name, value, controller) {
|
||||
|
||||
@@ -579,11 +579,16 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {
|
||||
function updateOptionElement(option, element) {
|
||||
option.element = element;
|
||||
element.disabled = option.disabled;
|
||||
if (option.value !== element.value) element.value = option.selectValue;
|
||||
// NOTE: The label must be set before the value, otherwise IE10/11/EDGE create unresponsive
|
||||
// selects in certain circumstances when multiple selects are next to each other and display
|
||||
// the option list in listbox style, i.e. the select is [multiple], or specifies a [size].
|
||||
// See https://github.com/angular/angular.js/issues/11314 for more info.
|
||||
// This is unfortunately untestable with unit / e2e tests
|
||||
if (option.label !== element.label) {
|
||||
element.label = option.label;
|
||||
element.textContent = option.label;
|
||||
}
|
||||
if (option.value !== element.value) element.value = option.selectValue;
|
||||
}
|
||||
|
||||
function addOrReuseElement(parent, current, type, templateElement) {
|
||||
@@ -624,7 +629,10 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {
|
||||
if (emptyOption_ || unknownOption_) {
|
||||
while (current &&
|
||||
(current === emptyOption_ ||
|
||||
current === unknownOption_)) {
|
||||
current === unknownOption_ ||
|
||||
emptyOption_ && emptyOption_.nodeType === NODE_TYPE_COMMENT)) {
|
||||
// Empty options might have directives that transclude
|
||||
// and insert comments (e.g. ngIf)
|
||||
current = current.nextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,10 @@
|
||||
* | `$even` | {@type boolean} | true if the iterator position `$index` is even (otherwise false). |
|
||||
* | `$odd` | {@type boolean} | true if the iterator position `$index` is odd (otherwise false). |
|
||||
*
|
||||
* Creating aliases for these properties is possible with {@link ng.directive:ngInit `ngInit`}.
|
||||
* This may be useful when, for instance, nesting ngRepeats.
|
||||
* <div class="alert alert-info">
|
||||
* Creating aliases for these properties is possible with {@link ng.directive:ngInit `ngInit`}.
|
||||
* This may be useful when, for instance, nesting ngRepeats.
|
||||
* </div>
|
||||
*
|
||||
*
|
||||
* # Iterating over object properties
|
||||
@@ -427,7 +429,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
|
||||
// if object, extract keys, in enumeration order, unsorted
|
||||
collectionKeys = [];
|
||||
for (var itemKey in collection) {
|
||||
if (collection.hasOwnProperty(itemKey) && itemKey.charAt(0) !== '$') {
|
||||
if (hasOwnProperty.call(collection, itemKey) && itemKey.charAt(0) !== '$') {
|
||||
collectionKeys.push(itemKey);
|
||||
}
|
||||
}
|
||||
|
||||
+30
-13
@@ -166,7 +166,7 @@ var SelectController =
|
||||
* </select><br>
|
||||
*
|
||||
* <label for="singleSelect"> Single select with "not selected" option and dynamic option values: </label><br>
|
||||
* <select name="singleSelect" ng-model="data.singleSelect">
|
||||
* <select name="singleSelect" id="singleSelect" ng-model="data.singleSelect">
|
||||
* <option value="">---Please select---</option> <!-- not selected / blank option -->
|
||||
* <option value="{{data.option1}}">Option 1</option> <!-- interpolation -->
|
||||
* <option value="option-2">Option 2</option>
|
||||
@@ -207,7 +207,7 @@ var SelectController =
|
||||
* <div ng-controller="ExampleController">
|
||||
* <form name="myForm">
|
||||
* <label for="repeatSelect"> Repeat select: </label>
|
||||
* <select name="repeatSelect" ng-model="data.repeatSelect">
|
||||
* <select name="repeatSelect" id="repeatSelect" ng-model="data.repeatSelect">
|
||||
* <option ng-repeat="option in data.availableOptions" value="{{option.id}}">{{option.name}}</option>
|
||||
* </select>
|
||||
* </form>
|
||||
@@ -219,7 +219,7 @@ var SelectController =
|
||||
* angular.module('ngrepeatSelect', [])
|
||||
* .controller('ExampleController', ['$scope', function($scope) {
|
||||
* $scope.data = {
|
||||
* singleSelect: null,
|
||||
* repeatSelect: null,
|
||||
* availableOptions: [
|
||||
* {id: '1', name: 'Option A'},
|
||||
* {id: '2', name: 'Option B'},
|
||||
@@ -401,9 +401,12 @@ var optionDirective = ['$interpolate', function($interpolate) {
|
||||
priority: 100,
|
||||
compile: function(element, attr) {
|
||||
|
||||
// If the value attribute is not defined then we fall back to the
|
||||
// text content of the option element, which may be interpolated
|
||||
if (isUndefined(attr.value)) {
|
||||
if (isDefined(attr.value)) {
|
||||
// If the value attribute is defined, check if it contains an interpolation
|
||||
var valueInterpolated = $interpolate(attr.value, true);
|
||||
} else {
|
||||
// If the value attribute is not defined then we fall back to the
|
||||
// text content of the option element, which may be interpolated
|
||||
var interpolateFn = $interpolate(element.text(), true);
|
||||
if (!interpolateFn) {
|
||||
attr.$set('value', element.text());
|
||||
@@ -419,24 +422,38 @@ var optionDirective = ['$interpolate', function($interpolate) {
|
||||
selectCtrl = parent.data(selectCtrlName) ||
|
||||
parent.parent().data(selectCtrlName); // in case we are in optgroup
|
||||
|
||||
function addOption(optionValue) {
|
||||
selectCtrl.addOption(optionValue, element);
|
||||
selectCtrl.ngModelCtrl.$render();
|
||||
chromeHack(element);
|
||||
}
|
||||
|
||||
// Only update trigger option updates if this is an option within a `select`
|
||||
// that also has `ngModel` attached
|
||||
if (selectCtrl && selectCtrl.ngModelCtrl) {
|
||||
|
||||
if (interpolateFn) {
|
||||
if (valueInterpolated) {
|
||||
// The value attribute is interpolated
|
||||
var oldVal;
|
||||
attr.$observe('value', function valueAttributeObserveAction(newVal) {
|
||||
if (isDefined(oldVal)) {
|
||||
selectCtrl.removeOption(oldVal);
|
||||
}
|
||||
oldVal = newVal;
|
||||
addOption(newVal);
|
||||
});
|
||||
} else if (interpolateFn) {
|
||||
// The text content is interpolated
|
||||
scope.$watch(interpolateFn, function interpolateWatchAction(newVal, oldVal) {
|
||||
attr.$set('value', newVal);
|
||||
if (oldVal !== newVal) {
|
||||
selectCtrl.removeOption(oldVal);
|
||||
}
|
||||
selectCtrl.addOption(newVal, element);
|
||||
selectCtrl.ngModelCtrl.$render();
|
||||
chromeHack(element);
|
||||
addOption(newVal);
|
||||
});
|
||||
} else {
|
||||
selectCtrl.addOption(attr.value, element);
|
||||
selectCtrl.ngModelCtrl.$render();
|
||||
chromeHack(element);
|
||||
// The value attribute is static
|
||||
addOption(attr.value);
|
||||
}
|
||||
|
||||
element.on('$destroy', function() {
|
||||
|
||||
@@ -214,6 +214,7 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
|
||||
if (fractionSize > 0 && number < 1) {
|
||||
formatedText = number.toFixed(fractionSize);
|
||||
number = parseFloat(formatedText);
|
||||
formatedText = formatedText.replace(DECIMAL_SEP, decimalSep);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-33
@@ -425,28 +425,18 @@ function $HttpProvider() {
|
||||
*
|
||||
*
|
||||
* ## General usage
|
||||
* The `$http` service is a function which takes a single argument — a configuration object —
|
||||
* The `$http` service is a function which takes a single argument — a {@link $http#usage configuration object} —
|
||||
* that is used to generate an HTTP request and returns a {@link ng.$q promise}.
|
||||
*
|
||||
* ```js
|
||||
* // Simple GET request example :
|
||||
* $http.get('/someUrl').
|
||||
* then(function(response) {
|
||||
* // Simple GET request example:
|
||||
* $http({
|
||||
* method: 'GET',
|
||||
* url: '/someUrl'
|
||||
* }).then(function successCallback(response) {
|
||||
* // this callback will be called asynchronously
|
||||
* // when the response is available
|
||||
* }, function(response) {
|
||||
* // called asynchronously if an error occurs
|
||||
* // or server returns response with an error status.
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* // Simple POST request example (passing data) :
|
||||
* $http.post('/someUrl', {msg:'hello word!'}).
|
||||
* then(function(response) {
|
||||
* // this callback will be called asynchronously
|
||||
* // when the response is available
|
||||
* }, function(response) {
|
||||
* }, function errorCallback(response) {
|
||||
* // called asynchronously if an error occurs
|
||||
* // or server returns response with an error status.
|
||||
* });
|
||||
@@ -466,25 +456,16 @@ function $HttpProvider() {
|
||||
* XMLHttpRequest will transparently follow it, meaning that the error callback will not be
|
||||
* called for such responses.
|
||||
*
|
||||
* ## Writing Unit Tests that use $http
|
||||
* When unit testing (using {@link ngMock ngMock}), it is necessary to call
|
||||
* {@link ngMock.$httpBackend#flush $httpBackend.flush()} to flush each pending
|
||||
* request using trained responses.
|
||||
*
|
||||
* ```
|
||||
* $httpBackend.expectGET(...);
|
||||
* $http.get(...);
|
||||
* $httpBackend.flush();
|
||||
* ```
|
||||
*
|
||||
* ## Shortcut methods
|
||||
*
|
||||
* Shortcut methods are also available. All shortcut methods require passing in the URL, and
|
||||
* request data must be passed in for POST/PUT requests.
|
||||
* request data must be passed in for POST/PUT requests. An optional config can be passed as the
|
||||
* last argument.
|
||||
*
|
||||
* ```js
|
||||
* $http.get('/someUrl').then(successCallback);
|
||||
* $http.post('/someUrl', data).then(successCallback);
|
||||
* $http.get('/someUrl', config).then(successCallback, errorCallback);
|
||||
* $http.post('/someUrl', data, config).then(successCallback, errorCallback);
|
||||
* ```
|
||||
*
|
||||
* Complete list of shortcut methods:
|
||||
@@ -498,6 +479,17 @@ function $HttpProvider() {
|
||||
* - {@link ng.$http#patch $http.patch}
|
||||
*
|
||||
*
|
||||
* ## Writing Unit Tests that use $http
|
||||
* When unit testing (using {@link ngMock ngMock}), it is necessary to call
|
||||
* {@link ngMock.$httpBackend#flush $httpBackend.flush()} to flush each pending
|
||||
* request using trained responses.
|
||||
*
|
||||
* ```
|
||||
* $httpBackend.expectGET(...);
|
||||
* $http.get(...);
|
||||
* $httpBackend.flush();
|
||||
* ```
|
||||
*
|
||||
* ## Deprecation Notice
|
||||
* <div class="alert alert-danger">
|
||||
* The `$http` legacy promise methods `success` and `error` have been deprecated.
|
||||
@@ -655,7 +647,7 @@ function $HttpProvider() {
|
||||
*
|
||||
* There are two kinds of interceptors (and two kinds of rejection interceptors):
|
||||
*
|
||||
* * `request`: interceptors get called with a http `config` object. The function is free to
|
||||
* * `request`: interceptors get called with a http {@link $http#usage config} object. The function is free to
|
||||
* modify the `config` object or create a new one. The function needs to return the `config`
|
||||
* object directly, or a promise containing the `config` or a new `config` object.
|
||||
* * `requestError`: interceptor gets called when a previous interceptor threw an error or
|
||||
@@ -1289,8 +1281,8 @@ function $HttpProvider() {
|
||||
* Resolves the raw $http promise.
|
||||
*/
|
||||
function resolvePromise(response, status, headers, statusText) {
|
||||
// normalize internal statuses to 0
|
||||
status = Math.max(status, 0);
|
||||
//status: HTTP response status code, 0, -1 (aborted by timeout / promise)
|
||||
status = status >= -1 ? status : 0;
|
||||
|
||||
(isSuccess(status) ? deferred.resolve : deferred.reject)({
|
||||
data: response,
|
||||
|
||||
+33
-7
@@ -1,7 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
function createXhr() {
|
||||
return new window.XMLHttpRequest();
|
||||
/**
|
||||
* @ngdoc service
|
||||
* @name $xhrFactory
|
||||
*
|
||||
* @description
|
||||
* Factory function used to create XMLHttpRequest objects.
|
||||
*
|
||||
* Replace or decorate this service to create your own custom XMLHttpRequest objects.
|
||||
*
|
||||
* ```
|
||||
* angular.module('myApp', [])
|
||||
* .factory('$xhrFactory', function() {
|
||||
* return function createXhr(method, url) {
|
||||
* return new window.XMLHttpRequest({mozSystem: true});
|
||||
* };
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param {string} method HTTP method of the request (GET, POST, PUT, ..)
|
||||
* @param {string} url URL of the request.
|
||||
*/
|
||||
function $xhrFactoryProvider() {
|
||||
this.$get = function() {
|
||||
return function createXhr() {
|
||||
return new window.XMLHttpRequest();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -9,6 +34,7 @@ function createXhr() {
|
||||
* @name $httpBackend
|
||||
* @requires $window
|
||||
* @requires $document
|
||||
* @requires $xhrFactory
|
||||
*
|
||||
* @description
|
||||
* HTTP backend used by the {@link ng.$http service} that delegates to
|
||||
@@ -21,8 +47,8 @@ function createXhr() {
|
||||
* $httpBackend} which can be trained with responses.
|
||||
*/
|
||||
function $HttpBackendProvider() {
|
||||
this.$get = ['$browser', '$window', '$document', function($browser, $window, $document) {
|
||||
return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]);
|
||||
this.$get = ['$browser', '$window', '$document', '$xhrFactory', function($browser, $window, $document, $xhrFactory) {
|
||||
return createHttpBackend($browser, $xhrFactory, $browser.defer, $window.angular.callbacks, $document[0]);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -46,7 +72,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
|
||||
});
|
||||
} else {
|
||||
|
||||
var xhr = createXhr();
|
||||
var xhr = createXhr(method, url);
|
||||
|
||||
xhr.open(method, url, true);
|
||||
forEach(headers, function(value, key) {
|
||||
@@ -109,7 +135,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
|
||||
}
|
||||
}
|
||||
|
||||
xhr.send(post);
|
||||
xhr.send(isUndefined(post) ? null : post);
|
||||
}
|
||||
|
||||
if (timeout > 0) {
|
||||
@@ -126,7 +152,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
|
||||
|
||||
function completeRequest(callback, status, response, headersString, statusText) {
|
||||
// cancel timeout and subsequent timeout promise resolution
|
||||
if (timeoutId !== undefined) {
|
||||
if (isDefined(timeoutId)) {
|
||||
$browserDefer.cancel(timeoutId);
|
||||
}
|
||||
jsonpDone = xhr = null;
|
||||
|
||||
@@ -139,7 +139,7 @@ function $InterpolateProvider() {
|
||||
* ```js
|
||||
* var $interpolate = ...; // injected
|
||||
* var exp = $interpolate('Hello {{name | uppercase}}!');
|
||||
* expect(exp({name:'Angular'}).toEqual('Hello ANGULAR!');
|
||||
* expect(exp({name:'Angular'})).toEqual('Hello ANGULAR!');
|
||||
* ```
|
||||
*
|
||||
* `$interpolate` takes an optional fourth argument, `allOrNothing`. If `allOrNothing` is
|
||||
|
||||
+3
-3
@@ -141,14 +141,14 @@ function LocationHtml5Url(appBase, appBaseNoFile, basePrefix) {
|
||||
var appUrl, prevAppUrl;
|
||||
var rewrittenUrl;
|
||||
|
||||
if ((appUrl = beginsWith(appBase, url)) !== undefined) {
|
||||
if (isDefined(appUrl = beginsWith(appBase, url))) {
|
||||
prevAppUrl = appUrl;
|
||||
if ((appUrl = beginsWith(basePrefix, appUrl)) !== undefined) {
|
||||
if (isDefined(appUrl = beginsWith(basePrefix, appUrl))) {
|
||||
rewrittenUrl = appBaseNoFile + (beginsWith('/', appUrl) || appUrl);
|
||||
} else {
|
||||
rewrittenUrl = appBase + prevAppUrl;
|
||||
}
|
||||
} else if ((appUrl = beginsWith(appBaseNoFile, url)) !== undefined) {
|
||||
} else if (isDefined(appUrl = beginsWith(appBaseNoFile, url))) {
|
||||
rewrittenUrl = appBaseNoFile + appUrl;
|
||||
} else if (appBaseNoFile == url + '/') {
|
||||
rewrittenUrl = appBaseNoFile;
|
||||
|
||||
@@ -48,6 +48,25 @@ function ensureSafeMemberName(name, fullExpression) {
|
||||
return name;
|
||||
}
|
||||
|
||||
function getStringValue(name, fullExpression) {
|
||||
// From the JavaScript docs:
|
||||
// Property names must be strings. This means that non-string objects cannot be used
|
||||
// as keys in an object. Any non-string object, including a number, is typecasted
|
||||
// into a string via the toString method.
|
||||
//
|
||||
// So, to ensure that we are checking the same `name` that JavaScript would use,
|
||||
// we cast it to a string, if possible.
|
||||
// Doing `name + ''` can cause a repl error if the result to `toString` is not a string,
|
||||
// this is, this will handle objects that misbehave.
|
||||
name = name + '';
|
||||
if (!isString(name)) {
|
||||
throw $parseMinErr('iseccst',
|
||||
'Cannot convert object to primitive value! '
|
||||
+ 'Expression: {0}', fullExpression);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
function ensureSafeObject(obj, fullExpression) {
|
||||
// nifty check if obj is Function that is fast and works across iframes and other contexts
|
||||
if (obj) {
|
||||
@@ -93,6 +112,16 @@ function ensureSafeFunction(obj, fullExpression) {
|
||||
}
|
||||
}
|
||||
|
||||
function ensureSafeAssignContext(obj, fullExpression) {
|
||||
if (obj) {
|
||||
if (obj === (0).constructor || obj === (false).constructor || obj === ''.constructor ||
|
||||
obj === {}.constructor || obj === [].constructor || obj === Function.constructor) {
|
||||
throw $parseMinErr('isecaf',
|
||||
'Assigning to a constructor is disallowed! Expression: {0}', fullExpression);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var OPERATORS = createMap();
|
||||
forEach('+ - * / % === !== == != < > <= >= && || ! = |'.split(' '), function(operator) { OPERATORS[operator] = true; });
|
||||
var ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'};
|
||||
@@ -774,6 +803,7 @@ ASTCompiler.prototype = {
|
||||
this.state.computing = 'assign';
|
||||
var result = this.nextId();
|
||||
this.recurse(assignable, result);
|
||||
this.return_(result);
|
||||
extra = 'fn.assign=' + this.generateFunction('assign', 's,v,l');
|
||||
}
|
||||
var toWatch = getInputs(ast.body);
|
||||
@@ -806,6 +836,8 @@ ASTCompiler.prototype = {
|
||||
'ensureSafeMemberName',
|
||||
'ensureSafeObject',
|
||||
'ensureSafeFunction',
|
||||
'getStringValue',
|
||||
'ensureSafeAssignContext',
|
||||
'ifDefined',
|
||||
'plus',
|
||||
'text',
|
||||
@@ -814,6 +846,8 @@ ASTCompiler.prototype = {
|
||||
ensureSafeMemberName,
|
||||
ensureSafeObject,
|
||||
ensureSafeFunction,
|
||||
getStringValue,
|
||||
ensureSafeAssignContext,
|
||||
ifDefined,
|
||||
plusFn,
|
||||
expression);
|
||||
@@ -957,6 +991,7 @@ ASTCompiler.prototype = {
|
||||
if (ast.computed) {
|
||||
right = self.nextId();
|
||||
self.recurse(ast.property, right);
|
||||
self.getStringValue(right);
|
||||
self.addEnsureSafeMemberName(right);
|
||||
if (create && create !== 1) {
|
||||
self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), '{}'));
|
||||
@@ -1040,6 +1075,7 @@ ASTCompiler.prototype = {
|
||||
self.if_(self.notNull(left.context), function() {
|
||||
self.recurse(ast.right, right);
|
||||
self.addEnsureSafeObject(self.member(left.context, left.name, left.computed));
|
||||
self.addEnsureSafeAssignContext(left.context);
|
||||
expression = self.member(left.context, left.name, left.computed) + ast.operator + right;
|
||||
self.assign(intoId, expression);
|
||||
recursionFn(intoId || expression);
|
||||
@@ -1165,6 +1201,10 @@ ASTCompiler.prototype = {
|
||||
this.current().body.push(this.ensureSafeFunction(item), ';');
|
||||
},
|
||||
|
||||
addEnsureSafeAssignContext: function(item) {
|
||||
this.current().body.push(this.ensureSafeAssignContext(item), ';');
|
||||
},
|
||||
|
||||
ensureSafeObject: function(item) {
|
||||
return 'ensureSafeObject(' + item + ',text)';
|
||||
},
|
||||
@@ -1177,6 +1217,14 @@ ASTCompiler.prototype = {
|
||||
return 'ensureSafeFunction(' + item + ',text)';
|
||||
},
|
||||
|
||||
getStringValue: function(item) {
|
||||
this.assign(item, 'getStringValue(' + item + ',text)');
|
||||
},
|
||||
|
||||
ensureSafeAssignContext: function(item) {
|
||||
return 'ensureSafeAssignContext(' + item + ',text)';
|
||||
},
|
||||
|
||||
lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) {
|
||||
var self = this;
|
||||
return function() {
|
||||
@@ -1354,6 +1402,7 @@ ASTInterpreter.prototype = {
|
||||
var lhs = left(scope, locals, assign, inputs);
|
||||
var rhs = right(scope, locals, assign, inputs);
|
||||
ensureSafeObject(lhs.value, self.expression);
|
||||
ensureSafeAssignContext(lhs.context);
|
||||
lhs.context[lhs.name] = rhs;
|
||||
return context ? {value: rhs} : rhs;
|
||||
};
|
||||
@@ -1551,6 +1600,7 @@ ASTInterpreter.prototype = {
|
||||
var value;
|
||||
if (lhs != null) {
|
||||
rhs = right(scope, locals, assign, inputs);
|
||||
rhs = getStringValue(rhs);
|
||||
ensureSafeMemberName(rhs, expression);
|
||||
if (create && create !== 1 && lhs && !(lhs[rhs])) {
|
||||
lhs[rhs] = {};
|
||||
|
||||
+6
-6
@@ -253,10 +253,10 @@ function $RootScopeProvider() {
|
||||
* Registers a `listener` callback to be executed whenever the `watchExpression` changes.
|
||||
*
|
||||
* - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest
|
||||
* $digest()} and should return the value that will be watched. (Since
|
||||
* {@link ng.$rootScope.Scope#$digest $digest()} reruns when it detects changes the
|
||||
* `watchExpression` can execute multiple times per
|
||||
* {@link ng.$rootScope.Scope#$digest $digest()} and should be idempotent.)
|
||||
* $digest()} and should return the value that will be watched. (`watchExpression` should not change
|
||||
* its value when executed multiple times with the same input because it may be executed multiple
|
||||
* times by {@link ng.$rootScope.Scope#$digest $digest()}. That is, `watchExpression` should be
|
||||
* [idempotent](http://en.wikipedia.org/wiki/Idempotence).
|
||||
* - The `listener` is called only when the value from the current `watchExpression` and the
|
||||
* previous call to `watchExpression` are not equal (with the exception of the initial run,
|
||||
* see below). Inequality is determined according to reference inequality,
|
||||
@@ -605,7 +605,7 @@ function $RootScopeProvider() {
|
||||
// copy the items to oldValue and look for changes.
|
||||
newLength = 0;
|
||||
for (key in newValue) {
|
||||
if (newValue.hasOwnProperty(key)) {
|
||||
if (hasOwnProperty.call(newValue, key)) {
|
||||
newLength++;
|
||||
newItem = newValue[key];
|
||||
oldItem = oldValue[key];
|
||||
@@ -627,7 +627,7 @@ function $RootScopeProvider() {
|
||||
// we used to have more keys, need to find them and destroy them.
|
||||
changeDetected++;
|
||||
for (key in oldValue) {
|
||||
if (!newValue.hasOwnProperty(key)) {
|
||||
if (!hasOwnProperty.call(newValue, key)) {
|
||||
oldLength--;
|
||||
delete oldValue[key];
|
||||
}
|
||||
|
||||
+2
-2
@@ -294,7 +294,7 @@ function $SceDelegateProvider() {
|
||||
'Attempted to trust a value in invalid context. Context: {0}; Value: {1}',
|
||||
type, trustedValue);
|
||||
}
|
||||
if (trustedValue === null || trustedValue === undefined || trustedValue === '') {
|
||||
if (trustedValue === null || isUndefined(trustedValue) || trustedValue === '') {
|
||||
return trustedValue;
|
||||
}
|
||||
// All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting
|
||||
@@ -349,7 +349,7 @@ function $SceDelegateProvider() {
|
||||
* `$sceDelegate.trustAs`} if valid in this context. Otherwise, throws an exception.
|
||||
*/
|
||||
function getTrusted(type, maybeTrusted) {
|
||||
if (maybeTrusted === null || maybeTrusted === undefined || maybeTrusted === '') {
|
||||
if (maybeTrusted === null || isUndefined(maybeTrusted) || maybeTrusted === '') {
|
||||
return maybeTrusted;
|
||||
}
|
||||
var constructor = (byType.hasOwnProperty(type) ? byType[type] : null);
|
||||
|
||||
@@ -187,7 +187,7 @@ var ANIMATE_TIMER_KEY = '$$animateCss';
|
||||
* * `event` - The DOM event (e.g. enter, leave, move). When used, a generated CSS class of `ng-EVENT` and `ng-EVENT-active` will be applied
|
||||
* to the element during the animation. Multiple events can be provided when spaces are used as a separator. (Note that this will not perform any DOM operation.)
|
||||
* * `easing` - The CSS easing value that will be applied to the transition or keyframe animation (or both).
|
||||
* * `transition` - The raw CSS transition style that will be used (e.g. `1s linear all`).
|
||||
* * `transitionStyle` - The raw CSS transition style that will be used (e.g. `1s linear all`).
|
||||
* * `keyframeStyle` - The raw CSS keyframe animation style that will be used (e.g. `1s my_animation linear`).
|
||||
* * `from` - The starting CSS styles (a key/value object) that will be applied at the start of the animation.
|
||||
* * `to` - The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition.
|
||||
@@ -204,6 +204,10 @@ var ANIMATE_TIMER_KEY = '$$animateCss';
|
||||
* * `staggerIndex` - The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item in the stagger; therefore when a
|
||||
* * `stagger` option value of `0.1` is used then there will be a stagger delay of `600ms`)
|
||||
* * `applyClassesEarly` - Whether or not the classes being added or removed will be used when detecting the animation. This is set by `$animate` when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time. (Note that this will prevent any transitions from occuring on the classes being added and removed.)
|
||||
* * `cleanupStyles` - Whether or not the provided `from` and `to` styles will be removed once
|
||||
* the animation is closed. This is useful for when the styles are used purely for the sake of
|
||||
* the animation and do not have a lasting visual effect on the element (e.g. a colapse and open animation).
|
||||
* By default this value is set to `false`.
|
||||
*
|
||||
* @return {object} an object with start and end methods and details about the animation.
|
||||
*
|
||||
@@ -324,6 +328,23 @@ function createLocalCacheLookup() {
|
||||
};
|
||||
}
|
||||
|
||||
// we do not reassign an already present style value since
|
||||
// if we detect the style property value again we may be
|
||||
// detecting styles that were added via the `from` styles.
|
||||
// We make use of `isDefined` here since an empty string
|
||||
// or null value (which is what getPropertyValue will return
|
||||
// for a non-existing style) will still be marked as a valid
|
||||
// value for the style (a falsy value implies that the style
|
||||
// is to be removed at the end of the animation). If we had a simple
|
||||
// "OR" statement then it would not be enough to catch that.
|
||||
function registerRestorableStyles(backup, node, properties) {
|
||||
forEach(properties, function(prop) {
|
||||
backup[prop] = isDefined(backup[prop])
|
||||
? backup[prop]
|
||||
: node.style.getPropertyValue(prop);
|
||||
});
|
||||
}
|
||||
|
||||
var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
||||
var gcsLookup = createLocalCacheLookup();
|
||||
var gcsStaggerLookup = createLocalCacheLookup();
|
||||
@@ -424,6 +445,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
||||
}
|
||||
|
||||
return function init(element, options) {
|
||||
var restoreStyles = {};
|
||||
var node = getDomNode(element);
|
||||
if (!node
|
||||
|| !node.parentNode
|
||||
@@ -625,7 +647,12 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
||||
stagger.animationDuration === 0;
|
||||
}
|
||||
|
||||
applyAnimationFromStyles(element, options);
|
||||
if (options.from) {
|
||||
if (options.cleanupStyles) {
|
||||
registerRestorableStyles(restoreStyles, node, Object.keys(options.from));
|
||||
}
|
||||
applyAnimationFromStyles(element, options);
|
||||
}
|
||||
|
||||
if (flags.blockTransition || flags.blockKeyframeAnimation) {
|
||||
applyBlocking(maxDuration);
|
||||
@@ -692,6 +719,13 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
||||
applyAnimationClasses(element, options);
|
||||
applyAnimationStyles(element, options);
|
||||
|
||||
if (Object.keys(restoreStyles).length) {
|
||||
forEach(restoreStyles, function(value, prop) {
|
||||
value ? node.style.setProperty(prop, value)
|
||||
: node.style.removeProperty(prop);
|
||||
});
|
||||
}
|
||||
|
||||
// the reason why we have this option is to allow a synchronous closing callback
|
||||
// that is fired as SOON as the animation ends (when the CSS is removed) or if
|
||||
// the animation never takes off at all. A good example is a leave animation since
|
||||
@@ -886,7 +920,12 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
||||
}
|
||||
|
||||
element.on(events.join(' '), onAnimationProgress);
|
||||
applyAnimationToStyles(element, options);
|
||||
if (options.to) {
|
||||
if (options.cleanupStyles) {
|
||||
registerRestorableStyles(restoreStyles, node, Object.keys(options.to));
|
||||
}
|
||||
applyAnimationToStyles(element, options);
|
||||
}
|
||||
}
|
||||
|
||||
function onAnimationExpired() {
|
||||
|
||||
@@ -9,16 +9,25 @@ var $$AnimateCssDriverProvider = ['$$animationProvider', function($$animationPro
|
||||
var NG_OUT_ANCHOR_CLASS_NAME = 'ng-anchor-out';
|
||||
var NG_IN_ANCHOR_CLASS_NAME = 'ng-anchor-in';
|
||||
|
||||
this.$get = ['$animateCss', '$rootScope', '$$AnimateRunner', '$rootElement', '$$body', '$sniffer', '$$jqLite',
|
||||
function($animateCss, $rootScope, $$AnimateRunner, $rootElement, $$body, $sniffer, $$jqLite) {
|
||||
function isDocumentFragment(node) {
|
||||
return node.parentNode && node.parentNode.nodeType === 11;
|
||||
}
|
||||
|
||||
this.$get = ['$animateCss', '$rootScope', '$$AnimateRunner', '$rootElement', '$sniffer', '$$jqLite', '$document',
|
||||
function($animateCss, $rootScope, $$AnimateRunner, $rootElement, $sniffer, $$jqLite, $document) {
|
||||
|
||||
// only browsers that support these properties can render animations
|
||||
if (!$sniffer.animations && !$sniffer.transitions) return noop;
|
||||
|
||||
var bodyNode = getDomNode($$body);
|
||||
var bodyNode = $document[0].body;
|
||||
var rootNode = getDomNode($rootElement);
|
||||
|
||||
var rootBodyElement = jqLite(bodyNode.parentNode === rootNode ? bodyNode : rootNode);
|
||||
var rootBodyElement = jqLite(
|
||||
// this is to avoid using something that exists outside of the body
|
||||
// we also special case the doc fragement case because our unit test code
|
||||
// appends the $rootElement to the body after the app has been bootstrapped
|
||||
isDocumentFragment(rootNode) || bodyNode.contains(rootNode) ? rootNode : bodyNode
|
||||
);
|
||||
|
||||
var applyAnimationClasses = applyAnimationClassesFactory($$jqLite);
|
||||
|
||||
|
||||
@@ -66,15 +66,33 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
|
||||
return (nO.addClass && nO.addClass === cO.removeClass) || (nO.removeClass && nO.removeClass === cO.addClass);
|
||||
});
|
||||
|
||||
this.$get = ['$$rAF', '$rootScope', '$rootElement', '$document', '$$body', '$$HashMap',
|
||||
this.$get = ['$$rAF', '$rootScope', '$rootElement', '$document', '$$HashMap',
|
||||
'$$animation', '$$AnimateRunner', '$templateRequest', '$$jqLite', '$$forceReflow',
|
||||
function($$rAF, $rootScope, $rootElement, $document, $$body, $$HashMap,
|
||||
function($$rAF, $rootScope, $rootElement, $document, $$HashMap,
|
||||
$$animation, $$AnimateRunner, $templateRequest, $$jqLite, $$forceReflow) {
|
||||
|
||||
var activeAnimationsLookup = new $$HashMap();
|
||||
var disabledElementsLookup = new $$HashMap();
|
||||
var animationsEnabled = null;
|
||||
|
||||
function postDigestTaskFactory() {
|
||||
var postDigestCalled = false;
|
||||
return function(fn) {
|
||||
// we only issue a call to postDigest before
|
||||
// it has first passed. This prevents any callbacks
|
||||
// from not firing once the animation has completed
|
||||
// since it will be out of the digest cycle.
|
||||
if (postDigestCalled) {
|
||||
fn();
|
||||
} else {
|
||||
$rootScope.$$postDigest(function() {
|
||||
postDigestCalled = true;
|
||||
fn();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Wait until all directive and route-related templates are downloaded and
|
||||
// compiled. The $templateRequest.totalPendingRequests variable keeps track of
|
||||
// all of the remote templates being currently downloaded. If there are no
|
||||
@@ -137,14 +155,6 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
|
||||
return matches;
|
||||
}
|
||||
|
||||
function triggerCallback(event, element, phase, data) {
|
||||
$$rAF(function() {
|
||||
forEach(findCallbacks(element, event), function(callback) {
|
||||
callback(element, phase, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
on: function(event, container, callback) {
|
||||
var node = extractElementNode(container);
|
||||
@@ -239,6 +249,9 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
|
||||
// These methods will become available after the digest has passed
|
||||
var runner = new $$AnimateRunner();
|
||||
|
||||
// this is used to trigger callbacks in postDigest mode
|
||||
var runInNextPostDigestOrNow = postDigestTaskFactory();
|
||||
|
||||
if (isArray(options.addClass)) {
|
||||
options.addClass = options.addClass.join(' ');
|
||||
}
|
||||
@@ -459,7 +472,20 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
|
||||
return runner;
|
||||
|
||||
function notifyProgress(runner, event, phase, data) {
|
||||
triggerCallback(event, element, phase, data);
|
||||
runInNextPostDigestOrNow(function() {
|
||||
var callbacks = findCallbacks(element, event);
|
||||
if (callbacks.length) {
|
||||
// do not optimize this call here to RAF because
|
||||
// we don't know how heavy the callback code here will
|
||||
// be and if this code is buffered then this can
|
||||
// lead to a performance regression.
|
||||
$$rAF(function() {
|
||||
forEach(callbacks, function(callback) {
|
||||
callback(element, phase, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
runner.progress(event, phase, data);
|
||||
}
|
||||
|
||||
@@ -502,7 +528,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
|
||||
}
|
||||
|
||||
function areAnimationsAllowed(element, parentElement, event) {
|
||||
var bodyElementDetected = isMatchingElement(element, $$body) || element[0].nodeName === 'HTML';
|
||||
var bodyElement = jqLite($document[0].body);
|
||||
var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';
|
||||
var rootElementDetected = isMatchingElement(element, $rootElement);
|
||||
var parentAnimationDetected = false;
|
||||
var animateChildren;
|
||||
@@ -558,7 +585,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
|
||||
if (!bodyElementDetected) {
|
||||
// we also need to ensure that the element is or will be apart of the body element
|
||||
// otherwise it is pointless to even issue an animation to be rendered
|
||||
bodyElementDetected = isMatchingElement(parentElement, $$body);
|
||||
bodyElementDetected = isMatchingElement(parentElement, bodyElement);
|
||||
}
|
||||
|
||||
parentElement = parentElement.parent();
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
function $$BodyProvider() {
|
||||
this.$get = ['$document', function($document) {
|
||||
return jqLite($document[0].body);
|
||||
}];
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
/* global angularAnimateModule: true,
|
||||
|
||||
$$BodyProvider,
|
||||
$$AnimateAsyncRunFactory,
|
||||
$$rAFSchedulerFactory,
|
||||
$$AnimateChildrenDirective,
|
||||
@@ -742,8 +741,6 @@
|
||||
* Click here {@link ng.$animate to learn more about animations with `$animate`}.
|
||||
*/
|
||||
angular.module('ngAnimate', [])
|
||||
.provider('$$body', $$BodyProvider)
|
||||
|
||||
.directive('ngAnimateChildren', $$AnimateChildrenDirective)
|
||||
.factory('$$rAFScheduler', $$rAFSchedulerFactory)
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ var CSS_PREFIX = '', TRANSITION_PROP, TRANSITIONEND_EVENT, ANIMATION_PROP, ANIMA
|
||||
// Also, the only modern browser that uses vendor prefixes for transitions/keyframes is webkit
|
||||
// therefore there is no reason to test anymore for other vendor prefixes:
|
||||
// http://caniuse.com/#search=transition
|
||||
if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
|
||||
if (isUndefined(window.ontransitionend) && isDefined(window.onwebkittransitionend)) {
|
||||
CSS_PREFIX = '-webkit-';
|
||||
TRANSITION_PROP = 'WebkitTransition';
|
||||
TRANSITIONEND_EVENT = 'webkitTransitionEnd transitionend';
|
||||
@@ -45,7 +45,7 @@ if (window.ontransitionend === undefined && window.onwebkittransitionend !== und
|
||||
TRANSITIONEND_EVENT = 'transitionend';
|
||||
}
|
||||
|
||||
if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {
|
||||
if (isUndefined(window.onanimationend) && isDefined(window.onwebkitanimationend)) {
|
||||
CSS_PREFIX = '-webkit-';
|
||||
ANIMATION_PROP = 'WebkitAnimation';
|
||||
ANIMATIONEND_EVENT = 'webkitAnimationEnd animationend';
|
||||
|
||||
+39
-35
@@ -52,6 +52,16 @@
|
||||
var ngAriaModule = angular.module('ngAria', ['ng']).
|
||||
provider('$aria', $AriaProvider);
|
||||
|
||||
/**
|
||||
* Internal Utilities
|
||||
*/
|
||||
var nodeBlackList = ['BUTTON', 'A', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS', 'SUMMARY'];
|
||||
|
||||
var isNodeOneOf = function(elem, nodeTypeArray) {
|
||||
if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @ngdoc provider
|
||||
* @name $ariaProvider
|
||||
@@ -113,10 +123,10 @@ function $AriaProvider() {
|
||||
config = angular.extend(config, newConfig);
|
||||
};
|
||||
|
||||
function watchExpr(attrName, ariaAttr, negate) {
|
||||
function watchExpr(attrName, ariaAttr, nodeBlackList, negate) {
|
||||
return function(scope, elem, attr) {
|
||||
var ariaCamelName = attr.$normalize(ariaAttr);
|
||||
if (config[ariaCamelName] && !attr[ariaCamelName]) {
|
||||
if (config[ariaCamelName] && !isNodeOneOf(elem, nodeBlackList) && !attr[ariaCamelName]) {
|
||||
scope.$watch(attr[attrName], function(boolVal) {
|
||||
// ensure boolean value
|
||||
boolVal = negate ? !boolVal : !!boolVal;
|
||||
@@ -125,7 +135,6 @@ function $AriaProvider() {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc service
|
||||
* @name $aria
|
||||
@@ -184,10 +193,10 @@ function $AriaProvider() {
|
||||
|
||||
|
||||
ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
||||
return $aria.$$watchExpr('ngShow', 'aria-hidden', true);
|
||||
return $aria.$$watchExpr('ngShow', 'aria-hidden', [], true);
|
||||
}])
|
||||
.directive('ngHide', ['$aria', function($aria) {
|
||||
return $aria.$$watchExpr('ngHide', 'aria-hidden', false);
|
||||
return $aria.$$watchExpr('ngHide', 'aria-hidden', [], false);
|
||||
}])
|
||||
.directive('ngModel', ['$aria', function($aria) {
|
||||
|
||||
@@ -261,6 +270,9 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
||||
scope.$watch(ngAriaWatchModelValue, shape === 'radio' ?
|
||||
getRadioReaction() : ngAriaCheckboxReaction);
|
||||
}
|
||||
if (needsTabIndex) {
|
||||
elem.attr('tabindex', 0);
|
||||
}
|
||||
break;
|
||||
case 'range':
|
||||
if (shouldAttachRole(shape, elem)) {
|
||||
@@ -289,6 +301,9 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (needsTabIndex) {
|
||||
elem.attr('tabindex', 0);
|
||||
}
|
||||
break;
|
||||
case 'multiline':
|
||||
if (shouldAttachAttr('aria-multiline', 'ariaMultiline', elem)) {
|
||||
@@ -297,10 +312,6 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (needsTabIndex) {
|
||||
elem.attr('tabindex', 0);
|
||||
}
|
||||
|
||||
if (ngModel.$validators.required && shouldAttachAttr('aria-required', 'ariaRequired', elem)) {
|
||||
scope.$watch(function ngAriaRequiredWatch() {
|
||||
return ngModel.$error.required;
|
||||
@@ -322,7 +333,7 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
||||
};
|
||||
}])
|
||||
.directive('ngDisabled', ['$aria', function($aria) {
|
||||
return $aria.$$watchExpr('ngDisabled', 'aria-disabled');
|
||||
return $aria.$$watchExpr('ngDisabled', 'aria-disabled', []);
|
||||
}])
|
||||
.directive('ngMessages', function() {
|
||||
return {
|
||||
@@ -342,35 +353,28 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
||||
var fn = $parse(attr.ngClick, /* interceptorFn */ null, /* expensiveChecks */ true);
|
||||
return function(scope, elem, attr) {
|
||||
|
||||
var nodeBlackList = ['BUTTON', 'A', 'INPUT', 'TEXTAREA'];
|
||||
if (!isNodeOneOf(elem, nodeBlackList)) {
|
||||
|
||||
function isNodeOneOf(elem, nodeTypeArray) {
|
||||
if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
|
||||
return true;
|
||||
if ($aria.config('bindRoleForClick') && !elem.attr('role')) {
|
||||
elem.attr('role', 'button');
|
||||
}
|
||||
}
|
||||
|
||||
if ($aria.config('bindRoleForClick')
|
||||
&& !elem.attr('role')
|
||||
&& !isNodeOneOf(elem, nodeBlackList)) {
|
||||
elem.attr('role', 'button');
|
||||
}
|
||||
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
|
||||
elem.attr('tabindex', 0);
|
||||
}
|
||||
|
||||
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
|
||||
elem.attr('tabindex', 0);
|
||||
}
|
||||
if ($aria.config('bindKeypress') && !attr.ngKeypress) {
|
||||
elem.on('keypress', function(event) {
|
||||
var keyCode = event.which || event.keyCode;
|
||||
if (keyCode === 32 || keyCode === 13) {
|
||||
scope.$apply(callback);
|
||||
}
|
||||
|
||||
if ($aria.config('bindKeypress') && !attr.ngKeypress && !isNodeOneOf(elem, nodeBlackList)) {
|
||||
elem.on('keypress', function(event) {
|
||||
var keyCode = event.which || event.keyCode;
|
||||
if (keyCode === 32 || keyCode === 13) {
|
||||
scope.$apply(callback);
|
||||
}
|
||||
|
||||
function callback() {
|
||||
fn(scope, { $event: event });
|
||||
}
|
||||
});
|
||||
function callback() {
|
||||
fn(scope, { $event: event });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -378,7 +382,7 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
||||
}])
|
||||
.directive('ngDblclick', ['$aria', function($aria) {
|
||||
return function(scope, elem, attr) {
|
||||
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
|
||||
if ($aria.config('tabindex') && !elem.attr('tabindex') && !isNodeOneOf(elem, nodeBlackList)) {
|
||||
elem.attr('tabindex', 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ function $$CookieWriter($document, $log, $browser) {
|
||||
options = options || {};
|
||||
expires = options.expires;
|
||||
path = angular.isDefined(options.path) ? options.path : cookiePath;
|
||||
if (value === undefined) {
|
||||
if (angular.isUndefined(value)) {
|
||||
expires = 'Thu, 01 Jan 1970 00:00:00 GMT';
|
||||
value = '';
|
||||
}
|
||||
|
||||
@@ -325,6 +325,9 @@ angular.module('ngMessages', [])
|
||||
controller: ['$element', '$scope', '$attrs', function($element, $scope, $attrs) {
|
||||
var ctrl = this;
|
||||
var latestKey = 0;
|
||||
var nextAttachId = 0;
|
||||
|
||||
this.getAttachId = function getAttachId() { return nextAttachId++; };
|
||||
|
||||
var messages = this.messages = {};
|
||||
var renderLater, cachedCollection;
|
||||
@@ -636,11 +639,15 @@ function ngMessageDirectiveFactory(restrict) {
|
||||
$animate.enter(elm, null, element);
|
||||
currentElement = elm;
|
||||
|
||||
// Each time we attach this node to a message we get a new id that we can match
|
||||
// when we are destroying the node later.
|
||||
var $$attachId = currentElement.$$attachId = ngMessagesCtrl.getAttachId();
|
||||
|
||||
// in the event that the parent element is destroyed
|
||||
// by any other structural directive then it's time
|
||||
// to deregister the message from the controller
|
||||
currentElement.on('$destroy', function() {
|
||||
if (currentElement) {
|
||||
if (currentElement && currentElement.$$attachId === $$attachId) {
|
||||
ngMessagesCtrl.deregister(commentNode);
|
||||
messageCtrl.detach();
|
||||
}
|
||||
|
||||
Vendored
+26
-14
@@ -87,7 +87,7 @@ angular.mock.$Browser = function() {
|
||||
if (fn.id === deferId) fnIndex = index;
|
||||
});
|
||||
|
||||
if (fnIndex !== undefined) {
|
||||
if (angular.isDefined(fnIndex)) {
|
||||
self.deferredFns.splice(fnIndex, 1);
|
||||
return true;
|
||||
}
|
||||
@@ -462,7 +462,7 @@ angular.mock.$IntervalProvider = function() {
|
||||
if (fn.id === promise.$$intervalId) fnIndex = index;
|
||||
});
|
||||
|
||||
if (fnIndex !== undefined) {
|
||||
if (angular.isDefined(fnIndex)) {
|
||||
repeatFns.splice(fnIndex, 1);
|
||||
}
|
||||
}
|
||||
@@ -504,7 +504,7 @@ angular.mock.$IntervalProvider = function() {
|
||||
if (fn.id === promise.$$intervalId) fnIndex = index;
|
||||
});
|
||||
|
||||
if (fnIndex !== undefined) {
|
||||
if (angular.isDefined(fnIndex)) {
|
||||
repeatFns[fnIndex].deferred.reject('canceled');
|
||||
repeatFns.splice(fnIndex, 1);
|
||||
return true;
|
||||
@@ -783,9 +783,10 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
|
||||
return queueFn;
|
||||
});
|
||||
|
||||
$provide.decorator('$animate', ['$delegate', '$timeout', '$browser', '$$rAF', '$$forceReflow', '$$animateAsyncRun',
|
||||
function($delegate, $timeout, $browser, $$rAF, $$forceReflow, $$animateAsyncRun) {
|
||||
|
||||
$provide.decorator('$animate', ['$delegate', '$timeout', '$browser', '$$rAF',
|
||||
'$$forceReflow', '$$animateAsyncRun', '$rootScope',
|
||||
function($delegate, $timeout, $browser, $$rAF,
|
||||
$$forceReflow, $$animateAsyncRun, $rootScope) {
|
||||
var animate = {
|
||||
queue: [],
|
||||
cancel: $delegate.cancel,
|
||||
@@ -797,16 +798,27 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
|
||||
},
|
||||
enabled: $delegate.enabled,
|
||||
flush: function() {
|
||||
var rafsFlushed = false;
|
||||
if ($$rAF.queue.length) {
|
||||
$$rAF.flush();
|
||||
rafsFlushed = true;
|
||||
}
|
||||
$rootScope.$digest();
|
||||
|
||||
var animatorsFlushed = $$animateAsyncRun.flush();
|
||||
if (!rafsFlushed && !animatorsFlushed) {
|
||||
var doNextRun, somethingFlushed = false;
|
||||
do {
|
||||
doNextRun = false;
|
||||
|
||||
if ($$rAF.queue.length) {
|
||||
$$rAF.flush();
|
||||
doNextRun = somethingFlushed = true;
|
||||
}
|
||||
|
||||
if ($$animateAsyncRun.flush()) {
|
||||
doNextRun = somethingFlushed = true;
|
||||
}
|
||||
} while (doNextRun);
|
||||
|
||||
if (!somethingFlushed) {
|
||||
throw new Error('No pending animations ready to be closed or flushed');
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1023,7 +1035,7 @@ angular.mock.dump = function(object) {
|
||||
$http.post('/add-msg.py', message, { headers: headers } ).success(function(response) {
|
||||
$scope.status = '';
|
||||
}).error(function() {
|
||||
$scope.status = 'ERROR!';
|
||||
$scope.status = 'Failed...';
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ function lookupDottedPath(obj, path) {
|
||||
throw $resourceMinErr('badmember', 'Dotted member path "@{0}" is invalid.', path);
|
||||
}
|
||||
var keys = path.split('.');
|
||||
for (var i = 0, ii = keys.length; i < ii && obj !== undefined; i++) {
|
||||
for (var i = 0, ii = keys.length; i < ii && angular.isDefined(obj); i++) {
|
||||
var key = keys[i];
|
||||
obj = (obj !== null) ? obj[key] : undefined;
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ _jQuery.fn.bindings = function(windowJquery, bindExp) {
|
||||
}
|
||||
|
||||
function push(value) {
|
||||
if (value === undefined) {
|
||||
if (angular.isUndefined(value)) {
|
||||
value = '';
|
||||
} else if (typeof value !== 'string') {
|
||||
value = angular.toJson(value);
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ function serializeObject(obj) {
|
||||
val = toJsonReplacer(key, val);
|
||||
if (isObject(val)) {
|
||||
|
||||
if (seen.indexOf(val) >= 0) return '<<already seen>>';
|
||||
if (seen.indexOf(val) >= 0) return '...';
|
||||
|
||||
seen.push(val);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ function serializeObject(obj) {
|
||||
function toDebugString(obj) {
|
||||
if (typeof obj === 'function') {
|
||||
return obj.toString().replace(/ \{[\s\S]*$/, '');
|
||||
} else if (typeof obj === 'undefined') {
|
||||
} else if (isUndefined(obj)) {
|
||||
return 'undefined';
|
||||
} else if (typeof obj !== 'string') {
|
||||
return serializeObject(obj);
|
||||
|
||||
@@ -386,6 +386,18 @@ describe('angular', function() {
|
||||
expect(aCopy).toBe(aCopy.self);
|
||||
});
|
||||
|
||||
it('should deeply copy XML nodes', function() {
|
||||
var anElement = document.createElement('foo');
|
||||
anElement.appendChild(document.createElement('bar'));
|
||||
var theCopy = anElement.cloneNode(true);
|
||||
expect(copy(anElement).outerHTML).toEqual(theCopy.outerHTML);
|
||||
expect(copy(anElement)).not.toBe(anElement);
|
||||
});
|
||||
|
||||
it('should not try to call a non-function called `cloneNode`', function() {
|
||||
expect(copy.bind(null, { cloneNode: 100 })).not.toThrow();
|
||||
});
|
||||
|
||||
it('should handle objects with multiple references', function() {
|
||||
var b = {};
|
||||
var a = [b, -1, b];
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
{{jqueryVersion}}
|
||||
|
||||
<script src="../../../../bower_components/jquery/dist/jquery.js"></script>
|
||||
<script type="text/javascript">
|
||||
// Verify that empty ng-jq is not accessing `window['']`.
|
||||
// (See https://github.com/angular/angular.js/issues/12741 for more details)
|
||||
window[''] = window.jQuery;
|
||||
</script>
|
||||
<script src="angular.js"></script>
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -47,6 +47,7 @@ afterEach(function() {
|
||||
if (bod) {
|
||||
bod.$$hashKey = null;
|
||||
}
|
||||
document.$$hashKey = null;
|
||||
|
||||
if (this.$injector) {
|
||||
var $rootScope = this.$injector.get('$rootScope');
|
||||
|
||||
@@ -78,6 +78,33 @@ describe('jqLite', function() {
|
||||
});
|
||||
|
||||
|
||||
// This is not working correctly in jQuery prior to v3.0.
|
||||
// See https://github.com/jquery/jquery/issues/1987 for details.
|
||||
it('should properly handle dash-delimited node names', function() {
|
||||
var jQueryVersion = window.jQuery && window.jQuery.fn.jquery.split('.')[0];
|
||||
var jQuery3xOrNewer = jQueryVersion && (Number(jQueryVersion) >= 3);
|
||||
|
||||
if (_jqLiteMode || jQuery3xOrNewer) {
|
||||
var nodeNames = 'thead tbody tfoot colgroup caption tr th td div kung'.split(' ');
|
||||
var nodeNamesTested = 0;
|
||||
var nodes, customNodeName;
|
||||
|
||||
forEach(nodeNames, function(nodeName) {
|
||||
var customNodeName = nodeName + '-foo';
|
||||
var nodes = jqLite('<' + customNodeName + '>Hello, world !</' + customNodeName + '>');
|
||||
|
||||
expect(nodes.length).toBe(1);
|
||||
expect(nodeName_(nodes)).toBe(customNodeName);
|
||||
expect(nodes.html()).toBe('Hello, world !');
|
||||
|
||||
nodeNamesTested++;
|
||||
});
|
||||
|
||||
expect(nodeNamesTested).toBe(10);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
it('should allow creation of comment tags', function() {
|
||||
var nodes = jqLite('<!-- foo -->');
|
||||
expect(nodes.length).toBe(1);
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ describe('minErr', function() {
|
||||
a.b.a = a;
|
||||
|
||||
var myError = testError('26', 'a is {0}', a);
|
||||
expect(myError.message).toMatch(/a is {"b":{"a":"<<already seen>>"}}/);
|
||||
expect(myError.message).toMatch(/a is {"b":{"a":"..."}}/);
|
||||
});
|
||||
|
||||
it('should preserve interpolation markers when fewer arguments than needed are provided', function() {
|
||||
|
||||
@@ -115,6 +115,38 @@ describe("$animateCss", function() {
|
||||
expect(cancelSpy).toHaveBeenCalled();
|
||||
expect(doneSpy).not.toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it("should not bother applying the provided [from] and [to] styles to the element if [cleanupStyles] is present",
|
||||
inject(function($animateCss, $rootScope) {
|
||||
|
||||
var animator = $animateCss(element, {
|
||||
cleanupStyles: true,
|
||||
from: { width: '100px' },
|
||||
to: { width: '900px', height: '1000px' }
|
||||
});
|
||||
|
||||
assertStyleIsEmpty(element, 'width');
|
||||
assertStyleIsEmpty(element, 'height');
|
||||
|
||||
var runner = animator.start();
|
||||
|
||||
assertStyleIsEmpty(element, 'width');
|
||||
assertStyleIsEmpty(element, 'height');
|
||||
|
||||
triggerRAF();
|
||||
|
||||
assertStyleIsEmpty(element, 'width');
|
||||
assertStyleIsEmpty(element, 'height');
|
||||
|
||||
runner.end();
|
||||
|
||||
assertStyleIsEmpty(element, 'width');
|
||||
assertStyleIsEmpty(element, 'height');
|
||||
|
||||
function assertStyleIsEmpty(element, prop) {
|
||||
expect(element[0].style.getPropertyValue(prop)).toBeFalsy();
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -341,6 +341,21 @@ describe("$animate", function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should not break postDigest for subsequent elements if addClass contains non-valid CSS class names', function() {
|
||||
inject(function($animate, $rootScope, $rootElement) {
|
||||
var element1 = jqLite('<div></div>');
|
||||
var element2 = jqLite('<div></div>');
|
||||
|
||||
$animate.enter(element1, $rootElement, null, { addClass: ' ' });
|
||||
$animate.enter(element2, $rootElement, null, { addClass: 'valid-name' });
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(element2.hasClass('valid-name')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should not issue a call to removeClass if the provided class value is not a string or array', function() {
|
||||
inject(function($animate, $rootScope, $rootElement) {
|
||||
var spy = spyOn(window, 'jqLiteRemoveClass').andCallThrough();
|
||||
|
||||
+48
-6
@@ -12,12 +12,20 @@ function MockWindow(options) {
|
||||
var events = {};
|
||||
var timeouts = this.timeouts = [];
|
||||
var locationHref = 'http://server/';
|
||||
var committedHref = 'http://server/';
|
||||
var mockWindow = this;
|
||||
var msie = options.msie;
|
||||
var ieState;
|
||||
|
||||
historyEntriesLength = 1;
|
||||
|
||||
function replaceHash(href, hash) {
|
||||
// replace the hash with the new one (stripping off a leading hash if there is one)
|
||||
// See hash setter spec: https://url.spec.whatwg.org/#urlutils-and-urlutilsreadonly-members
|
||||
return stripHash(href) + '#' + hash.replace(/^#/,'');
|
||||
}
|
||||
|
||||
|
||||
this.setTimeout = function(fn) {
|
||||
return timeouts.push(fn) - 1;
|
||||
};
|
||||
@@ -46,24 +54,28 @@ function MockWindow(options) {
|
||||
|
||||
this.location = {
|
||||
get href() {
|
||||
return locationHref;
|
||||
return committedHref;
|
||||
},
|
||||
set href(value) {
|
||||
locationHref = value;
|
||||
mockWindow.history.state = null;
|
||||
historyEntriesLength++;
|
||||
if (!options.updateAsync) this.flushHref();
|
||||
},
|
||||
get hash() {
|
||||
return getHash(locationHref);
|
||||
return getHash(committedHref);
|
||||
},
|
||||
set hash(value) {
|
||||
// replace the hash with the new one (stripping off a leading hash if there is one)
|
||||
// See hash setter spec: https://url.spec.whatwg.org/#urlutils-and-urlutilsreadonly-members
|
||||
locationHref = stripHash(locationHref) + '#' + value.replace(/^#/,'');
|
||||
locationHref = replaceHash(locationHref, value);
|
||||
if (!options.updateAsync) this.flushHref();
|
||||
},
|
||||
replace: function(url) {
|
||||
locationHref = url;
|
||||
mockWindow.history.state = null;
|
||||
if (!options.updateAsync) this.flushHref();
|
||||
},
|
||||
flushHref: function() {
|
||||
committedHref = locationHref;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -132,7 +144,7 @@ describe('browser', function() {
|
||||
|
||||
logs = {log:[], warn:[], info:[], error:[]};
|
||||
|
||||
var fakeLog = {log: function() { logs.log.push(slice.call(arguments)); },
|
||||
fakeLog = {log: function() { logs.log.push(slice.call(arguments)); },
|
||||
warn: function() { logs.warn.push(slice.call(arguments)); },
|
||||
info: function() { logs.info.push(slice.call(arguments)); },
|
||||
error: function() { logs.error.push(slice.call(arguments)); }};
|
||||
@@ -703,7 +715,11 @@ describe('browser', function() {
|
||||
describe('integration tests with $location', function() {
|
||||
|
||||
function setup(options) {
|
||||
fakeWindow = new MockWindow(options);
|
||||
browser = new Browser(fakeWindow, fakeDocument, fakeLog, sniffer);
|
||||
|
||||
module(function($provide, $locationProvider) {
|
||||
|
||||
spyOn(fakeWindow.history, 'pushState').andCallFake(function(stateObj, title, newUrl) {
|
||||
fakeWindow.location.href = newUrl;
|
||||
});
|
||||
@@ -827,6 +843,32 @@ describe('browser', function() {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// issue #12241
|
||||
it('should not infinite digest if the browser does not synchronously update the location properties', function() {
|
||||
setup({
|
||||
history: true,
|
||||
html5Mode: true,
|
||||
updateAsync: true // Simulate a browser that doesn't update the href synchronously
|
||||
});
|
||||
|
||||
inject(function($location, $rootScope) {
|
||||
|
||||
// Change the hash within Angular and check that we don't infinitely digest
|
||||
$location.hash('newHash');
|
||||
expect(function() { $rootScope.$digest(); }).not.toThrow();
|
||||
expect($location.absUrl()).toEqual('http://server/#newHash');
|
||||
|
||||
// Now change the hash from outside Angular and check that $location updates correctly
|
||||
fakeWindow.location.hash = '#otherHash';
|
||||
|
||||
// simulate next tick - since this browser doesn't update synchronously
|
||||
fakeWindow.location.flushHref();
|
||||
fakeWindow.fire('hashchange');
|
||||
|
||||
expect($location.absUrl()).toEqual('http://server/#otherHash');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('integration test with $rootScope', function() {
|
||||
|
||||
@@ -3577,6 +3577,22 @@ describe('$compile', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to interpolate attribute names which are present in Object.prototype', function() {
|
||||
var attrs;
|
||||
module(function() {
|
||||
directive('attrExposer', valueFn({
|
||||
link: function($scope, $element, $attrs) {
|
||||
attrs = $attrs;
|
||||
}
|
||||
}));
|
||||
});
|
||||
inject(function($compile, $rootScope) {
|
||||
$compile('<div attr-exposer to-string="{{1 + 1}}">')($rootScope);
|
||||
$rootScope.$apply();
|
||||
expect(attrs.toString).toBe('2');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should not initialize scope value if optional expression binding is not passed', inject(function($compile) {
|
||||
compile('<div my-component></div>');
|
||||
|
||||
+256
-25
@@ -58,6 +58,119 @@ describe('form', function() {
|
||||
expect(form.alias).toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
it('should ignore changes in manually removed controls', function() {
|
||||
doc = $compile(
|
||||
'<form name="myForm">' +
|
||||
'<input name="control" ng-maxlength="1" ng-model="value" store-model-ctrl/>' +
|
||||
'</form>')(scope);
|
||||
|
||||
var form = scope.myForm;
|
||||
|
||||
var input = doc.find('input').eq(0);
|
||||
var inputController = input.controller('ngModel');
|
||||
|
||||
changeInputValue(input, 'ab');
|
||||
scope.$apply();
|
||||
|
||||
expect(form.$error.maxlength).toBeTruthy();
|
||||
expect(form.$dirty).toBe(true);
|
||||
expect(form.$error.maxlength[0].$name).toBe('control');
|
||||
|
||||
// remove control
|
||||
form.$removeControl(form.control);
|
||||
expect(form.control).toBeUndefined();
|
||||
expect(form.$error.maxlength).toBeFalsy();
|
||||
|
||||
inputController.$setPristine();
|
||||
expect(form.$dirty).toBe(true);
|
||||
|
||||
form.$setPristine();
|
||||
|
||||
changeInputValue(input, 'abc');
|
||||
scope.$apply();
|
||||
|
||||
expect(form.$error.maxlength).toBeFalsy();
|
||||
expect(form.$dirty).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
it('should react to validation changes in manually added controls', function() {
|
||||
doc = $compile(
|
||||
'<form name="myForm">' +
|
||||
'<input name="control" ng-maxlength="1" ng-model="value" store-model-ctrl/>' +
|
||||
'</form>')(scope);
|
||||
|
||||
scope.$digest();
|
||||
|
||||
var form = scope.myForm;
|
||||
|
||||
var input = doc.find('input').eq(0);
|
||||
|
||||
// remove control and invalidate it
|
||||
form.$removeControl(control);
|
||||
expect(form.control).toBeUndefined();
|
||||
|
||||
changeInputValue(input, 'abc');
|
||||
expect(control.$error.maxlength).toBe(true);
|
||||
expect(control.$dirty).toBe(true);
|
||||
expect(form.$error.maxlength).toBeFalsy();
|
||||
expect(form.$dirty).toBe(false);
|
||||
|
||||
// re-add the control; its current validation state is not propagated
|
||||
form.$addControl(control);
|
||||
expect(form.control).toBe(control);
|
||||
expect(form.$error.maxlength).toBeFalsy();
|
||||
expect(form.$dirty).toBe(false);
|
||||
|
||||
// Only when the input changes again its validation state is propagated
|
||||
changeInputValue(input, 'abcd');
|
||||
expect(form.$error.maxlength[0]).toBe(control);
|
||||
expect(form.$dirty).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
it('should use the correct parent when renaming and removing dynamically added controls', function() {
|
||||
scope.controlName = 'childControl';
|
||||
scope.hasChildControl = true;
|
||||
|
||||
doc = $compile(
|
||||
'<form name="myForm">' +
|
||||
'<div ng-if="hasChildControl">' +
|
||||
'<input name="{{controlName}}" ng-maxlength="1" ng-model="value"/>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<form name="otherForm"></form>')(scope);
|
||||
|
||||
scope.$digest();
|
||||
|
||||
var form = scope.myForm;
|
||||
var otherForm = scope.otherForm;
|
||||
var childControl = form.childControl;
|
||||
|
||||
// remove child form and add it to another form
|
||||
form.$removeControl(childControl);
|
||||
otherForm.$addControl(childControl);
|
||||
|
||||
expect(form.childControl).toBeUndefined();
|
||||
expect(otherForm.childControl).toBe(childControl);
|
||||
|
||||
// rename the childControl
|
||||
scope.controlName = 'childControlMoved';
|
||||
scope.$digest();
|
||||
|
||||
expect(form.childControlMoved).toBeUndefined();
|
||||
expect(otherForm.childControl).toBeUndefined();
|
||||
expect(otherForm.childControlMoved).toBe(childControl);
|
||||
|
||||
scope.hasChildControl = false;
|
||||
scope.$digest();
|
||||
|
||||
expect(form.childControlMoved).toBeUndefined();
|
||||
expect(otherForm.childControlMoved).toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
it('should remove scope reference when form with no parent form is removed from the DOM', function() {
|
||||
var formController;
|
||||
scope.ctrl = {};
|
||||
@@ -547,35 +660,153 @@ describe('form', function() {
|
||||
expect(doc.find('div').hasClass('ng-pending')).toBe(false);
|
||||
});
|
||||
|
||||
it('should leave the parent form invalid when deregister a removed input', function() {
|
||||
doc = jqLite(
|
||||
'<form name="parent">' +
|
||||
'<div class="ng-form" name="child">' +
|
||||
'<input ng-if="inputPresent" ng-model="modelA" name="inputA" required>' +
|
||||
'<input ng-model="modelB" name="inputB" required>' +
|
||||
'</div>' +
|
||||
'</form>');
|
||||
$compile(doc)(scope);
|
||||
scope.inputPresent = true;
|
||||
scope.$apply();
|
||||
|
||||
var parent = scope.parent,
|
||||
child = scope.child,
|
||||
inputA = child.inputA,
|
||||
inputB = child.inputB;
|
||||
it('should leave the parent form invalid when deregister a removed input', function() {
|
||||
doc = jqLite(
|
||||
'<form name="parent">' +
|
||||
'<div class="ng-form" name="child">' +
|
||||
'<input ng-if="inputPresent" ng-model="modelA" name="inputA" required>' +
|
||||
'<input ng-model="modelB" name="inputB" required>' +
|
||||
'</div>' +
|
||||
'</form>');
|
||||
$compile(doc)(scope);
|
||||
scope.inputPresent = true;
|
||||
scope.$apply();
|
||||
|
||||
expect(parent).toBeDefined();
|
||||
expect(child).toBeDefined();
|
||||
expect(parent.$error.required).toEqual([child]);
|
||||
expect(child.$error.required).toEqual([inputB, inputA]);
|
||||
var parent = scope.parent,
|
||||
child = scope.child,
|
||||
inputA = child.inputA,
|
||||
inputB = child.inputB;
|
||||
|
||||
//remove child input
|
||||
scope.inputPresent = false;
|
||||
scope.$apply();
|
||||
expect(parent).toBeDefined();
|
||||
expect(child).toBeDefined();
|
||||
expect(parent.$error.required).toEqual([child]);
|
||||
expect(child.$error.required).toEqual([inputB, inputA]);
|
||||
|
||||
//remove child input
|
||||
scope.inputPresent = false;
|
||||
scope.$apply();
|
||||
|
||||
expect(parent.$error.required).toEqual([child]);
|
||||
expect(child.$error.required).toEqual([inputB]);
|
||||
});
|
||||
|
||||
|
||||
it('should ignore changes in manually removed child forms', function() {
|
||||
doc = $compile(
|
||||
'<form name="myForm">' +
|
||||
'<ng-form name="childform">' +
|
||||
'<input name="childformcontrol" ng-maxlength="1" ng-model="value"/>' +
|
||||
'</ng-form>' +
|
||||
'</form>')(scope);
|
||||
|
||||
var form = scope.myForm;
|
||||
var childformController = doc.find('ng-form').eq(0).controller('form');
|
||||
|
||||
var input = doc.find('input').eq(0);
|
||||
var inputController = input.controller('ngModel');
|
||||
|
||||
changeInputValue(input, 'ab');
|
||||
scope.$apply();
|
||||
|
||||
expect(form.$dirty).toBe(true);
|
||||
expect(form.$error.maxlength).toBeTruthy();
|
||||
expect(form.$error.maxlength[0].$name).toBe('childform');
|
||||
|
||||
inputController.$setPristine();
|
||||
expect(form.$dirty).toBe(true);
|
||||
|
||||
form.$setPristine();
|
||||
|
||||
// remove child form
|
||||
form.$removeControl(childformController);
|
||||
expect(form.childform).toBeUndefined();
|
||||
expect(form.$error.maxlength).toBeFalsy();
|
||||
|
||||
changeInputValue(input, 'abc');
|
||||
scope.$apply();
|
||||
|
||||
expect(form.$error.maxlength).toBeFalsy();
|
||||
expect(form.$dirty).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
it('should react to changes in manually added child forms', function() {
|
||||
doc = $compile(
|
||||
'<form name="myForm">' +
|
||||
'<ng-form name="childForm">' +
|
||||
'<input name="childformcontrol" ng-maxlength="1" ng-model="value" />' +
|
||||
'</ng-form>' +
|
||||
'</form>')(scope);
|
||||
|
||||
var form = scope.myForm;
|
||||
var childFormController = doc.find('ng-form').eq(0).controller('form');
|
||||
|
||||
var input = doc.find('input').eq(0);
|
||||
|
||||
// remove child form so we can add it manually
|
||||
form.$removeControl(childFormController);
|
||||
changeInputValue(input, 'ab');
|
||||
|
||||
expect(form.childForm).toBeUndefined();
|
||||
expect(form.$dirty).toBe(false);
|
||||
expect(form.$error.maxlength).toBeFalsy();
|
||||
|
||||
// re-add the child form; its current validation state is not propagated
|
||||
form.$addControl(childFormController);
|
||||
expect(form.childForm).toBe(childFormController);
|
||||
expect(form.$error.maxlength).toBeFalsy();
|
||||
expect(form.$dirty).toBe(false);
|
||||
|
||||
// Only when the input inside the child form changes, the validation state is propagated
|
||||
changeInputValue(input, 'abc');
|
||||
expect(form.$error.maxlength[0]).toBe(childFormController);
|
||||
expect(form.$dirty).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
it('should use the correct parent when renaming and removing dynamically added forms', function() {
|
||||
scope.formName = 'childForm';
|
||||
scope.hasChildForm = true;
|
||||
|
||||
doc = $compile(
|
||||
'<form name="myForm">' +
|
||||
'<div ng-if="hasChildForm">' +
|
||||
'<ng-form name="{{formName}}">' +
|
||||
'<input name="childformcontrol" ng-maxlength="1" ng-model="value"/>' +
|
||||
'</ng-form>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<form name="otherForm"></form>')(scope);
|
||||
|
||||
scope.$digest();
|
||||
|
||||
var form = scope.myForm;
|
||||
var otherForm = scope.otherForm;
|
||||
var childForm = form.childForm;
|
||||
|
||||
// remove child form and add it to another form
|
||||
form.$removeControl(childForm);
|
||||
otherForm.$addControl(childForm);
|
||||
|
||||
expect(form.childForm).toBeUndefined();
|
||||
expect(otherForm.childForm).toBe(childForm);
|
||||
|
||||
// rename the childForm
|
||||
scope.formName = 'childFormMoved';
|
||||
scope.$digest();
|
||||
|
||||
expect(form.childFormMoved).toBeUndefined();
|
||||
expect(otherForm.childForm).toBeUndefined();
|
||||
expect(otherForm.childFormMoved).toBe(childForm);
|
||||
|
||||
scope.hasChildForm = false;
|
||||
scope.$digest();
|
||||
|
||||
expect(form.childFormMoved).toBeUndefined();
|
||||
expect(otherForm.childFormMoved).toBeUndefined();
|
||||
});
|
||||
|
||||
expect(parent.$error.required).toEqual([child]);
|
||||
expect(child.$error.required).toEqual([inputB]);
|
||||
});
|
||||
|
||||
it('should chain nested forms in repeater', function() {
|
||||
doc = jqLite(
|
||||
|
||||
@@ -688,6 +688,14 @@ describe('input', function() {
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect($rootScope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if min is empty', function() {
|
||||
$rootScope.minVal = undefined;
|
||||
$rootScope.value = new Date(-9999, 0, 1, 0, 0, 0);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function() {
|
||||
@@ -722,6 +730,14 @@ describe('input', function() {
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect($rootScope.form.alias.$error.max).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if max is empty', function() {
|
||||
$rootScope.maxVal = undefined;
|
||||
$rootScope.value = new Date(9999, 11, 31, 23, 59, 59);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -886,6 +902,14 @@ describe('input', function() {
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect($rootScope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if min is empty', function() {
|
||||
$rootScope.minVal = undefined;
|
||||
$rootScope.value = new Date(-9999, 0, 1, 0, 0, 0);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function() {
|
||||
@@ -921,6 +945,14 @@ describe('input', function() {
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect($rootScope.form.alias.$error.max).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if max is empty', function() {
|
||||
$rootScope.maxVal = undefined;
|
||||
$rootScope.value = new Date(9999, 11, 31, 23, 59, 59);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1119,6 +1151,14 @@ describe('input', function() {
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect($rootScope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if min is empty', function() {
|
||||
$rootScope.minVal = undefined;
|
||||
$rootScope.value = new Date(-9999, 0, 1, 0, 0, 0);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function() {
|
||||
@@ -1153,6 +1193,14 @@ describe('input', function() {
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect($rootScope.form.alias.$error.max).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if max is empty', function() {
|
||||
$rootScope.maxVal = undefined;
|
||||
$rootScope.value = new Date(9999, 11, 31, 23, 59, 59);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1428,12 +1476,21 @@ describe('input', function() {
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect($rootScope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if min is empty', function() {
|
||||
$rootScope.minVal = undefined;
|
||||
$rootScope.value = new Date(-9999, 0, 1, 0, 0, 0);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function() {
|
||||
var inputElm;
|
||||
beforeEach(function() {
|
||||
inputElm = helper.compileInput('<input type="time" ng-model="value" name="alias" max="22:30:00" />');
|
||||
$rootScope.maxVal = '22:30:00';
|
||||
inputElm = helper.compileInput('<input type="time" ng-model="value" name="alias" max="{{ maxVal }}" />');
|
||||
});
|
||||
|
||||
it('should invalidate', function() {
|
||||
@@ -1449,11 +1506,19 @@ describe('input', function() {
|
||||
expect(+$rootScope.value).toBe(+new Date(1970, 0, 1, 5, 30, 0));
|
||||
expect($rootScope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should validate if max is empty', function() {
|
||||
$rootScope.maxVal = undefined;
|
||||
$rootScope.value = new Date(9999, 11, 31, 23, 59, 59);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should validate even if max value changes on-the-fly', function() {
|
||||
$rootScope.max = '4:02:00';
|
||||
$rootScope.max = '04:02:00';
|
||||
var inputElm = helper.compileInput('<input type="time" ng-model="value" name="alias" max="{{max}}" />');
|
||||
|
||||
helper.changeInputValueTo('05:34:00');
|
||||
@@ -1481,7 +1546,7 @@ describe('input', function() {
|
||||
|
||||
|
||||
it('should validate even if ng-max value changes on-the-fly', function() {
|
||||
$rootScope.max = '4:02:00';
|
||||
$rootScope.max = '04:02:00';
|
||||
var inputElm = helper.compileInput('<input type="time" ng-model="value" name="alias" ng-max="max" />');
|
||||
|
||||
helper.changeInputValueTo('05:34:00');
|
||||
@@ -1706,6 +1771,16 @@ describe('input', function() {
|
||||
|
||||
expect($rootScope.form.myControl.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if min is empty', function() {
|
||||
var inputElm = helper.compileInput(
|
||||
'<input type="date" name="alias" ng-model="value" min />');
|
||||
|
||||
$rootScope.value = new Date(-9999, 0, 1, 0, 0, 0);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function() {
|
||||
@@ -1735,6 +1810,16 @@ describe('input', function() {
|
||||
|
||||
expect($rootScope.form.myControl.$error.max).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate if max is empty', function() {
|
||||
var inputElm = helper.compileInput(
|
||||
'<input type="date" name="alias" ng-model="value" max />');
|
||||
|
||||
$rootScope.value = new Date(9999, 11, 31, 23, 59, 59);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($rootScope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -2598,14 +2683,17 @@ describe('input', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should set the ngTrueValue when required directive is present', function() {
|
||||
var inputElm = helper.compileInput('<input type="checkbox" ng-model="value" required ng-true-value="\'yes\'" />');
|
||||
it('should pass validation for "required" when trueValue is a string', function() {
|
||||
var inputElm = helper.compileInput('<input type="checkbox" required name="cb"' +
|
||||
'ng-model="value" ng-true-value="\'yes\'" />');
|
||||
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect($rootScope.form.cb.$error.required).toBe(true);
|
||||
|
||||
browserTrigger(inputElm, 'click');
|
||||
expect(inputElm[0].checked).toBe(true);
|
||||
expect(inputElm).toBeValid();
|
||||
expect($rootScope.form.cb.$error.required).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -468,12 +468,12 @@ describe('ngClass animations', function() {
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($compile, $rootScope, $browser, $rootElement, $animate, $timeout, $$body) {
|
||||
inject(function($compile, $rootScope, $browser, $rootElement, $animate, $document) {
|
||||
$animate.enabled(true);
|
||||
|
||||
$rootScope.val = 'crazy';
|
||||
element = angular.element('<div ng-class="val"></div>');
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
$compile(element)($rootScope);
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ describe('ngModel', function() {
|
||||
};
|
||||
|
||||
element = jqLite('<form><input></form>');
|
||||
element.data('$formController', parentFormCtrl);
|
||||
|
||||
scope = $rootScope;
|
||||
ngModelAccessor = jasmine.createSpy('ngModel accessor');
|
||||
@@ -28,6 +27,9 @@ describe('ngModel', function() {
|
||||
$element: element.find('input'),
|
||||
$attrs: attrs
|
||||
});
|
||||
|
||||
//Assign the mocked parentFormCtrl to the model controller
|
||||
ctrl.$$parentForm = parentFormCtrl;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
@@ -2013,7 +2013,7 @@ describe('ngOptions', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should support biding via ngBind attribute', function() {
|
||||
it('should support binding via ngBind attribute', function() {
|
||||
var option;
|
||||
createSingleSelect('<option value="" ng-bind="blankVal"></option>');
|
||||
|
||||
@@ -2029,6 +2029,22 @@ describe('ngOptions', function() {
|
||||
expect(option.text()).toBe('is blank');
|
||||
});
|
||||
|
||||
it('should be ignored when it has no value attribute', function() {
|
||||
// The option value is set to the textContent if there's no value attribute,
|
||||
// so in that case it doesn't count as a blank option
|
||||
createSingleSelect('<option>--select--</option>');
|
||||
scope.$apply(function() {
|
||||
scope.values = [{name: 'A'}, {name: 'B'}, {name: 'C'}];
|
||||
});
|
||||
|
||||
var options = element.find('option');
|
||||
|
||||
expect(options.eq(0)).toEqualUnknownOption();
|
||||
expect(options.eq(1)).toEqualOption(scope.values[0], 'A');
|
||||
expect(options.eq(2)).toEqualOption(scope.values[1], 'B');
|
||||
expect(options.eq(3)).toEqualOption(scope.values[2], 'C');
|
||||
});
|
||||
|
||||
|
||||
it('should be rendered with the attributes preserved', function() {
|
||||
var option;
|
||||
@@ -2070,6 +2086,30 @@ describe('ngOptions', function() {
|
||||
expect(element[0].selectedIndex).toEqual(0);
|
||||
expect(scope.selected).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
it('should be possible to use ngIf in the blank option', function() {
|
||||
var option;
|
||||
createSingleSelect('<option ng-if="isBlank" value="">blank</option>');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.values = [{name: 'A'}];
|
||||
scope.isBlank = true;
|
||||
});
|
||||
|
||||
expect(element.find('option').length).toBe(2);
|
||||
option = element.find('option').eq(0);
|
||||
expect(option.val()).toBe('');
|
||||
expect(option.text()).toBe('blank');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.isBlank = false;
|
||||
});
|
||||
|
||||
expect(element.find('option').length).toBe(1);
|
||||
option = element.find('option').eq(0);
|
||||
expect(option.text()).toBe('A');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -166,6 +166,26 @@ describe('ngRepeat', function() {
|
||||
expect(element.text()).toEqual('age:20|wealth:20|prodname:Bingo|dogname:Bingo|codename:20|');
|
||||
});
|
||||
|
||||
|
||||
it('should iterate over on object created using `Object.create(null)`', function() {
|
||||
element = $compile(
|
||||
'<ul>' +
|
||||
'<li ng-repeat="(key, value) in items">{{key}}:{{value}}|</li>' +
|
||||
'</ul>')(scope);
|
||||
|
||||
var items = Object.create(null);
|
||||
items.misko = 'swe';
|
||||
items.shyam = 'set';
|
||||
|
||||
scope.items = items;
|
||||
scope.$digest();
|
||||
expect(element.text()).toEqual('misko:swe|shyam:set|');
|
||||
|
||||
delete items.shyam;
|
||||
scope.$digest();
|
||||
expect(element.text()).toEqual('misko:swe|');
|
||||
});
|
||||
|
||||
describe('track by', function() {
|
||||
it('should track using expression function', function() {
|
||||
element = $compile(
|
||||
|
||||
@@ -318,6 +318,26 @@ describe('select', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should support option without a value attribute', function() {
|
||||
compile('<select ng-model="robot">' +
|
||||
'<option>--select--</option>' +
|
||||
'<option value="x">robot x</option>' +
|
||||
'<option value="y">robot y</option>' +
|
||||
'</select>');
|
||||
expect(element).toEqualSelect(["? undefined:undefined ?"], "--select--", 'x', 'y');
|
||||
});
|
||||
|
||||
|
||||
it('should support option without a value with other HTML attributes', function() {
|
||||
compile('<select ng-model="robot">' +
|
||||
'<option data-foo="bar">--select--</option>' +
|
||||
'<option value="x">robot x</option>' +
|
||||
'<option value="y">robot y</option>' +
|
||||
'</select>');
|
||||
expect(element).toEqualSelect(["? undefined:undefined ?"], "--select--", 'x', 'y');
|
||||
});
|
||||
|
||||
|
||||
describe('interactions with repeated options', function() {
|
||||
|
||||
it('should select empty option when model is undefined', function() {
|
||||
@@ -964,22 +984,123 @@ describe('select', function() {
|
||||
|
||||
describe('option', function() {
|
||||
|
||||
it('should populate value attribute on OPTION', function() {
|
||||
it('should populate a missing value attribute with the option text', function() {
|
||||
compile('<select ng-model="x"><option selected>abc</option></select>');
|
||||
expect(element).toEqualSelect([unknownValue(undefined)], 'abc');
|
||||
});
|
||||
|
||||
it('should ignore value if already exists', function() {
|
||||
|
||||
it('should ignore the option text if the value attribute exists', function() {
|
||||
compile('<select ng-model="x"><option value="abc">xyz</option></select>');
|
||||
expect(element).toEqualSelect([unknownValue(undefined)], 'abc');
|
||||
});
|
||||
|
||||
|
||||
it('should set value even if self closing HTML', function() {
|
||||
scope.x = 'hello';
|
||||
compile('<select ng-model="x"><option>hello</select>');
|
||||
expect(element).toEqualSelect(['hello']);
|
||||
});
|
||||
|
||||
|
||||
it('should add options with interpolated value attributes', function() {
|
||||
scope.option1 = 'option1';
|
||||
scope.option2 = 'option2';
|
||||
|
||||
compile('<select ng-model="selected">' +
|
||||
'<option value="{{option1}}">Option 1</option>' +
|
||||
'<option value="{{option2}}">Option 2</option>' +
|
||||
'</select>');
|
||||
|
||||
scope.$digest();
|
||||
expect(scope.selected).toBeUndefined();
|
||||
|
||||
browserTrigger(element.find('option').eq(0));
|
||||
expect(scope.selected).toBe('option1');
|
||||
|
||||
scope.selected = 'option2';
|
||||
scope.$digest();
|
||||
expect(element.find('option').eq(1).prop('selected')).toBe(true);
|
||||
expect(element.find('option').eq(1).text()).toBe('Option 2');
|
||||
});
|
||||
|
||||
|
||||
it('should update the option when the interpolated value attribute changes', function() {
|
||||
scope.option1 = 'option1';
|
||||
scope.option2 = '';
|
||||
|
||||
compile('<select ng-model="selected">' +
|
||||
'<option value="{{option1}}">Option 1</option>' +
|
||||
'<option value="{{option2}}">Option 2</option>' +
|
||||
'</select>');
|
||||
|
||||
var selectCtrl = element.controller('select');
|
||||
spyOn(selectCtrl, 'removeOption').andCallThrough();
|
||||
|
||||
scope.$digest();
|
||||
expect(scope.selected).toBeUndefined();
|
||||
expect(selectCtrl.removeOption).not.toHaveBeenCalled();
|
||||
|
||||
//Change value of option2
|
||||
scope.option2 = 'option2Changed';
|
||||
scope.selected = 'option2Changed';
|
||||
scope.$digest();
|
||||
|
||||
expect(selectCtrl.removeOption).toHaveBeenCalledWith('');
|
||||
expect(element.find('option').eq(1).prop('selected')).toBe(true);
|
||||
expect(element.find('option').eq(1).text()).toBe('Option 2');
|
||||
});
|
||||
|
||||
|
||||
it('should add options with interpolated text', function() {
|
||||
scope.option1 = 'Option 1';
|
||||
scope.option2 = 'Option 2';
|
||||
|
||||
compile('<select ng-model="selected">' +
|
||||
'<option>{{option1}}</option>' +
|
||||
'<option>{{option2}}</option>' +
|
||||
'</select>');
|
||||
|
||||
scope.$digest();
|
||||
expect(scope.selected).toBeUndefined();
|
||||
|
||||
browserTrigger(element.find('option').eq(0));
|
||||
expect(scope.selected).toBe('Option 1');
|
||||
|
||||
scope.selected = 'Option 2';
|
||||
scope.$digest();
|
||||
expect(element.find('option').eq(1).prop('selected')).toBe(true);
|
||||
expect(element.find('option').eq(1).text()).toBe('Option 2');
|
||||
});
|
||||
|
||||
|
||||
it('should update options when their interpolated text changes', function() {
|
||||
scope.option1 = 'Option 1';
|
||||
scope.option2 = '';
|
||||
|
||||
compile('<select ng-model="selected">' +
|
||||
'<option>{{option1}}</option>' +
|
||||
'<option>{{option2}}</option>' +
|
||||
'</select>');
|
||||
|
||||
var selectCtrl = element.controller('select');
|
||||
spyOn(selectCtrl, 'removeOption').andCallThrough();
|
||||
|
||||
scope.$digest();
|
||||
expect(scope.selected).toBeUndefined();
|
||||
expect(selectCtrl.removeOption).not.toHaveBeenCalled();
|
||||
|
||||
//Change value of option2
|
||||
scope.option2 = 'Option 2 Changed';
|
||||
scope.selected = 'Option 2 Changed';
|
||||
scope.$digest();
|
||||
|
||||
expect(selectCtrl.removeOption).toHaveBeenCalledWith('');
|
||||
expect(element.find('option').eq(1).prop('selected')).toBe(true);
|
||||
expect(element.find('option').eq(1).text()).toBe('Option 2 Changed');
|
||||
});
|
||||
|
||||
|
||||
it('should not blow up when option directive is found inside of a datalist',
|
||||
inject(function($compile, $rootScope) {
|
||||
var element = $compile('<div>' +
|
||||
|
||||
@@ -219,6 +219,24 @@ describe('validators', function() {
|
||||
expect($rootScope.form.test.$modelValue).toBe('12340');
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
|
||||
it('should validate on non-input elements', inject(function($compile) {
|
||||
$rootScope.pattern = '\\d{4}';
|
||||
var elm = $compile('<span ng-model="value" pattern="\\d{4}"></span>')($rootScope);
|
||||
var elmNg = $compile('<span ng-model="value" ng-pattern="pattern"></span>')($rootScope);
|
||||
var ctrl = elm.controller('ngModel');
|
||||
var ctrlNg = elmNg.controller('ngModel');
|
||||
|
||||
expect(ctrl.$error.pattern).not.toBe(true);
|
||||
expect(ctrlNg.$error.pattern).not.toBe(true);
|
||||
|
||||
ctrl.$setViewValue('12');
|
||||
ctrlNg.$setViewValue('12');
|
||||
|
||||
expect(ctrl.$error.pattern).toBe(true);
|
||||
expect(ctrlNg.$error.pattern).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
@@ -283,6 +301,24 @@ describe('validators', function() {
|
||||
helper.changeInputValueTo('12345');
|
||||
expect(ctrl.$isEmpty).toHaveBeenCalledWith('12345');
|
||||
});
|
||||
|
||||
|
||||
it('should validate on non-input elements', inject(function($compile) {
|
||||
$rootScope.min = 3;
|
||||
var elm = $compile('<span ng-model="value" minlength="{{min}}"></span>')($rootScope);
|
||||
var elmNg = $compile('<span ng-model="value" ng-minlength="min"></span>')($rootScope);
|
||||
var ctrl = elm.controller('ngModel');
|
||||
var ctrlNg = elmNg.controller('ngModel');
|
||||
|
||||
expect(ctrl.$error.minlength).not.toBe(true);
|
||||
expect(ctrlNg.$error.minlength).not.toBe(true);
|
||||
|
||||
ctrl.$setViewValue('12');
|
||||
ctrlNg.$setViewValue('12');
|
||||
|
||||
expect(ctrl.$error.minlength).toBe(true);
|
||||
expect(ctrlNg.$error.minlength).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
@@ -453,6 +489,24 @@ describe('validators', function() {
|
||||
helper.changeInputValueTo('12345');
|
||||
expect(ctrl.$isEmpty).toHaveBeenCalledWith('12345');
|
||||
});
|
||||
|
||||
|
||||
it('should validate on non-input elements', inject(function($compile) {
|
||||
$rootScope.max = 3;
|
||||
var elm = $compile('<span ng-model="value" maxlength="{{max}}"></span>')($rootScope);
|
||||
var elmNg = $compile('<span ng-model="value" ng-maxlength="max"></span>')($rootScope);
|
||||
var ctrl = elm.controller('ngModel');
|
||||
var ctrlNg = elmNg.controller('ngModel');
|
||||
|
||||
expect(ctrl.$error.maxlength).not.toBe(true);
|
||||
expect(ctrlNg.$error.maxlength).not.toBe(true);
|
||||
|
||||
ctrl.$setViewValue('1234');
|
||||
ctrlNg.$setViewValue('1234');
|
||||
|
||||
expect(ctrl.$error.maxlength).toBe(true);
|
||||
expect(ctrlNg.$error.maxlength).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
@@ -547,6 +601,7 @@ describe('validators', function() {
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
|
||||
it('should validate emptiness against the viewValue', function() {
|
||||
var inputElm = helper.compileInput('<input type="text" name="input" ng-model="value" required />');
|
||||
|
||||
@@ -560,5 +615,23 @@ describe('validators', function() {
|
||||
helper.changeInputValueTo('12345');
|
||||
expect(ctrl.$isEmpty).toHaveBeenCalledWith('12345');
|
||||
});
|
||||
|
||||
|
||||
it('should validate on non-input elements', inject(function($compile) {
|
||||
$rootScope.value = '12';
|
||||
var elm = $compile('<span ng-model="value" required></span>')($rootScope);
|
||||
var elmNg = $compile('<span ng-model="value" ng-required="true"></span>')($rootScope);
|
||||
var ctrl = elm.controller('ngModel');
|
||||
var ctrlNg = elmNg.controller('ngModel');
|
||||
|
||||
expect(ctrl.$error.required).not.toBe(true);
|
||||
expect(ctrlNg.$error.required).not.toBe(true);
|
||||
|
||||
ctrl.$setViewValue('');
|
||||
ctrlNg.$setViewValue('');
|
||||
|
||||
expect(ctrl.$error.required).toBe(true);
|
||||
expect(ctrlNg.$error.required).toBe(true);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -62,6 +62,8 @@ describe('filters', function() {
|
||||
it('should format according different separators', function() {
|
||||
var num = formatNumber(1234567.1, pattern, '.', ',', 2);
|
||||
expect(num).toBe('1.234.567,10');
|
||||
num = formatNumber(1e-14, pattern, '.', ',', 14);
|
||||
expect(num).toBe('0,00000000000001');
|
||||
});
|
||||
|
||||
it('should format with or without fractionSize', function() {
|
||||
|
||||
@@ -44,21 +44,23 @@ describe('$httpBackend', function() {
|
||||
});
|
||||
|
||||
it('should pass null to send if no body is set', function() {
|
||||
$backend('GET', '/some-url', null, noop);
|
||||
$backend('GET', '/some-url', undefined, noop);
|
||||
xhr = MockXhr.$$lastInstance;
|
||||
|
||||
expect(xhr.$$data).toBe(null);
|
||||
});
|
||||
|
||||
it('should pass the correct falsy value to send if falsy body is set (excluding NaN)', function() {
|
||||
var values = [false, 0, "", null, undefined];
|
||||
angular.forEach(values, function(value) {
|
||||
$backend('GET', '/some-url', value, noop);
|
||||
xhr = MockXhr.$$lastInstance;
|
||||
it('should pass the correct falsy value to send if falsy body is set (excluding undefined, NaN)',
|
||||
function() {
|
||||
var values = [false, 0, "", null];
|
||||
angular.forEach(values, function(value) {
|
||||
$backend('GET', '/some-url', value, noop);
|
||||
xhr = MockXhr.$$lastInstance;
|
||||
|
||||
expect(xhr.$$data).toBe(value);
|
||||
});
|
||||
});
|
||||
expect(xhr.$$data).toBe(value);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should pass NaN to send if NaN body is set', function() {
|
||||
$backend('GET', '/some-url', NaN, noop);
|
||||
@@ -231,6 +233,13 @@ describe('$httpBackend', function() {
|
||||
expect(MockXhr.$$lastInstance.withCredentials).toBe(true);
|
||||
});
|
||||
|
||||
it('should call $xhrFactory with method and url', function() {
|
||||
var mockXhrFactory = jasmine.createSpy('mockXhrFactory').andCallFake(createMockXhr);
|
||||
$backend = createHttpBackend($browser, mockXhrFactory, $browser.defer, callbacks, fakeDocument);
|
||||
$backend('GET', '/some-url', 'some-data', noop);
|
||||
expect(mockXhrFactory).toHaveBeenCalledWith('GET', '/some-url');
|
||||
});
|
||||
|
||||
|
||||
describe('responseType', function() {
|
||||
|
||||
|
||||
+14
-13
@@ -764,8 +764,8 @@ describe('$http', function() {
|
||||
$httpBackend.expect('POST', '/url', 'messageBody', function(headers) {
|
||||
return headers['accept'] == 'Rewritten' &&
|
||||
headers['content-type'] == 'Content-Type Rewritten' &&
|
||||
headers['Accept'] === undefined &&
|
||||
headers['Content-Type'] === undefined;
|
||||
isUndefined(headers['Accept']) &&
|
||||
isUndefined(headers['Content-Type']);
|
||||
}).respond('');
|
||||
|
||||
$http({url: '/url', method: 'POST', data: 'messageBody', headers: {
|
||||
@@ -779,7 +779,7 @@ describe('$http', function() {
|
||||
mockedCookies['XSRF-TOKEN'] = 'secret';
|
||||
$browser.url('http://host.com/base');
|
||||
$httpBackend.expect('GET', 'http://www.test.com/url', undefined, function(headers) {
|
||||
return headers['X-XSRF-TOKEN'] === undefined;
|
||||
return isUndefined(headers['X-XSRF-TOKEN']);
|
||||
}).respond('');
|
||||
|
||||
$http({url: 'http://www.test.com/url', method: 'GET', headers: {}});
|
||||
@@ -933,12 +933,13 @@ describe('$http', function() {
|
||||
it('should handle empty response header', function() {
|
||||
$httpBackend.expect('GET', '/url', undefined)
|
||||
.respond(200, '', { 'Custom-Empty-Response-Header': '', 'Constructor': '' });
|
||||
$http.get('/url').success(callback);
|
||||
$http.get('/url').then(callback);
|
||||
$httpBackend.flush();
|
||||
expect(callback).toHaveBeenCalledOnce();
|
||||
expect(callback.mostRecentCall.args[2]('custom-empty-response-Header')).toBe('');
|
||||
expect(callback.mostRecentCall.args[2]('ToString')).toBe(null);
|
||||
expect(callback.mostRecentCall.args[2]('Constructor')).toBe('');
|
||||
var headers = callback.mostRecentCall.args[0].headers;
|
||||
expect(headers('custom-empty-response-Header')).toEqual('');
|
||||
expect(headers('ToString')).toBe(null);
|
||||
expect(headers('Constructor')).toBe('');
|
||||
});
|
||||
|
||||
it('should have delete()', function() {
|
||||
@@ -1731,12 +1732,12 @@ describe('$http', function() {
|
||||
|
||||
$httpBackend.expect('GET', '/some').respond(200);
|
||||
|
||||
$http({method: 'GET', url: '/some', timeout: canceler.promise}).error(
|
||||
function(data, status, headers, config) {
|
||||
expect(data).toBeUndefined();
|
||||
expect(status).toBe(0);
|
||||
expect(headers()).toEqual({});
|
||||
expect(config.url).toBe('/some');
|
||||
$http({method: 'GET', url: '/some', timeout: canceler.promise}).catch(
|
||||
function(response) {
|
||||
expect(response.data).toBeUndefined();
|
||||
expect(response.status).toBe(-1);
|
||||
expect(response.headers()).toEqual({});
|
||||
expect(response.config.url).toBe('/some');
|
||||
callback();
|
||||
});
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('$interval', function() {
|
||||
if (fn.id === id) fnIndex = index;
|
||||
});
|
||||
|
||||
if (fnIndex !== undefined) {
|
||||
if (isDefined(fnIndex)) {
|
||||
repeatFns.splice(fnIndex, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
+64
-6
@@ -1679,12 +1679,10 @@ describe('parser', function() {
|
||||
forEach([true, false], function(cspEnabled) {
|
||||
describe('csp: ' + cspEnabled, function() {
|
||||
|
||||
beforeEach(module(function($provide) {
|
||||
$provide.decorator('$sniffer', function($delegate) {
|
||||
expect($delegate.csp.noUnsafeEval === true ||
|
||||
$delegate.csp.noUnsafeEval === false).toEqual(true);
|
||||
$delegate.csp.noUnsafeEval = cspEnabled;
|
||||
});
|
||||
beforeEach(module(function() {
|
||||
expect(csp().noUnsafeEval === true ||
|
||||
csp().noUnsafeEval === false).toEqual(true);
|
||||
csp().noUnsafeEval = cspEnabled;
|
||||
}, provideLog));
|
||||
|
||||
beforeEach(inject(function($rootScope) {
|
||||
@@ -2669,6 +2667,20 @@ describe('parser', function() {
|
||||
scope.$eval('{}["__proto__"].foo = 1');
|
||||
}).toThrowMinErr('$parse', 'isecfld');
|
||||
|
||||
expect(function() {
|
||||
scope.$eval('{}[["__proto__"]]');
|
||||
}).toThrowMinErr('$parse', 'isecfld');
|
||||
expect(function() {
|
||||
scope.$eval('{}[["__proto__"]].foo = 1');
|
||||
}).toThrowMinErr('$parse', 'isecfld');
|
||||
|
||||
expect(function() {
|
||||
scope.$eval('0[["__proto__"]]');
|
||||
}).toThrowMinErr('$parse', 'isecfld');
|
||||
expect(function() {
|
||||
scope.$eval('0[["__proto__"]].foo = 1');
|
||||
}).toThrowMinErr('$parse', 'isecfld');
|
||||
|
||||
scope.a = "__pro";
|
||||
scope.b = "to__";
|
||||
expect(function() {
|
||||
@@ -2680,6 +2692,15 @@ describe('parser', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should prevent the exploit', function() {
|
||||
expect(function() {
|
||||
scope.$eval('(1)[{0: "__proto__", 1: "__proto__", 2: "__proto__", 3: "safe", length: 4, toString: [].pop}].foo = 1');
|
||||
}).toThrow();
|
||||
if (!msie || msie > 10) {
|
||||
expect((1)['__proto__'].foo).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('should prevent the exploit', function() {
|
||||
expect(function() {
|
||||
scope.$eval('' +
|
||||
@@ -2691,6 +2712,35 @@ describe('parser', function() {
|
||||
'');
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
it('should prevent assigning in the context of a constructor', function() {
|
||||
expect(function() {
|
||||
scope.$eval("''.constructor.join");
|
||||
}).not.toThrow();
|
||||
expect(function() {
|
||||
scope.$eval("''.constructor.join = ''.constructor.join");
|
||||
}).toThrow();
|
||||
expect(function() {
|
||||
scope.$eval("''.constructor[0] = ''");
|
||||
}).toThrow();
|
||||
expect(function() {
|
||||
scope.$eval("(0).constructor[0] = ''");
|
||||
}).toThrow();
|
||||
expect(function() {
|
||||
scope.$eval("{}.constructor[0] = ''");
|
||||
}).toThrow();
|
||||
// foo.constructor is the object constructor.
|
||||
expect(function() {
|
||||
scope.$eval("foo.constructor[0] = ''", {foo: {}});
|
||||
}).toThrow();
|
||||
// foo.constructor is not a constructor.
|
||||
expect(function() {
|
||||
scope.$eval("foo.constructor[0] = ''", {foo: {constructor: ''}});
|
||||
}).not.toThrow();
|
||||
expect(function() {
|
||||
scope.$eval("objConstructor = {}.constructor; objConstructor.join = ''");
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the function from the received instance and not from a new one', function() {
|
||||
@@ -2797,6 +2847,14 @@ describe('parser', function() {
|
||||
expect(scope).toEqual({a:123});
|
||||
}));
|
||||
|
||||
it('should return the assigned value', inject(function($parse) {
|
||||
var fn = $parse('a');
|
||||
var scope = {};
|
||||
expect(fn.assign(scope, 123)).toBe(123);
|
||||
var someObject = {};
|
||||
expect(fn.assign(scope, someObject)).toBe(someObject);
|
||||
}));
|
||||
|
||||
it('should expose working assignment function for expressions ending with brackets', inject(function($parse) {
|
||||
var fn = $parse('a.b["c"]');
|
||||
expect(fn.assign).toBeTruthy();
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ describe('q', function() {
|
||||
log.push(logPrefix + '->throw(' + _argToString(returnVal) + ')');
|
||||
throw returnVal;
|
||||
} else {
|
||||
if (returnVal === undefined) {
|
||||
if (isUndefined(returnVal)) {
|
||||
log.push(logPrefix);
|
||||
} else {
|
||||
log.push(logPrefix + '->' + _argToString(returnVal));
|
||||
|
||||
@@ -822,6 +822,7 @@ describe('Scope', function() {
|
||||
expect(log.empty()).toEqual([{newVal: {b: {}, c: 'B'}, oldVal: {a: [], b: {}, c: 'B'}}]);
|
||||
});
|
||||
|
||||
|
||||
it('should not infinitely digest when current value is NaN', function() {
|
||||
$rootScope.obj = {a: NaN};
|
||||
expect(function() {
|
||||
@@ -829,6 +830,18 @@ describe('Scope', function() {
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
|
||||
it('should handle objects created using `Object.create(null)`', function() {
|
||||
$rootScope.obj = Object.create(null);
|
||||
$rootScope.obj.a = 'a';
|
||||
$rootScope.obj.b = 'b';
|
||||
$rootScope.$digest();
|
||||
expect(log.empty()[0].newVal).toEqual({a: 'a', b: 'b'});
|
||||
|
||||
delete $rootScope.obj.b;
|
||||
$rootScope.$digest();
|
||||
expect(log.empty()[0].newVal).toEqual({a: 'a'});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -282,10 +282,10 @@ describe('SCE', function() {
|
||||
function runTest(cfg, testFn) {
|
||||
return function() {
|
||||
module(function($sceDelegateProvider) {
|
||||
if (cfg.whiteList !== undefined) {
|
||||
if (isDefined(cfg.whiteList)) {
|
||||
$sceDelegateProvider.resourceUrlWhitelist(cfg.whiteList);
|
||||
}
|
||||
if (cfg.blackList !== undefined) {
|
||||
if (isDefined(cfg.blackList)) {
|
||||
$sceDelegateProvider.resourceUrlBlacklist(cfg.blackList);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -121,7 +121,7 @@ describe("ngAnimate $$animateCssDriver", function() {
|
||||
var from, to, fromAnimation, toAnimation;
|
||||
|
||||
beforeEach(module(function() {
|
||||
return function($rootElement, $$body) {
|
||||
return function($rootElement, $document) {
|
||||
from = element;
|
||||
to = jqLite('<div></div>');
|
||||
fromAnimation = { element: from, event: 'enter' };
|
||||
@@ -129,8 +129,14 @@ describe("ngAnimate $$animateCssDriver", function() {
|
||||
$rootElement.append(from);
|
||||
$rootElement.append(to);
|
||||
|
||||
// we need to do this so that style detection works
|
||||
$$body.append($rootElement);
|
||||
var doc = $document[0];
|
||||
|
||||
// there is one test in here that expects the rootElement
|
||||
// to superceed the body node
|
||||
if (!$rootElement[0].contains(doc.body)) {
|
||||
// we need to do this so that style detection works
|
||||
jqLite(doc.body).append($rootElement);
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
@@ -975,6 +981,39 @@ describe("ngAnimate $$animateCssDriver", function() {
|
||||
|
||||
expect(completed).toBe(true);
|
||||
}));
|
||||
|
||||
it("should use <body> as the element container if the rootElement exists outside of the <body> tag", function() {
|
||||
module(function($provide) {
|
||||
$provide.factory('$rootElement', function($document) {
|
||||
return jqLite($document[0].querySelector('html'));
|
||||
});
|
||||
});
|
||||
inject(function($rootElement, $rootScope, $animate, $document) {
|
||||
ss.addRule('.ending-element', 'width:9999px; height:6666px; display:inline-block;');
|
||||
|
||||
var fromAnchor = jqLite('<div></div>');
|
||||
from.append(fromAnchor);
|
||||
|
||||
var toAnchor = jqLite('<div></div>');
|
||||
to.append(toAnchor);
|
||||
|
||||
$rootElement.append(fromAnchor);
|
||||
$rootElement.append(toAnchor);
|
||||
|
||||
var completed = false;
|
||||
driver({
|
||||
from: fromAnimation,
|
||||
to: toAnimation,
|
||||
anchors: [{
|
||||
'out': fromAnchor,
|
||||
'in': toAnchor
|
||||
}]
|
||||
}).start();
|
||||
|
||||
var clone = captureLog[2].element[0];
|
||||
expect(clone.parentNode).toBe($document[0].body);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,12 +35,12 @@ describe("ngAnimate $animateCss", function() {
|
||||
});
|
||||
|
||||
it("should return false if neither transitions or keyframes are supported by the browser",
|
||||
inject(function($animateCss, $sniffer, $rootElement, $$body) {
|
||||
inject(function($animateCss, $sniffer, $rootElement, $document) {
|
||||
|
||||
var animator;
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
$sniffer.transitions = $sniffer.animations = false;
|
||||
animator = $animateCss(element, {
|
||||
@@ -54,13 +54,13 @@ describe("ngAnimate $animateCss", function() {
|
||||
if (!browserSupportsCssAnimations()) return;
|
||||
|
||||
it("should not attempt an animation if animations are globally disabled",
|
||||
inject(function($animateCss, $animate, $rootElement, $$body) {
|
||||
inject(function($animateCss, $animate, $rootElement, $document) {
|
||||
|
||||
$animate.enabled(false);
|
||||
|
||||
var animator, element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
animator = $animateCss(element, {
|
||||
duration: 10,
|
||||
@@ -109,9 +109,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
describe("rAF usage", function() {
|
||||
it("should buffer all requests into a single requestAnimationFrame call",
|
||||
inject(function($animateCss, $$rAF, $rootScope, $$body, $rootElement) {
|
||||
inject(function($animateCss, $$rAF, $rootScope, $document, $rootElement) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var count = 0;
|
||||
var runners = [];
|
||||
@@ -149,8 +149,8 @@ describe("ngAnimate $animateCss", function() {
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($animateCss, $$rAF, $$body, $rootElement) {
|
||||
$$body.append($rootElement);
|
||||
inject(function($animateCss, $$rAF, $document, $rootElement) {
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
function makeRequest() {
|
||||
var element = jqLite('<div></div>');
|
||||
@@ -169,10 +169,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
describe("animator and runner", function() {
|
||||
var animationDuration = 5;
|
||||
var element, animator;
|
||||
beforeEach(inject(function($animateCss, $rootElement, $$body) {
|
||||
beforeEach(inject(function($animateCss, $rootElement, $document) {
|
||||
element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
animator = $animateCss(element, {
|
||||
event: 'enter',
|
||||
@@ -365,10 +365,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
{ timeStamp: Date.now() + ((delay || 1) * 1000), elapsedTime: duration });
|
||||
}
|
||||
|
||||
beforeEach(inject(function($rootElement, $$body) {
|
||||
beforeEach(inject(function($rootElement, $document) {
|
||||
element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
options = { event: 'enter', structural: true };
|
||||
}));
|
||||
|
||||
@@ -638,9 +638,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
describe("staggering", function() {
|
||||
it("should apply a stagger based when an active ng-EVENT-stagger class with a transition-delay is detected",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.ng-enter-stagger', 'transition-delay:0.2s');
|
||||
ss.addRule('.ng-enter', 'transition:2s linear all');
|
||||
@@ -679,9 +679,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should apply a stagger based when for all provided addClass/removeClass CSS classes",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.red-add-stagger,' +
|
||||
'.blue-remove-stagger,' +
|
||||
@@ -749,9 +749,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should block the transition animation between start and animate when staggered",
|
||||
inject(function($animateCss, $$body, $rootElement) {
|
||||
inject(function($animateCss, $document, $rootElement) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.ng-enter-stagger', 'transition-delay:0.2s');
|
||||
ss.addRule('.ng-enter', 'transition:2s linear all;');
|
||||
@@ -780,9 +780,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should block (pause) the keyframe animation between start and animate when staggered",
|
||||
inject(function($animateCss, $$body, $rootElement) {
|
||||
inject(function($animateCss, $document, $rootElement) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.ng-enter-stagger', prefix + 'animation-delay:0.2s');
|
||||
ss.addRule('.ng-enter', prefix + 'animation:my_animation 2s;');
|
||||
@@ -809,9 +809,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should not apply a stagger if the transition delay value is inherited from a earlier CSS class",
|
||||
inject(function($animateCss, $$body, $rootElement) {
|
||||
inject(function($animateCss, $document, $rootElement) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.transition-animation', 'transition:2s 5s linear all;');
|
||||
|
||||
@@ -828,9 +828,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should apply a stagger only if the transition duration value is zero when inherited from a earlier CSS class",
|
||||
inject(function($animateCss, $$body, $rootElement) {
|
||||
inject(function($animateCss, $document, $rootElement) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.transition-animation', 'transition:2s 5s linear all;');
|
||||
ss.addRule('.transition-animation.ng-enter-stagger',
|
||||
@@ -854,9 +854,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
|
||||
it("should ignore animation staggers if only transition animations were detected",
|
||||
inject(function($animateCss, $$body, $rootElement) {
|
||||
inject(function($animateCss, $document, $rootElement) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.ng-enter-stagger', prefix + 'animation-delay:0.2s');
|
||||
ss.addRule('.transition-animation', 'transition:2s 5s linear all;');
|
||||
@@ -874,9 +874,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should ignore transition staggers if only keyframe animations were detected",
|
||||
inject(function($animateCss, $$body, $rootElement) {
|
||||
inject(function($animateCss, $document, $rootElement) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.ng-enter-stagger', 'transition-delay:0.2s');
|
||||
ss.addRule('.transition-animation', prefix + 'animation:2s 5s my_animation;');
|
||||
@@ -894,9 +894,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should start on the highest stagger value if both transition and keyframe staggers are used together",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout, $browser) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout, $browser) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.ng-enter-stagger', 'transition-delay:0.5s;' +
|
||||
prefix + 'animation-delay:1s');
|
||||
@@ -932,9 +932,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should apply the closing timeout ontop of the stagger timeout",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout, $browser) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout, $browser) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.ng-enter-stagger', 'transition-delay:1s;');
|
||||
ss.addRule('.ng-enter', 'transition:10s linear all;');
|
||||
@@ -959,9 +959,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should apply the closing timeout ontop of the stagger timeout with an added delay",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout, $browser) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout, $browser) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.ng-enter-stagger', 'transition-delay:1s;');
|
||||
ss.addRule('.ng-enter', 'transition:10s linear all; transition-delay:50s;');
|
||||
@@ -986,9 +986,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should issue a stagger if a stagger value is provided in the options",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
ss.addRule('.ng-enter', 'transition:2s linear all');
|
||||
|
||||
var elm, i, elements = [];
|
||||
@@ -1025,9 +1025,9 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should only add/remove classes once the stagger timeout has passed",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout) {
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var element = jqLite('<div class="green"></div>');
|
||||
$rootElement.append(element);
|
||||
@@ -1052,13 +1052,13 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
describe("closing timeout", function() {
|
||||
it("should close off the animation after 150% of the animation time has passed",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout) {
|
||||
|
||||
ss.addRule('.ng-enter', 'transition:10s linear all;');
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var animator = $animateCss(element, { event: 'enter', structural: true });
|
||||
animator.start();
|
||||
@@ -1075,13 +1075,13 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should close off the animation after 150% of the animation time has passed and consider the detected delay value",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout) {
|
||||
|
||||
ss.addRule('.ng-enter', 'transition:10s linear all; transition-delay:30s;');
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var animator = $animateCss(element, { event: 'enter', structural: true });
|
||||
animator.start();
|
||||
@@ -1098,13 +1098,13 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should still resolve the animation once expired",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout, $animate, $rootScope) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout, $animate, $rootScope) {
|
||||
|
||||
ss.addRule('.ng-enter', 'transition:10s linear all;');
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var animator = $animateCss(element, { event: 'enter', structural: true });
|
||||
|
||||
@@ -1123,13 +1123,13 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should not resolve/reject after passing if the animation completed successfully",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout, $rootScope, $animate) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout, $rootScope, $animate) {
|
||||
|
||||
ss.addRule('.ng-enter', 'transition:10s linear all;');
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var animator = $animateCss(element, { event: 'enter', structural: true });
|
||||
|
||||
@@ -1160,7 +1160,7 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should close all stacked animations after the last timeout runs on the same element",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout, $animate) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout, $animate) {
|
||||
|
||||
var now = 0;
|
||||
spyOn(Date, 'now').andCallFake(function() {
|
||||
@@ -1177,7 +1177,7 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
var element = jqLite('<div class="elm"></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
// timeout will be at 1500s
|
||||
animate(element, 'red', doneSpy);
|
||||
@@ -1218,11 +1218,11 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should not throw an error any pending timeout requests resolve after the element has already been removed",
|
||||
inject(function($animateCss, $$body, $rootElement, $timeout, $animate) {
|
||||
inject(function($animateCss, $document, $rootElement, $timeout, $animate) {
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.red', 'transition:1s linear all;');
|
||||
|
||||
@@ -1255,8 +1255,8 @@ describe("ngAnimate $animateCss", function() {
|
||||
}
|
||||
}));
|
||||
|
||||
return function($$body, $rootElement) {
|
||||
$$body.append($rootElement);
|
||||
return function($document, $rootElement) {
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
};
|
||||
}));
|
||||
|
||||
@@ -1340,7 +1340,7 @@ describe("ngAnimate $animateCss", function() {
|
||||
});
|
||||
|
||||
it('should avoid applying the same cache to an element a follow-up animation is run on the same element',
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
|
||||
function endTransition(element, elapsedTime) {
|
||||
browserTrigger(element, 'transitionend',
|
||||
@@ -1357,7 +1357,7 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
startAnimation(element, 0.5, 'red');
|
||||
expect(element.attr('style')).toContain('transition');
|
||||
@@ -1377,14 +1377,14 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it("should clear cache if no animation so follow-up animation on the same element will not be from cache",
|
||||
inject(function($animateCss, $rootElement, $$body, $$rAF) {
|
||||
inject(function($animateCss, $rootElement, $document, $$rAF) {
|
||||
var element = jqLite('<div class="rclass"></div>');
|
||||
var options = {
|
||||
event: 'enter',
|
||||
structural: true
|
||||
};
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
var animator = $animateCss(element, options);
|
||||
expect(animator.$$willAnimate).toBeFalsy();
|
||||
|
||||
@@ -1396,11 +1396,11 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
|
||||
it('should apply a custom temporary class when a non-structural animation is used',
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
$animateCss(element, {
|
||||
event: 'super',
|
||||
@@ -1416,10 +1416,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
describe("structural animations", function() {
|
||||
they('should decorate the element with the ng-$prop CSS class',
|
||||
['enter', 'leave', 'move'], function(event) {
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
$animateCss(element, {
|
||||
event: event,
|
||||
@@ -1433,10 +1433,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
they('should decorate the element with the ng-$prop-active CSS class',
|
||||
['enter', 'leave', 'move'], function(event) {
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var animator = $animateCss(element, {
|
||||
event: event,
|
||||
@@ -1454,10 +1454,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
they('should remove the ng-$prop and ng-$prop-active CSS classes from the element once the animation is done',
|
||||
['enter', 'leave', 'move'], function(event) {
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var animator = $animateCss(element, {
|
||||
event: event,
|
||||
@@ -1511,10 +1511,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
they('should place a CSS transition block after the preparation function to block accidental style changes',
|
||||
['enter', 'leave', 'move', 'addClass', 'removeClass'], function(event) {
|
||||
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.cool-animation', 'transition:1.5s linear all;');
|
||||
element.addClass('cool-animation');
|
||||
@@ -1541,10 +1541,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
they('should not place a CSS transition block if options.skipBlocking is provided',
|
||||
['enter', 'leave', 'move', 'addClass', 'removeClass'], function(event) {
|
||||
|
||||
inject(function($animateCss, $rootElement, $$body, $window) {
|
||||
inject(function($animateCss, $rootElement, $document, $window) {
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.cool-animation', 'transition:1.5s linear all;');
|
||||
element.addClass('cool-animation');
|
||||
@@ -1582,10 +1582,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
they('should place a CSS transition block after the preparation function even if a duration is provided',
|
||||
['enter', 'leave', 'move', 'addClass', 'removeClass'], function(event) {
|
||||
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
ss.addRule('.cool-animation', 'transition:1.5s linear all;');
|
||||
element.addClass('cool-animation');
|
||||
@@ -1616,11 +1616,11 @@ describe("ngAnimate $animateCss", function() {
|
||||
});
|
||||
|
||||
it('should allow multiple events to be animated at the same time',
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
$animateCss(element, {
|
||||
event: ['enter', 'leave', 'move'],
|
||||
@@ -1688,10 +1688,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
they('should remove the class-$prop-add and class-$prop-active CSS classes from the element once the animation is done',
|
||||
['enter', 'leave', 'move'], function(event) {
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
var element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var options = {};
|
||||
options.event = event;
|
||||
@@ -1713,7 +1713,7 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
they('should allow the class duration styles to be recalculated once started if the CSS classes being applied result new transition styles',
|
||||
['add', 'remove'], function(event) {
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
|
||||
@@ -1728,7 +1728,7 @@ describe("ngAnimate $animateCss", function() {
|
||||
}
|
||||
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var options = {};
|
||||
options[event + 'Class'] = 'natural-class';
|
||||
@@ -1749,13 +1749,13 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
they('should force the class-based values to be applied early if no options.applyClassEarly is used as an option',
|
||||
['enter', 'leave', 'move'], function(event) {
|
||||
inject(function($animateCss, $rootElement, $$body) {
|
||||
inject(function($animateCss, $rootElement, $document) {
|
||||
|
||||
ss.addRule('.blue.ng-' + event, 'transition:2s linear all;');
|
||||
|
||||
var element = jqLite('<div class="red"></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
var runner = $animateCss(element, {
|
||||
addClass: 'blue',
|
||||
@@ -1790,8 +1790,8 @@ describe("ngAnimate $animateCss", function() {
|
||||
describe("options", function() {
|
||||
var element;
|
||||
beforeEach(module(function() {
|
||||
return function($rootElement, $$body) {
|
||||
$$body.append($rootElement);
|
||||
return function($rootElement, $document) {
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
@@ -2741,10 +2741,10 @@ describe("ngAnimate $animateCss", function() {
|
||||
describe("[easing]", function() {
|
||||
|
||||
var element;
|
||||
beforeEach(inject(function($$body, $rootElement) {
|
||||
beforeEach(inject(function($document, $rootElement) {
|
||||
element = jqLite('<div></div>');
|
||||
$rootElement.append(element);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
}));
|
||||
|
||||
it("should apply easing to a transition animation if it exists", inject(function($animateCss) {
|
||||
@@ -2786,6 +2786,71 @@ describe("ngAnimate $animateCss", function() {
|
||||
}));
|
||||
});
|
||||
|
||||
describe("[cleanupStyles]", function() {
|
||||
it("should cleanup [from] and [to] styles that have been applied for the animation when true",
|
||||
inject(function($animateCss) {
|
||||
|
||||
var runner = $animateCss(element, {
|
||||
duration: 1,
|
||||
from: { background: 'gold' },
|
||||
to: { color: 'brown' },
|
||||
cleanupStyles: true
|
||||
}).start();
|
||||
|
||||
assertStyleIsPresent(element, 'background', true);
|
||||
assertStyleIsPresent(element, 'color', false);
|
||||
|
||||
triggerAnimationStartFrame();
|
||||
|
||||
assertStyleIsPresent(element, 'background', true);
|
||||
assertStyleIsPresent(element, 'color', true);
|
||||
|
||||
runner.end();
|
||||
|
||||
assertStyleIsPresent(element, 'background', false);
|
||||
assertStyleIsPresent(element, 'color', false);
|
||||
|
||||
function assertStyleIsPresent(element, style, bool) {
|
||||
expect(element[0].style[style])[bool ? 'toBeTruthy' : 'toBeFalsy']();
|
||||
}
|
||||
}));
|
||||
|
||||
it('should restore existing overidden styles already present on the element when true',
|
||||
inject(function($animateCss) {
|
||||
|
||||
element.css('height', '100px');
|
||||
element.css('width', '111px');
|
||||
|
||||
var runner = $animateCss(element, {
|
||||
duration: 1,
|
||||
from: { height: '200px', 'font-size':'66px' },
|
||||
to: { height: '300px', 'font-size': '99px', width: '222px' },
|
||||
cleanupStyles: true
|
||||
}).start();
|
||||
|
||||
assertStyle(element, 'height', '200px');
|
||||
assertStyle(element, 'font-size', '66px');
|
||||
assertStyle(element, 'width', '111px');
|
||||
|
||||
triggerAnimationStartFrame();
|
||||
|
||||
assertStyle(element, 'height', '300px');
|
||||
assertStyle(element, 'width', '222px');
|
||||
assertStyle(element, 'font-size', '99px');
|
||||
|
||||
runner.end();
|
||||
|
||||
assertStyle(element, 'width', '111px');
|
||||
assertStyle(element, 'height', '100px');
|
||||
|
||||
expect(element[0].style.getPropertyValue('font-size')).not.toBe('66px');
|
||||
|
||||
function assertStyle(element, prop, value) {
|
||||
expect(element[0].style.getPropertyValue(prop)).toBe(value);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
it('should round up long elapsedTime values to close off a CSS3 animation',
|
||||
inject(function($animateCss) {
|
||||
|
||||
@@ -2812,13 +2877,13 @@ describe("ngAnimate $animateCss", function() {
|
||||
|
||||
describe('SVG', function() {
|
||||
it('should properly apply transitions on an SVG element',
|
||||
inject(function($animateCss, $rootScope, $compile, $$body, $rootElement) {
|
||||
inject(function($animateCss, $rootScope, $compile, $document, $rootElement) {
|
||||
|
||||
var element = $compile('<svg width="500" height="500">' +
|
||||
'<circle cx="15" cy="5" r="100" fill="orange" />' +
|
||||
'</svg>')($rootScope);
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
$rootElement.append(element);
|
||||
|
||||
$animateCss(element, {
|
||||
|
||||
@@ -26,12 +26,12 @@ describe("animations", function() {
|
||||
});
|
||||
});
|
||||
|
||||
inject(function($animate, $rootScope, $$body) {
|
||||
inject(function($animate, $rootScope, $document) {
|
||||
$animate.enabled(true);
|
||||
|
||||
element = jqLite('<div></div>');
|
||||
|
||||
$animate.enter(element, $$body);
|
||||
$animate.enter(element, jqLite($document[0].body));
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(capturedAnimation).toBeTruthy();
|
||||
@@ -116,7 +116,7 @@ describe("animations", function() {
|
||||
return overriddenAnimationRunner || defaultFakeAnimationRunner;
|
||||
});
|
||||
|
||||
return function($rootElement, $q, $animate, $$AnimateRunner, $$body) {
|
||||
return function($rootElement, $q, $animate, $$AnimateRunner, $document) {
|
||||
defaultFakeAnimationRunner = new $$AnimateRunner();
|
||||
$animate.enabled(true);
|
||||
|
||||
@@ -126,7 +126,7 @@ describe("animations", function() {
|
||||
|
||||
$rootElement.append(parent);
|
||||
$rootElement.append(parent2);
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
};
|
||||
}));
|
||||
|
||||
@@ -749,7 +749,7 @@ describe("animations", function() {
|
||||
}));
|
||||
|
||||
it("should disable all child animations for atleast one turn when a structural animation is issued",
|
||||
inject(function($animate, $rootScope, $compile, $$body, $rootElement, $$AnimateRunner) {
|
||||
inject(function($animate, $rootScope, $compile, $document, $rootElement, $$AnimateRunner) {
|
||||
|
||||
element = $compile(
|
||||
'<div><div class="if-animation" ng-if="items.length">' +
|
||||
@@ -759,7 +759,7 @@ describe("animations", function() {
|
||||
'</div></div>'
|
||||
)($rootScope);
|
||||
|
||||
$$body.append($rootElement);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
$rootElement.append(element);
|
||||
|
||||
var runner = new $$AnimateRunner();
|
||||
@@ -890,7 +890,6 @@ describe("animations", function() {
|
||||
});
|
||||
|
||||
$rootScope.$digest();
|
||||
$animate.flush();
|
||||
expect(capturedAnimation).toBeTruthy();
|
||||
expect(runner1done).toBeFalsy();
|
||||
|
||||
@@ -910,7 +909,6 @@ describe("animations", function() {
|
||||
});
|
||||
|
||||
$rootScope.$digest();
|
||||
$animate.flush();
|
||||
expect(capturedAnimation).toBeTruthy();
|
||||
expect(runner2done).toBeFalsy();
|
||||
|
||||
@@ -990,8 +988,6 @@ describe("animations", function() {
|
||||
var doneHandler = jasmine.createSpy('addClass done');
|
||||
runner.done(doneHandler);
|
||||
|
||||
$animate.flush();
|
||||
|
||||
expect(doneHandler).not.toHaveBeenCalled();
|
||||
|
||||
$animate.removeClass(element, 'active-class');
|
||||
@@ -1011,8 +1007,6 @@ describe("animations", function() {
|
||||
var doneHandler = jasmine.createSpy('addClass done');
|
||||
runner.done(doneHandler);
|
||||
|
||||
$animate.flush();
|
||||
|
||||
expect(doneHandler).not.toHaveBeenCalled();
|
||||
|
||||
$animate.addClass(element, 'active-class');
|
||||
@@ -1284,8 +1278,8 @@ describe("animations", function() {
|
||||
return new $$AnimateRunner();
|
||||
};
|
||||
});
|
||||
return function($rootElement, $$body, $animate) {
|
||||
$$body.append($rootElement);
|
||||
return function($rootElement, $document, $animate) {
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
parent = jqLite('<div class="parent"></div>');
|
||||
element = jqLite('<div class="element"></div>');
|
||||
child = jqLite('<div class="child"></div>');
|
||||
@@ -1389,14 +1383,14 @@ describe("animations", function() {
|
||||
}));
|
||||
|
||||
it('should allow an element to pinned elsewhere and still be available in animations',
|
||||
inject(function($animate, $compile, $$body, $rootElement, $rootScope) {
|
||||
inject(function($animate, $compile, $document, $rootElement, $rootScope) {
|
||||
|
||||
var innerParent = jqLite('<div></div>');
|
||||
$$body.append(innerParent);
|
||||
jqLite($document[0].body).append(innerParent);
|
||||
innerParent.append($rootElement);
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$$body.append(element);
|
||||
jqLite($document[0].body).append(element);
|
||||
|
||||
$animate.addClass(element, 'red');
|
||||
$rootScope.$digest();
|
||||
@@ -1412,16 +1406,16 @@ describe("animations", function() {
|
||||
}));
|
||||
|
||||
it('should adhere to the disabled state of the hosted parent when an element is pinned',
|
||||
inject(function($animate, $compile, $$body, $rootElement, $rootScope) {
|
||||
inject(function($animate, $compile, $document, $rootElement, $rootScope) {
|
||||
|
||||
var innerParent = jqLite('<div></div>');
|
||||
$$body.append(innerParent);
|
||||
jqLite($document[0].body).append(innerParent);
|
||||
innerParent.append($rootElement);
|
||||
var innerChild = jqLite('<div></div>');
|
||||
$rootElement.append(innerChild);
|
||||
|
||||
var element = jqLite('<div></div>');
|
||||
$$body.append(element);
|
||||
jqLite($document[0].body).append(element);
|
||||
|
||||
$animate.pin(element, innerChild);
|
||||
|
||||
@@ -1456,17 +1450,17 @@ describe("animations", function() {
|
||||
};
|
||||
});
|
||||
|
||||
return function($$body, $rootElement, $animate) {
|
||||
$$body.append($rootElement);
|
||||
return function($document, $rootElement, $animate) {
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
$animate.enabled(true);
|
||||
};
|
||||
}));
|
||||
|
||||
it('should trigger a callback for an enter animation',
|
||||
inject(function($animate, $rootScope, $rootElement, $$body) {
|
||||
inject(function($animate, $rootScope, $rootElement, $document) {
|
||||
|
||||
var callbackTriggered = false;
|
||||
$animate.on('enter', $$body, function() {
|
||||
$animate.on('enter', jqLite($document[0].body), function() {
|
||||
callbackTriggered = true;
|
||||
});
|
||||
|
||||
@@ -1480,12 +1474,12 @@ describe("animations", function() {
|
||||
}));
|
||||
|
||||
it('should fire the callback with the signature of (element, phase, data)',
|
||||
inject(function($animate, $rootScope, $rootElement, $$body) {
|
||||
inject(function($animate, $rootScope, $rootElement, $document) {
|
||||
|
||||
var capturedElement;
|
||||
var capturedPhase;
|
||||
var capturedData;
|
||||
$animate.on('enter', $$body,
|
||||
$animate.on('enter', jqLite($document[0].body),
|
||||
function(element, phase, data) {
|
||||
|
||||
capturedElement = element;
|
||||
@@ -1519,7 +1513,6 @@ describe("animations", function() {
|
||||
element = jqLite('<div></div>');
|
||||
$animate.enter(element, $rootElement);
|
||||
$rootScope.$digest();
|
||||
$animate.flush();
|
||||
|
||||
expect(callbackTriggered).toBe(false);
|
||||
}));
|
||||
@@ -1544,13 +1537,13 @@ describe("animations", function() {
|
||||
}));
|
||||
|
||||
it('should remove all the event-based event listeners when $animate.off(event) is called',
|
||||
inject(function($animate, $rootScope, $rootElement, $$body) {
|
||||
inject(function($animate, $rootScope, $rootElement, $document) {
|
||||
|
||||
element = jqLite('<div></div>');
|
||||
|
||||
var count = 0;
|
||||
$animate.on('enter', element, counter);
|
||||
$animate.on('enter', $$body, counter);
|
||||
$animate.on('enter', jqLite($document[0].body), counter);
|
||||
|
||||
function counter(element, phase) {
|
||||
count++;
|
||||
@@ -1572,13 +1565,13 @@ describe("animations", function() {
|
||||
}));
|
||||
|
||||
it('should remove the container-based event listeners when $animate.off(event, container) is called',
|
||||
inject(function($animate, $rootScope, $rootElement, $$body) {
|
||||
inject(function($animate, $rootScope, $rootElement, $document) {
|
||||
|
||||
element = jqLite('<div></div>');
|
||||
|
||||
var count = 0;
|
||||
$animate.on('enter', element, counter);
|
||||
$animate.on('enter', $$body, counter);
|
||||
$animate.on('enter', jqLite($document[0].body), counter);
|
||||
|
||||
function counter(element, phase) {
|
||||
if (phase === 'start') {
|
||||
@@ -1592,7 +1585,7 @@ describe("animations", function() {
|
||||
|
||||
expect(count).toBe(2);
|
||||
|
||||
$animate.off('enter', $$body);
|
||||
$animate.off('enter', jqLite($document[0].body));
|
||||
|
||||
$animate.enter(element, $rootElement);
|
||||
$rootScope.$digest();
|
||||
@@ -1638,13 +1631,13 @@ describe("animations", function() {
|
||||
}));
|
||||
|
||||
it('should fire a `start` callback when the animation starts with the matching element',
|
||||
inject(function($animate, $rootScope, $rootElement, $$body) {
|
||||
inject(function($animate, $rootScope, $rootElement, $document) {
|
||||
|
||||
element = jqLite('<div></div>');
|
||||
|
||||
var capturedState;
|
||||
var capturedElement;
|
||||
$animate.on('enter', $$body, function(element, phase) {
|
||||
$animate.on('enter', jqLite($document[0].body), function(element, phase) {
|
||||
capturedState = phase;
|
||||
capturedElement = element;
|
||||
});
|
||||
@@ -1658,13 +1651,13 @@ describe("animations", function() {
|
||||
}));
|
||||
|
||||
it('should fire a `close` callback when the animation ends with the matching element',
|
||||
inject(function($animate, $rootScope, $rootElement, $$body) {
|
||||
inject(function($animate, $rootScope, $rootElement, $document) {
|
||||
|
||||
element = jqLite('<div></div>');
|
||||
|
||||
var capturedState;
|
||||
var capturedElement;
|
||||
$animate.on('enter', $$body, function(element, phase) {
|
||||
$animate.on('enter', jqLite($document[0].body), function(element, phase) {
|
||||
capturedState = phase;
|
||||
capturedElement = element;
|
||||
});
|
||||
@@ -1707,6 +1700,69 @@ describe("animations", function() {
|
||||
expect(count).toBe(1);
|
||||
}));
|
||||
|
||||
it('should always detect registered callbacks after one postDigest has fired',
|
||||
inject(function($animate, $rootScope, $rootElement) {
|
||||
|
||||
element = jqLite('<div></div>');
|
||||
|
||||
var spy = jasmine.createSpy();
|
||||
registerCallback();
|
||||
|
||||
var runner = $animate.enter(element, $rootElement);
|
||||
registerCallback();
|
||||
|
||||
$rootScope.$digest();
|
||||
registerCallback();
|
||||
|
||||
expect(spy.callCount).toBe(0);
|
||||
$animate.flush();
|
||||
|
||||
// this is not 3 since the 3rd callback
|
||||
// was added after the first callback
|
||||
// was fired
|
||||
expect(spy.callCount).toBe(2);
|
||||
|
||||
spy.reset();
|
||||
runner.end();
|
||||
|
||||
$animate.flush();
|
||||
|
||||
// now we expect all three callbacks
|
||||
// to fire when the animation ends since
|
||||
// the callback detection happens again
|
||||
expect(spy.callCount).toBe(3);
|
||||
|
||||
function registerCallback() {
|
||||
$animate.on('enter', element, spy);
|
||||
}
|
||||
}));
|
||||
|
||||
it('should use RAF if there are detected callbacks within the hierachy of the element being animated',
|
||||
inject(function($animate, $rootScope, $rootElement, $$rAF) {
|
||||
|
||||
var runner;
|
||||
|
||||
element = jqLite('<div></div>');
|
||||
runner = $animate.enter(element, $rootElement);
|
||||
$rootScope.$digest();
|
||||
runner.end();
|
||||
|
||||
assertRAFsUsed(false);
|
||||
|
||||
var spy = jasmine.createSpy();
|
||||
$animate.on('leave', element, spy);
|
||||
|
||||
runner = $animate.leave(element, $rootElement);
|
||||
$rootScope.$digest();
|
||||
runner.end();
|
||||
|
||||
assertRAFsUsed(true);
|
||||
|
||||
function assertRAFsUsed(bool) {
|
||||
expect($$rAF.queue.length)[bool ? 'toBeGreaterThan' : 'toBe'](0);
|
||||
}
|
||||
}));
|
||||
|
||||
it('leave: should remove the element even if another animation is called after',
|
||||
inject(function($animate, $rootScope, $rootElement) {
|
||||
|
||||
|
||||
@@ -507,8 +507,7 @@ describe('$$animation', function() {
|
||||
|
||||
$rootScope.$digest();
|
||||
|
||||
$animate.flush(); // element -> child
|
||||
$animate.flush(); // child -> grandchild
|
||||
$animate.flush();
|
||||
|
||||
expect(captureLog[0].element).toBe(element);
|
||||
expect(captureLog[1].element).toBe(child);
|
||||
@@ -837,8 +836,8 @@ describe('$$animation', function() {
|
||||
element = jqLite('<div></div>');
|
||||
parent = jqLite('<div></div>');
|
||||
|
||||
return function($$AnimateRunner, $q, $rootElement, $$body) {
|
||||
$$body.append($rootElement);
|
||||
return function($$AnimateRunner, $rootElement, $document) {
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
$rootElement.append(parent);
|
||||
|
||||
mockedDriverFn = function(element, method, options, domOperation) {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
describe('$$body', function() {
|
||||
beforeEach(module('ngAnimate'));
|
||||
|
||||
it("should inject $document", inject(function($$body, $document) {
|
||||
expect($$body).toEqual(jqLite($document[0].body));
|
||||
}));
|
||||
});
|
||||
@@ -7,12 +7,12 @@ describe('ngAnimate integration tests', function() {
|
||||
|
||||
var element, html, ss;
|
||||
beforeEach(module(function() {
|
||||
return function($rootElement, $document, $$body, $window, $animate) {
|
||||
return function($rootElement, $document, $window, $animate) {
|
||||
$animate.enabled(true);
|
||||
|
||||
ss = createMockStyleSheet($document, $window);
|
||||
|
||||
var body = $$body;
|
||||
var body = jqLite($document[0].body);
|
||||
html = function(element) {
|
||||
body.append($rootElement);
|
||||
$rootElement.append(element);
|
||||
@@ -319,6 +319,38 @@ describe('ngAnimate integration tests', function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should trigger callbacks at the start and end of an animation',
|
||||
inject(function($rootScope, $rootElement, $animate, $compile) {
|
||||
|
||||
ss.addRule('.animate-me', 'transition:2s linear all;');
|
||||
|
||||
var parent = jqLite('<div><div ng-if="exp" class="animate-me"></div></div>');
|
||||
element = parent.find('div');
|
||||
html(parent);
|
||||
|
||||
$compile(parent)($rootScope);
|
||||
$rootScope.$digest();
|
||||
|
||||
var spy = jasmine.createSpy();
|
||||
$animate.on('enter', parent, spy);
|
||||
|
||||
$rootScope.exp = true;
|
||||
$rootScope.$digest();
|
||||
|
||||
element = parent.find('div');
|
||||
|
||||
$animate.flush();
|
||||
|
||||
expect(spy.callCount).toBe(1);
|
||||
|
||||
browserTrigger(element, 'transitionend', { timeStamp: Date.now(), elapsedTime: 2 });
|
||||
$animate.flush();
|
||||
|
||||
expect(spy.callCount).toBe(2);
|
||||
|
||||
dealoc(element);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('JS animations', function() {
|
||||
|
||||
+26
-21
@@ -616,10 +616,35 @@ describe('$aria', function() {
|
||||
describe('tabindex', function() {
|
||||
beforeEach(injectScopeAndCompiler);
|
||||
|
||||
it('should attach tabindex to role="checkbox", ng-click, and ng-dblclick', function() {
|
||||
it('should not attach to native controls', function() {
|
||||
var element = [
|
||||
$compile("<button ng-click='something'></button>")(scope),
|
||||
$compile("<a ng-href='#/something'>")(scope),
|
||||
$compile("<input ng-model='val'>")(scope),
|
||||
$compile("<textarea ng-model='val'></textarea>")(scope),
|
||||
$compile("<select ng-model='val'></select>")(scope),
|
||||
$compile("<details ng-model='val'></details>")(scope)
|
||||
];
|
||||
expectAriaAttrOnEachElement(element, 'tabindex', undefined);
|
||||
});
|
||||
|
||||
it('should not attach to random ng-model elements', function() {
|
||||
compileElement('<div ng-model="val"></div>');
|
||||
expect(element.attr('tabindex')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should attach tabindex to custom inputs', function() {
|
||||
compileElement('<div type="checkbox" ng-model="val"></div>');
|
||||
expect(element.attr('tabindex')).toBe('0');
|
||||
|
||||
compileElement('<div role="checkbox" ng-model="val"></div>');
|
||||
expect(element.attr('tabindex')).toBe('0');
|
||||
|
||||
compileElement('<div type="range" ng-model="val"></div>');
|
||||
expect(element.attr('tabindex')).toBe('0');
|
||||
});
|
||||
|
||||
it('should attach to ng-click and ng-dblclick', function() {
|
||||
compileElement('<div ng-click="someAction()"></div>');
|
||||
expect(element.attr('tabindex')).toBe('0');
|
||||
|
||||
@@ -640,26 +665,6 @@ describe('$aria', function() {
|
||||
compileElement('<div ng-dblclick="someAction()" tabindex="userSetValue"></div>');
|
||||
expect(element.attr('tabindex')).toBe('userSetValue');
|
||||
});
|
||||
|
||||
it('should set proper tabindex values for radiogroup', function() {
|
||||
compileElement('<div role="radiogroup">' +
|
||||
'<div role="radio" ng-model="val" value="one">1</div>' +
|
||||
'<div role="radio" ng-model="val" value="two">2</div>' +
|
||||
'</div>');
|
||||
|
||||
var one = element.contents().eq(0);
|
||||
var two = element.contents().eq(1);
|
||||
|
||||
scope.$apply("val = 'one'");
|
||||
expect(one.attr('tabindex')).toBe('0');
|
||||
expect(two.attr('tabindex')).toBe('-1');
|
||||
|
||||
scope.$apply("val = 'two'");
|
||||
expect(one.attr('tabindex')).toBe('-1');
|
||||
expect(two.attr('tabindex')).toBe('0');
|
||||
|
||||
dealoc(element);
|
||||
});
|
||||
});
|
||||
|
||||
describe('accessible actions', function() {
|
||||
|
||||
@@ -138,8 +138,8 @@ describe('cookie options', function() {
|
||||
.reduce(function(prev, value) {
|
||||
var pair = value.split('=', 2);
|
||||
if (pair[0] === key) {
|
||||
if (prev === undefined) {
|
||||
return pair[1] === undefined ? true : pair[1];
|
||||
if (isUndefined(prev)) {
|
||||
return isUndefined(pair[1]) ? true : pair[1];
|
||||
} else {
|
||||
throw 'duplicate key in cookie string';
|
||||
}
|
||||
|
||||
@@ -372,6 +372,50 @@ describe('ngMessages', function() {
|
||||
expect(trim(element.text())).toEqual("Enter something");
|
||||
}));
|
||||
|
||||
// issue #12856
|
||||
it('should only detach the message object that is associated with the message node being removed',
|
||||
inject(function($rootScope, $compile, $animate) {
|
||||
|
||||
// We are going to spy on the `leave` method to give us control over
|
||||
// when the element is actually removed
|
||||
spyOn($animate, 'leave');
|
||||
|
||||
// Create a basic ng-messages set up
|
||||
element = $compile('<div ng-messages="col">' +
|
||||
' <div ng-message="primary">Enter something</div>' +
|
||||
'</div>')($rootScope);
|
||||
|
||||
// Trigger the message to be displayed
|
||||
$rootScope.col = { primary: true };
|
||||
$rootScope.$digest();
|
||||
expect(messageChildren(element).length).toEqual(1);
|
||||
var oldMessageNode = messageChildren(element)[0];
|
||||
|
||||
// Remove the message
|
||||
$rootScope.col = { primary: undefined };
|
||||
$rootScope.$digest();
|
||||
|
||||
// Since we have spied on the `leave` method, the message node is still in the DOM
|
||||
expect($animate.leave).toHaveBeenCalledOnce();
|
||||
var nodeToRemove = $animate.leave.mostRecentCall.args[0][0];
|
||||
expect(nodeToRemove).toBe(oldMessageNode);
|
||||
$animate.leave.reset();
|
||||
|
||||
// Add the message back in
|
||||
$rootScope.col = { primary: true };
|
||||
$rootScope.$digest();
|
||||
|
||||
// Simulate the animation completing on the node
|
||||
jqLite(nodeToRemove).remove();
|
||||
|
||||
// We should not get another call to `leave`
|
||||
expect($animate.leave).not.toHaveBeenCalled();
|
||||
|
||||
// There should only be the new message node
|
||||
expect(messageChildren(element).length).toEqual(1);
|
||||
var newMessageNode = messageChildren(element)[0];
|
||||
expect(newMessageNode).not.toBe(oldMessageNode);
|
||||
}));
|
||||
|
||||
it('should render animations when the active/inactive classes are added/removed', function() {
|
||||
module('ngAnimate');
|
||||
|
||||
Vendored
+181
@@ -1828,6 +1828,187 @@ describe('ngMockE2E', function() {
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('ngAnimateMock', function() {
|
||||
|
||||
beforeEach(module('ngAnimate'));
|
||||
beforeEach(module('ngAnimateMock'));
|
||||
|
||||
var ss, element, trackedAnimations;
|
||||
|
||||
afterEach(function() {
|
||||
if (element) {
|
||||
element.remove();
|
||||
}
|
||||
if (ss) {
|
||||
ss.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(module(function($animateProvider) {
|
||||
trackedAnimations = [];
|
||||
$animateProvider.register('.animate', function() {
|
||||
return {
|
||||
leave: logFn('leave'),
|
||||
addClass: logFn('addClass')
|
||||
};
|
||||
|
||||
function logFn(method) {
|
||||
return function(element) {
|
||||
trackedAnimations.push(getDoneCallback(arguments));
|
||||
};
|
||||
}
|
||||
|
||||
function getDoneCallback(args) {
|
||||
for (var i = args.length; i > 0; i--) {
|
||||
if (angular.isFunction(args[i])) return args[i];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return function($animate, $rootElement, $document, $rootScope, $window) {
|
||||
ss = createMockStyleSheet($document, $window);
|
||||
|
||||
element = angular.element('<div class="animate"></div>');
|
||||
$rootElement.append(element);
|
||||
angular.element($document[0].body).append($rootElement);
|
||||
$animate.enabled(true);
|
||||
$rootScope.$digest();
|
||||
};
|
||||
}));
|
||||
|
||||
describe('$animate.queue', function() {
|
||||
it('should maintain a queue of the executed animations', inject(function($animate) {
|
||||
element.removeClass('animate'); // we don't care to test any actual animations
|
||||
var options = {};
|
||||
|
||||
$animate.addClass(element, 'on', options);
|
||||
var first = $animate.queue[0];
|
||||
expect(first.element).toBe(element);
|
||||
expect(first.event).toBe('addClass');
|
||||
expect(first.options).toBe(options);
|
||||
|
||||
$animate.removeClass(element, 'off', options);
|
||||
var second = $animate.queue[1];
|
||||
expect(second.element).toBe(element);
|
||||
expect(second.event).toBe('removeClass');
|
||||
expect(second.options).toBe(options);
|
||||
|
||||
$animate.leave(element, options);
|
||||
var third = $animate.queue[2];
|
||||
expect(third.element).toBe(element);
|
||||
expect(third.event).toBe('leave');
|
||||
expect(third.options).toBe(options);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('$animate.flush()', function() {
|
||||
it('should throw an error if there is nothing to animate', inject(function($animate) {
|
||||
expect(function() {
|
||||
$animate.flush();
|
||||
}).toThrow('No pending animations ready to be closed or flushed');
|
||||
}));
|
||||
|
||||
it('should trigger the animation to start',
|
||||
inject(function($animate) {
|
||||
|
||||
expect(trackedAnimations.length).toBe(0);
|
||||
$animate.leave(element);
|
||||
$animate.flush();
|
||||
expect(trackedAnimations.length).toBe(1);
|
||||
}));
|
||||
|
||||
it('should trigger the animation to end once run and called',
|
||||
inject(function($animate) {
|
||||
|
||||
$animate.leave(element);
|
||||
$animate.flush();
|
||||
expect(element.parent().length).toBe(1);
|
||||
|
||||
trackedAnimations[0]();
|
||||
$animate.flush();
|
||||
expect(element.parent().length).toBe(0);
|
||||
}));
|
||||
|
||||
it('should trigger the animation promise callback to fire once run and closed',
|
||||
inject(function($animate) {
|
||||
|
||||
var doneSpy = jasmine.createSpy();
|
||||
$animate.leave(element).then(doneSpy);
|
||||
$animate.flush();
|
||||
|
||||
trackedAnimations[0]();
|
||||
expect(doneSpy).not.toHaveBeenCalled();
|
||||
$animate.flush();
|
||||
expect(doneSpy).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('should trigger a series of CSS animations to trigger and start once run',
|
||||
inject(function($animate, $rootScope) {
|
||||
|
||||
if (!browserSupportsCssAnimations()) return;
|
||||
|
||||
ss.addRule('.leave-me.ng-leave', 'transition:1s linear all;');
|
||||
|
||||
var i, elm, elms = [];
|
||||
for (i = 0; i < 5; i++) {
|
||||
elm = angular.element('<div class="leave-me"></div>');
|
||||
element.append(elm);
|
||||
elms.push(elm);
|
||||
|
||||
$animate.leave(elm);
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
elm = elms[i];
|
||||
expect(elm.hasClass('ng-leave')).toBe(true);
|
||||
expect(elm.hasClass('ng-leave-active')).toBe(false);
|
||||
}
|
||||
|
||||
$animate.flush();
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
elm = elms[i];
|
||||
expect(elm.hasClass('ng-leave')).toBe(true);
|
||||
expect(elm.hasClass('ng-leave-active')).toBe(true);
|
||||
}
|
||||
}));
|
||||
|
||||
it('should trigger parent and child animations to run within the same flush',
|
||||
inject(function($animate, $rootScope) {
|
||||
|
||||
var child = angular.element('<div class="animate child"></div>');
|
||||
element.append(child);
|
||||
|
||||
expect(trackedAnimations.length).toBe(0);
|
||||
|
||||
$animate.addClass(element, 'go');
|
||||
$animate.addClass(child, 'start');
|
||||
$animate.flush();
|
||||
|
||||
expect(trackedAnimations.length).toBe(2);
|
||||
}));
|
||||
|
||||
it('should trigger animation callbacks when called',
|
||||
inject(function($animate, $rootScope) {
|
||||
|
||||
var spy = jasmine.createSpy();
|
||||
$animate.on('addClass', element, spy);
|
||||
|
||||
$animate.addClass(element, 'on');
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
|
||||
$animate.flush();
|
||||
expect(spy.callCount).toBe(1);
|
||||
|
||||
trackedAnimations[0]();
|
||||
$animate.flush();
|
||||
expect(spy.callCount).toBe(2);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('make sure that we can create an injector outside of tests', function() {
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('angular.scenario.matchers', function() {
|
||||
function expectMatcher(value, test) {
|
||||
delete matchers.error;
|
||||
delete matchers.future.value;
|
||||
if (value !== undefined) {
|
||||
if (isDefined(value)) {
|
||||
matchers.future.value = value;
|
||||
}
|
||||
test();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user