Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f73a651461 | |||
| d65636988b | |||
| e75fbc494e | |||
| 5e28b6ea8c | |||
| 586ec15398 | |||
| 8541d25ded | |||
| a580f8132b | |||
| 41aa9125b9 | |||
| b4581e3e99 | |||
| bdb5bc82a3 | |||
| 1cf93fd2b0 | |||
| 4f3858e7c3 | |||
| 4993728819 | |||
| 6933cf64fe | |||
| 32e656b769 |
@@ -1,6 +1,6 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2010-2016 Google, Inc. http://angularjs.org
|
||||
Copyright (c) 2010-2017 Google, Inc. http://angularjs.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
<p class="pull-right"><a back-to-top>Back to top</a></p>
|
||||
|
||||
<p>
|
||||
Super-powered by Google ©2010-2016
|
||||
Super-powered by Google ©2010-2017
|
||||
( <a id="version"
|
||||
ng-href="https://github.com/angular/angular.js/blob/master/CHANGELOG.md#{{versionNumber}}"
|
||||
ng-bind-template="v{{version}}" title="Changelog of this version of Angular JS">
|
||||
|
||||
@@ -555,7 +555,7 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
|
||||
</example>
|
||||
|
||||
####Browser in HTML5 Fallback mode (Hashbang mode)
|
||||
#### Browser in HTML5 Fallback mode (Hashbang mode)
|
||||
<example module="hashbang-mode" name="location-hashbang-mode">
|
||||
<file name="index.html">
|
||||
<div ng-controller="LocationController">
|
||||
|
||||
@@ -28,8 +28,8 @@ for other directives to augment its behavior.
|
||||
<form novalidate class="simple-form">
|
||||
<label>Name: <input type="text" ng-model="user.name" /></label><br />
|
||||
<label>E-mail: <input type="email" ng-model="user.email" /></label><br />
|
||||
Gender: <label><input type="radio" ng-model="user.gender" value="male" />male</label>
|
||||
<label><input type="radio" ng-model="user.gender" value="female" />female</label><br />
|
||||
Best Editor: <label><input type="radio" ng-model="user.preference" value="vi" />vi</label>
|
||||
<label><input type="radio" ng-model="user.preference" value="emacs" />emacs</label><br />
|
||||
<input type="button" ng-click="reset()" value="Reset" />
|
||||
<input type="submit" ng-click="update(user)" value="Save" />
|
||||
</form>
|
||||
|
||||
@@ -221,8 +221,8 @@ it('should clear messages after alert', function() {
|
||||
notify('two');
|
||||
notify('third');
|
||||
|
||||
expect(mock.alert.callCount).toEqual(2);
|
||||
expect(mock.alert.mostRecentCall.args).toEqual(["more\ntwo\nthird"]);
|
||||
expect(mock.alert.calls.count()).toEqual(2);
|
||||
expect(mock.alert.calls.mostRecent().args).toEqual(["more\ntwo\nthird"]);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ We will keep this in mind though, as we add more features.
|
||||
So, now that we learned we should put everything in its own file, our `app/` directory will soon be
|
||||
full with dozens of files and specs (remember we keep our unit test files next to the corresponding
|
||||
source code files). What's more important, logically related files will not be grouped together; it
|
||||
will be really difficult of locate all files related to a specific section of the application and
|
||||
will be really difficult to locate all files related to a specific section of the application and
|
||||
make a change or fix a bug.
|
||||
|
||||
So, what shall we do?
|
||||
|
||||
@@ -173,7 +173,10 @@ angular.module('phoneList', ['core.phone']);
|
||||
**`app/phone-detail/phone-detail.module.js`:**
|
||||
|
||||
```js
|
||||
angular.module('phoneDetail', ['core.phone']);
|
||||
angular.module('phoneDetail', [
|
||||
'ngRoute',
|
||||
'core.phone'
|
||||
]);
|
||||
```
|
||||
|
||||
<br />
|
||||
|
||||
+6
-2
@@ -1446,12 +1446,16 @@ function getNgAttribute(element, ngAttr) {
|
||||
}
|
||||
|
||||
function allowAutoBootstrap(document) {
|
||||
if (!document.currentScript) {
|
||||
var script = document.currentScript;
|
||||
var src = script && script.getAttribute('src');
|
||||
|
||||
if (!src) {
|
||||
return true;
|
||||
}
|
||||
var src = document.currentScript.getAttribute('src');
|
||||
|
||||
var link = document.createElement('a');
|
||||
link.href = src;
|
||||
|
||||
if (document.location.origin === link.origin) {
|
||||
// Same-origin resources are always allowed, even for non-whitelisted schemes.
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @license AngularJS v"NG_VERSION_FULL"
|
||||
* (c) 2010-2016 Google, Inc. http://angularjs.org
|
||||
* (c) 2010-2017 Google, Inc. http://angularjs.org
|
||||
* License: MIT
|
||||
*/
|
||||
(function(window) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @license AngularJS v"NG_VERSION_FULL"
|
||||
* (c) 2010-2016 Google, Inc. http://angularjs.org
|
||||
* (c) 2010-2017 Google, Inc. http://angularjs.org
|
||||
* License: MIT
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @license AngularJS v"NG_VERSION_FULL"
|
||||
* (c) 2010-2016 Google, Inc. http://angularjs.org
|
||||
* (c) 2010-2017 Google, Inc. http://angularjs.org
|
||||
* License: MIT
|
||||
*/
|
||||
(function(window, angular) {
|
||||
|
||||
+1
-1
@@ -983,7 +983,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
var bindingCache = createMap();
|
||||
|
||||
function parseIsolateBindings(scope, directiveName, isController) {
|
||||
var LOCAL_REGEXP = /^\s*([@&<]|=(\*?))(\??)\s*(\w*)\s*$/;
|
||||
var LOCAL_REGEXP = /^\s*([@&<]|=(\*?))(\??)\s*([\w$]*)\s*$/;
|
||||
|
||||
var bindings = createMap();
|
||||
|
||||
|
||||
@@ -14,6 +14,14 @@ function $$CookieReader($document) {
|
||||
var lastCookies = {};
|
||||
var lastCookieString = '';
|
||||
|
||||
function safeGetCookie(rawDocument) {
|
||||
try {
|
||||
return rawDocument.cookie || '';
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function safeDecodeURIComponent(str) {
|
||||
try {
|
||||
return decodeURIComponent(str);
|
||||
@@ -24,7 +32,7 @@ function $$CookieReader($document) {
|
||||
|
||||
return function() {
|
||||
var cookieArray, cookie, i, index, name;
|
||||
var currentCookieString = rawDocument.cookie || '';
|
||||
var currentCookieString = safeGetCookie(rawDocument);
|
||||
|
||||
if (currentCookieString !== lastCookieString) {
|
||||
lastCookieString = currentCookieString;
|
||||
|
||||
+224
-159
@@ -8,11 +8,13 @@ var NG_HIDE_IN_PROGRESS_CLASS = 'ng-hide-animate';
|
||||
* @multiElement
|
||||
*
|
||||
* @description
|
||||
* The `ngShow` directive shows or hides the given HTML element based on the expression
|
||||
* provided to the `ngShow` attribute. The element is shown or hidden by removing or adding
|
||||
* the `.ng-hide` CSS class onto the element. The `.ng-hide` CSS class is predefined
|
||||
* in AngularJS and sets the display style to none (using an !important flag).
|
||||
* For CSP mode please add `angular-csp.css` to your html file (see {@link ng.directive:ngCsp ngCsp}).
|
||||
* The `ngShow` directive shows or hides the given HTML element based on the expression provided to
|
||||
* the `ngShow` attribute.
|
||||
*
|
||||
* The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
|
||||
* The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
|
||||
* `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
|
||||
* {@link ng.directive:ngCsp ngCsp}).
|
||||
*
|
||||
* ```html
|
||||
* <!-- when $scope.myValue is truthy (element is visible) -->
|
||||
@@ -22,31 +24,32 @@ var NG_HIDE_IN_PROGRESS_CLASS = 'ng-hide-animate';
|
||||
* <div ng-show="myValue" class="ng-hide"></div>
|
||||
* ```
|
||||
*
|
||||
* When the `ngShow` expression evaluates to a falsy value then the `.ng-hide` CSS class is added to the class
|
||||
* attribute on the element causing it to become hidden. When truthy, the `.ng-hide` CSS class is removed
|
||||
* from the element causing the element not to appear hidden.
|
||||
* When the `ngShow` expression evaluates to a falsy value then the `.ng-hide` CSS class is added
|
||||
* to the class attribute on the element causing it to become hidden. When truthy, the `.ng-hide`
|
||||
* CSS class is removed from the element causing the element not to appear hidden.
|
||||
*
|
||||
* ## Why is !important used?
|
||||
* ## Why is `!important` used?
|
||||
*
|
||||
* You may be wondering why !important is used for the `.ng-hide` CSS class. This is because the `.ng-hide` selector
|
||||
* can be easily overridden by heavier selectors. For example, something as simple
|
||||
* as changing the display style on a HTML list item would make hidden elements appear visible.
|
||||
* This also becomes a bigger issue when dealing with CSS frameworks.
|
||||
* You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
|
||||
* `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
|
||||
* simple as changing the display style on a HTML list item would make hidden elements appear
|
||||
* visible. This also becomes a bigger issue when dealing with CSS frameworks.
|
||||
*
|
||||
* By using !important, the show and hide behavior will work as expected despite any clash between CSS selector
|
||||
* specificity (when !important isn't used with any conflicting styles). If a developer chooses to override the
|
||||
* styling to change how to hide an element then it is just a matter of using !important in their own CSS code.
|
||||
* By using `!important`, the show and hide behavior will work as expected despite any clash between
|
||||
* CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
|
||||
* developer chooses to override the styling to change how to hide an element then it is just a
|
||||
* matter of using `!important` in their own CSS code.
|
||||
*
|
||||
* ### Overriding `.ng-hide`
|
||||
*
|
||||
* By default, the `.ng-hide` class will style the element with `display: none!important`. If you wish to change
|
||||
* the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide`
|
||||
* class CSS. Note that the selector that needs to be used is actually `.ng-hide:not(.ng-hide-animate)` to cope
|
||||
* with extra animation classes that can be added.
|
||||
* By default, the `.ng-hide` class will style the element with `display: none !important`. If you
|
||||
* wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
|
||||
* the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
|
||||
* `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
|
||||
*
|
||||
* ```css
|
||||
* .ng-hide:not(.ng-hide-animate) {
|
||||
* /* this is just another form of hiding an element */
|
||||
* /* These are just alternative ways of hiding an element */
|
||||
* display: block!important;
|
||||
* position: absolute;
|
||||
* top: -9999px;
|
||||
@@ -54,29 +57,20 @@ var NG_HIDE_IN_PROGRESS_CLASS = 'ng-hide-animate';
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* By default you don't need to override in CSS anything and the animations will work around the display style.
|
||||
* By default you don't need to override anything in CSS and the animations will work around the
|
||||
* display style.
|
||||
*
|
||||
* ## A note about animations with `ngShow`
|
||||
*
|
||||
* Animations in ngShow/ngHide work with the show and hide events that are triggered when the directive expression
|
||||
* is true and false. This system works like the animation system present with ngClass except that
|
||||
* you must also include the !important flag to override the display property
|
||||
* so that you can perform an animation when the element is hidden during the time of the animation.
|
||||
* Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
|
||||
* directive expression is true and false. This system works like the animation system present with
|
||||
* `ngClass` except that you must also include the `!important` flag to override the display
|
||||
* property so that the elements are not actually hidden during the animation.
|
||||
*
|
||||
* ```css
|
||||
* //
|
||||
* //a working example can be found at the bottom of this page
|
||||
* //
|
||||
* /* A working example can be found at the bottom of this page. */
|
||||
* .my-element.ng-hide-add, .my-element.ng-hide-remove {
|
||||
* /* this is required as of 1.3x to properly
|
||||
* apply all styling in a show/hide animation */
|
||||
* transition: 0s linear all;
|
||||
* }
|
||||
*
|
||||
* .my-element.ng-hide-add-active,
|
||||
* .my-element.ng-hide-remove-active {
|
||||
* /* the transition is defined in the active class */
|
||||
* transition: 1s linear all;
|
||||
* transition: all 0.5s linear;
|
||||
* }
|
||||
*
|
||||
* .my-element.ng-hide-add { ... }
|
||||
@@ -85,76 +79,108 @@ var NG_HIDE_IN_PROGRESS_CLASS = 'ng-hide-animate';
|
||||
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
|
||||
* ```
|
||||
*
|
||||
* Keep in mind that, as of AngularJS version 1.3, there is no need to change the display
|
||||
* property to block during animation states--ngAnimate will handle the style toggling automatically for you.
|
||||
* Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
|
||||
* to block during animation states - ngAnimate will automatically handle the style toggling for you.
|
||||
*
|
||||
* @animations
|
||||
* | Animation | Occurs |
|
||||
* |----------------------------------|-------------------------------------|
|
||||
* | {@link $animate#addClass addClass} `.ng-hide` | after the `ngShow` expression evaluates to a non truthy value and just before the contents are set to hidden |
|
||||
* | {@link $animate#removeClass removeClass} `.ng-hide` | after the `ngShow` expression evaluates to a truthy value and just before contents are set to visible |
|
||||
* | Animation | Occurs |
|
||||
* |-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
|
||||
* | {@link $animate#addClass addClass} `.ng-hide` | After the `ngShow` expression evaluates to a non truthy value and just before the contents are set to hidden. |
|
||||
* | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngShow` expression evaluates to a truthy value and just before contents are set to visible. |
|
||||
*
|
||||
* @element ANY
|
||||
* @param {expression} ngShow If the {@link guide/expression expression} is truthy
|
||||
* then the element is shown or hidden respectively.
|
||||
* @param {expression} ngShow If the {@link guide/expression expression} is truthy/falsy then the
|
||||
* element is shown/hidden respectively.
|
||||
*
|
||||
* @example
|
||||
<example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-show">
|
||||
* A simple example, animating the element's opacity:
|
||||
*
|
||||
<example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-show-simple">
|
||||
<file name="index.html">
|
||||
Click me: <input type="checkbox" ng-model="checked" aria-label="Toggle ngHide"><br/>
|
||||
<div>
|
||||
Show:
|
||||
<div class="check-element animate-show" ng-show="checked">
|
||||
<span class="glyphicon glyphicon-thumbs-up"></span> I show up when your checkbox is checked.
|
||||
</div>
|
||||
Show: <input type="checkbox" ng-model="checked" aria-label="Toggle ngShow"><br />
|
||||
<div class="check-element animate-show-hide" ng-show="checked">
|
||||
I show up when your checkbox is checked.
|
||||
</div>
|
||||
<div>
|
||||
Hide:
|
||||
<div class="check-element animate-show" ng-hide="checked">
|
||||
<span class="glyphicon glyphicon-thumbs-down"></span> I hide when your checkbox is checked.
|
||||
</div>
|
||||
</div>
|
||||
</file>
|
||||
<file name="glyphicons.css">
|
||||
@import url(../../components/bootstrap-3.1.1/css/bootstrap.css);
|
||||
</file>
|
||||
<file name="animations.css">
|
||||
.animate-show {
|
||||
line-height: 20px;
|
||||
opacity: 1;
|
||||
padding: 10px;
|
||||
border: 1px solid black;
|
||||
background: white;
|
||||
.animate-show-hide.ng-hide {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.animate-show.ng-hide-add, .animate-show.ng-hide-remove {
|
||||
.animate-show-hide.ng-hide-add,
|
||||
.animate-show-hide.ng-hide-remove {
|
||||
transition: all linear 0.5s;
|
||||
}
|
||||
|
||||
.animate-show.ng-hide {
|
||||
line-height: 0;
|
||||
opacity: 0;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.check-element {
|
||||
padding: 10px;
|
||||
border: 1px solid black;
|
||||
background: white;
|
||||
opacity: 1;
|
||||
padding: 10px;
|
||||
}
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
var thumbsUp = element(by.css('span.glyphicon-thumbs-up'));
|
||||
var thumbsDown = element(by.css('span.glyphicon-thumbs-down'));
|
||||
it('should check ngShow', function() {
|
||||
var checkbox = element(by.model('checked'));
|
||||
var checkElem = element(by.css('.check-element'));
|
||||
|
||||
it('should check ng-show / ng-hide', function() {
|
||||
expect(thumbsUp.isDisplayed()).toBeFalsy();
|
||||
expect(thumbsDown.isDisplayed()).toBeTruthy();
|
||||
expect(checkElem.isDisplayed()).toBe(false);
|
||||
checkbox.click();
|
||||
expect(checkElem.isDisplayed()).toBe(true);
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
*
|
||||
* <hr />
|
||||
* @example
|
||||
* A more complex example, featuring different show/hide animations:
|
||||
*
|
||||
<example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-show-complex">
|
||||
<file name="index.html">
|
||||
Show: <input type="checkbox" ng-model="checked" aria-label="Toggle ngShow"><br />
|
||||
<div class="check-element funky-show-hide" ng-show="checked">
|
||||
I show up when your checkbox is checked.
|
||||
</div>
|
||||
</file>
|
||||
<file name="animations.css">
|
||||
body {
|
||||
overflow: hidden;
|
||||
perspective: 1000px;
|
||||
}
|
||||
|
||||
element(by.model('checked')).click();
|
||||
.funky-show-hide.ng-hide-add {
|
||||
transform: rotateZ(0);
|
||||
transform-origin: right;
|
||||
transition: all 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
expect(thumbsUp.isDisplayed()).toBeTruthy();
|
||||
expect(thumbsDown.isDisplayed()).toBeFalsy();
|
||||
.funky-show-hide.ng-hide-add.ng-hide-add-active {
|
||||
transform: rotateZ(-135deg);
|
||||
}
|
||||
|
||||
.funky-show-hide.ng-hide-remove {
|
||||
transform: rotateY(90deg);
|
||||
transform-origin: left;
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
|
||||
.funky-show-hide.ng-hide-remove.ng-hide-remove-active {
|
||||
transform: rotateY(0);
|
||||
}
|
||||
|
||||
.check-element {
|
||||
border: 1px solid black;
|
||||
opacity: 1;
|
||||
padding: 10px;
|
||||
}
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ngShow', function() {
|
||||
var checkbox = element(by.model('checked'));
|
||||
var checkElem = element(by.css('.check-element'));
|
||||
|
||||
expect(checkElem.isDisplayed()).toBe(false);
|
||||
checkbox.click();
|
||||
expect(checkElem.isDisplayed()).toBe(true);
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
@@ -184,11 +210,13 @@ var ngShowDirective = ['$animate', function($animate) {
|
||||
* @multiElement
|
||||
*
|
||||
* @description
|
||||
* The `ngHide` directive shows or hides the given HTML element based on the expression
|
||||
* provided to the `ngHide` attribute. The element is shown or hidden by removing or adding
|
||||
* the `ng-hide` CSS class onto the element. The `.ng-hide` CSS class is predefined
|
||||
* in AngularJS and sets the display style to none (using an !important flag).
|
||||
* For CSP mode please add `angular-csp.css` to your html file (see {@link ng.directive:ngCsp ngCsp}).
|
||||
* The `ngHide` directive shows or hides the given HTML element based on the expression provided to
|
||||
* the `ngHide` attribute.
|
||||
*
|
||||
* The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
|
||||
* The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
|
||||
* `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
|
||||
* {@link ng.directive:ngCsp ngCsp}).
|
||||
*
|
||||
* ```html
|
||||
* <!-- when $scope.myValue is truthy (element is hidden) -->
|
||||
@@ -198,30 +226,32 @@ var ngShowDirective = ['$animate', function($animate) {
|
||||
* <div ng-hide="myValue"></div>
|
||||
* ```
|
||||
*
|
||||
* When the `ngHide` expression evaluates to a truthy value then the `.ng-hide` CSS class is added to the class
|
||||
* attribute on the element causing it to become hidden. When falsy, the `.ng-hide` CSS class is removed
|
||||
* from the element causing the element not to appear hidden.
|
||||
* When the `ngHide` expression evaluates to a truthy value then the `.ng-hide` CSS class is added
|
||||
* to the class attribute on the element causing it to become hidden. When falsy, the `.ng-hide`
|
||||
* CSS class is removed from the element causing the element not to appear hidden.
|
||||
*
|
||||
* ## Why is !important used?
|
||||
* ## Why is `!important` used?
|
||||
*
|
||||
* You may be wondering why !important is used for the `.ng-hide` CSS class. This is because the `.ng-hide` selector
|
||||
* can be easily overridden by heavier selectors. For example, something as simple
|
||||
* as changing the display style on a HTML list item would make hidden elements appear visible.
|
||||
* This also becomes a bigger issue when dealing with CSS frameworks.
|
||||
* You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
|
||||
* `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
|
||||
* simple as changing the display style on a HTML list item would make hidden elements appear
|
||||
* visible. This also becomes a bigger issue when dealing with CSS frameworks.
|
||||
*
|
||||
* By using !important, the show and hide behavior will work as expected despite any clash between CSS selector
|
||||
* specificity (when !important isn't used with any conflicting styles). If a developer chooses to override the
|
||||
* styling to change how to hide an element then it is just a matter of using !important in their own CSS code.
|
||||
* By using `!important`, the show and hide behavior will work as expected despite any clash between
|
||||
* CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
|
||||
* developer chooses to override the styling to change how to hide an element then it is just a
|
||||
* matter of using `!important` in their own CSS code.
|
||||
*
|
||||
* ### Overriding `.ng-hide`
|
||||
*
|
||||
* By default, the `.ng-hide` class will style the element with `display: none!important`. If you wish to change
|
||||
* the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide`
|
||||
* class in CSS:
|
||||
* By default, the `.ng-hide` class will style the element with `display: none !important`. If you
|
||||
* wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
|
||||
* the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
|
||||
* `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
|
||||
*
|
||||
* ```css
|
||||
* .ng-hide {
|
||||
* /* this is just another form of hiding an element */
|
||||
* .ng-hide:not(.ng-hide-animate) {
|
||||
* /* These are just alternative ways of hiding an element */
|
||||
* display: block!important;
|
||||
* position: absolute;
|
||||
* top: -9999px;
|
||||
@@ -229,20 +259,20 @@ var ngShowDirective = ['$animate', function($animate) {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* By default you don't need to override in CSS anything and the animations will work around the display style.
|
||||
* By default you don't need to override in CSS anything and the animations will work around the
|
||||
* display style.
|
||||
*
|
||||
* ## A note about animations with `ngHide`
|
||||
*
|
||||
* Animations in ngShow/ngHide work with the show and hide events that are triggered when the directive expression
|
||||
* is true and false. This system works like the animation system present with ngClass, except that the `.ng-hide`
|
||||
* CSS class is added and removed for you instead of your own CSS class.
|
||||
* Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
|
||||
* directive expression is true and false. This system works like the animation system present with
|
||||
* `ngClass` except that you must also include the `!important` flag to override the display
|
||||
* property so that the elements are not actually hidden during the animation.
|
||||
*
|
||||
* ```css
|
||||
* //
|
||||
* //a working example can be found at the bottom of this page
|
||||
* //
|
||||
* /* A working example can be found at the bottom of this page. */
|
||||
* .my-element.ng-hide-add, .my-element.ng-hide-remove {
|
||||
* transition: 0.5s linear all;
|
||||
* transition: all 0.5s linear;
|
||||
* }
|
||||
*
|
||||
* .my-element.ng-hide-add { ... }
|
||||
@@ -251,74 +281,109 @@ var ngShowDirective = ['$animate', function($animate) {
|
||||
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
|
||||
* ```
|
||||
*
|
||||
* Keep in mind that, as of AngularJS version 1.3, there is no need to change the display
|
||||
* property to block during animation states--ngAnimate will handle the style toggling automatically for you.
|
||||
* Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
|
||||
* to block during animation states - ngAnimate will automatically handle the style toggling for you.
|
||||
*
|
||||
* @animations
|
||||
* | Animation | Occurs |
|
||||
* |----------------------------------|-------------------------------------|
|
||||
* | {@link $animate#addClass addClass} `.ng-hide` | after the `ngHide` expression evaluates to a truthy value and just before the contents are set to hidden |
|
||||
* | {@link $animate#removeClass removeClass} `.ng-hide` | after the `ngHide` expression evaluates to a non truthy value and just before contents are set to visible |
|
||||
* | Animation | Occurs |
|
||||
* |-----------------------------------------------------|------------------------------------------------------------------------------------------------------------|
|
||||
* | {@link $animate#addClass addClass} `.ng-hide` | After the `ngHide` expression evaluates to a truthy value and just before the contents are set to hidden. |
|
||||
* | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngHide` expression evaluates to a non truthy value and just before contents are set to visible. |
|
||||
*
|
||||
*
|
||||
* @element ANY
|
||||
* @param {expression} ngHide If the {@link guide/expression expression} is truthy then
|
||||
* the element is shown or hidden respectively.
|
||||
* @param {expression} ngHide If the {@link guide/expression expression} is truthy/falsy then the
|
||||
* element is hidden/shown respectively.
|
||||
*
|
||||
* @example
|
||||
<example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-hide">
|
||||
* A simple example, animating the element's opacity:
|
||||
*
|
||||
<example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-hide-simple">
|
||||
<file name="index.html">
|
||||
Click me: <input type="checkbox" ng-model="checked" aria-label="Toggle ngShow"><br/>
|
||||
<div>
|
||||
Show:
|
||||
<div class="check-element animate-hide" ng-show="checked">
|
||||
<span class="glyphicon glyphicon-thumbs-up"></span> I show up when your checkbox is checked.
|
||||
</div>
|
||||
Hide: <input type="checkbox" ng-model="checked" aria-label="Toggle ngHide"><br />
|
||||
<div class="check-element animate-show-hide" ng-hide="checked">
|
||||
I hide when your checkbox is checked.
|
||||
</div>
|
||||
<div>
|
||||
Hide:
|
||||
<div class="check-element animate-hide" ng-hide="checked">
|
||||
<span class="glyphicon glyphicon-thumbs-down"></span> I hide when your checkbox is checked.
|
||||
</div>
|
||||
</div>
|
||||
</file>
|
||||
<file name="glyphicons.css">
|
||||
@import url(../../components/bootstrap-3.1.1/css/bootstrap.css);
|
||||
</file>
|
||||
<file name="animations.css">
|
||||
.animate-hide {
|
||||
transition: all linear 0.5s;
|
||||
line-height: 20px;
|
||||
opacity: 1;
|
||||
padding: 10px;
|
||||
border: 1px solid black;
|
||||
background: white;
|
||||
.animate-show-hide.ng-hide {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.animate-hide.ng-hide {
|
||||
line-height: 0;
|
||||
opacity: 0;
|
||||
padding: 0 10px;
|
||||
.animate-show-hide.ng-hide-add,
|
||||
.animate-show-hide.ng-hide-remove {
|
||||
transition: all linear 0.5s;
|
||||
}
|
||||
|
||||
.check-element {
|
||||
padding: 10px;
|
||||
border: 1px solid black;
|
||||
background: white;
|
||||
opacity: 1;
|
||||
padding: 10px;
|
||||
}
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
var thumbsUp = element(by.css('span.glyphicon-thumbs-up'));
|
||||
var thumbsDown = element(by.css('span.glyphicon-thumbs-down'));
|
||||
it('should check ngHide', function() {
|
||||
var checkbox = element(by.model('checked'));
|
||||
var checkElem = element(by.css('.check-element'));
|
||||
|
||||
it('should check ng-show / ng-hide', function() {
|
||||
expect(thumbsUp.isDisplayed()).toBeFalsy();
|
||||
expect(thumbsDown.isDisplayed()).toBeTruthy();
|
||||
expect(checkElem.isDisplayed()).toBe(true);
|
||||
checkbox.click();
|
||||
expect(checkElem.isDisplayed()).toBe(false);
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
*
|
||||
* <hr />
|
||||
* @example
|
||||
* A more complex example, featuring different show/hide animations:
|
||||
*
|
||||
<example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-hide-complex">
|
||||
<file name="index.html">
|
||||
Hide: <input type="checkbox" ng-model="checked" aria-label="Toggle ngHide"><br />
|
||||
<div class="check-element funky-show-hide" ng-hide="checked">
|
||||
I hide when your checkbox is checked.
|
||||
</div>
|
||||
</file>
|
||||
<file name="animations.css">
|
||||
body {
|
||||
overflow: hidden;
|
||||
perspective: 1000px;
|
||||
}
|
||||
|
||||
element(by.model('checked')).click();
|
||||
.funky-show-hide.ng-hide-add {
|
||||
transform: rotateZ(0);
|
||||
transform-origin: right;
|
||||
transition: all 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
expect(thumbsUp.isDisplayed()).toBeTruthy();
|
||||
expect(thumbsDown.isDisplayed()).toBeFalsy();
|
||||
.funky-show-hide.ng-hide-add.ng-hide-add-active {
|
||||
transform: rotateZ(-135deg);
|
||||
}
|
||||
|
||||
.funky-show-hide.ng-hide-remove {
|
||||
transform: rotateY(90deg);
|
||||
transform-origin: left;
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
|
||||
.funky-show-hide.ng-hide-remove.ng-hide-remove-active {
|
||||
transform: rotateY(0);
|
||||
}
|
||||
|
||||
.check-element {
|
||||
border: 1px solid black;
|
||||
opacity: 1;
|
||||
padding: 10px;
|
||||
}
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ngHide', function() {
|
||||
var checkbox = element(by.model('checked'));
|
||||
var checkElem = element(by.css('.check-element'));
|
||||
|
||||
expect(checkElem.isDisplayed()).toBe(true);
|
||||
checkbox.click();
|
||||
expect(checkElem.isDisplayed()).toBe(false);
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ function $LogProvider() {
|
||||
this.debugEnabled = function(flag) {
|
||||
if (isDefined(flag)) {
|
||||
debug = flag;
|
||||
return this;
|
||||
return this;
|
||||
} else {
|
||||
return debug;
|
||||
}
|
||||
|
||||
@@ -670,6 +670,7 @@ angular.module('ngResource', ['ng']).
|
||||
var data = extend({}, this);
|
||||
delete data.$promise;
|
||||
delete data.$resolved;
|
||||
delete data.$cancelRequest;
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @license AngularJS v"NG_VERSION_FULL"
|
||||
* (c) 2010-2016 Google, Inc. http://angularjs.org
|
||||
* (c) 2010-2017 Google, Inc. http://angularjs.org
|
||||
* License: MIT
|
||||
*/
|
||||
(function(window){
|
||||
|
||||
+23
-2
@@ -1698,7 +1698,8 @@ describe('angular', function() {
|
||||
});
|
||||
|
||||
it('should bootstrap from an extension into an extension document for same-origin documents only', function() {
|
||||
if (msie) return; // IE does not support document.currentScript (nor extensions with protocol), so skip test.
|
||||
// IE does not support `document.currentScript` (nor extensions with protocol), so skip test.
|
||||
if (msie) return;
|
||||
|
||||
// Extension URLs are browser-specific, so we must choose a scheme that is supported by the browser to make
|
||||
// sure that the URL is properly parsed.
|
||||
@@ -1729,8 +1730,28 @@ describe('angular', function() {
|
||||
expect(allowAutoBootstrap(fakeDoc)).toBe(false);
|
||||
});
|
||||
|
||||
it('should bootstrap from a script with an empty or missing `src` attribute', function() {
|
||||
// IE does not support `document.currentScript` (nor extensions with protocol), so skip test.
|
||||
if (msie) return;
|
||||
|
||||
// Fake a minimal document object (the actual document.currentScript is readonly).
|
||||
var src;
|
||||
var fakeDoc = {
|
||||
createElement: document.createElement.bind(document),
|
||||
currentScript: {getAttribute: function() { return src; }},
|
||||
location: {origin: 'some-value', protocol: 'http:'}
|
||||
};
|
||||
|
||||
src = null;
|
||||
expect(allowAutoBootstrap(fakeDoc)).toBe(true);
|
||||
|
||||
src = '';
|
||||
expect(allowAutoBootstrap(fakeDoc)).toBe(true);
|
||||
});
|
||||
|
||||
it('should not bootstrap from an extension into a non-extension document', function() {
|
||||
if (msie) return; // IE does not support document.currentScript (nor extensions with protocol), so skip test.
|
||||
// IE does not support `document.currentScript` (nor extensions with protocol), so skip test.
|
||||
if (msie) return;
|
||||
|
||||
var src = 'resource://something';
|
||||
// Fake a minimal document object (the actual document.currentScript is readonly).
|
||||
|
||||
+53
-13
@@ -4701,21 +4701,28 @@ describe('$compile', function() {
|
||||
scope: {
|
||||
attr: '@',
|
||||
attrAlias: '@attr',
|
||||
$attrAlias: '@$attr$',
|
||||
ref: '=',
|
||||
refAlias: '= ref',
|
||||
$refAlias: '= $ref$',
|
||||
reference: '=',
|
||||
optref: '=?',
|
||||
optrefAlias: '=? optref',
|
||||
$optrefAlias: '=? $optref$',
|
||||
optreference: '=?',
|
||||
colref: '=*',
|
||||
colrefAlias: '=* colref',
|
||||
$colrefAlias: '=* $colref$',
|
||||
owRef: '<',
|
||||
owRefAlias: '< owRef',
|
||||
$owRefAlias: '< $owRef$',
|
||||
owOptref: '<?',
|
||||
owOptrefAlias: '<? owOptref',
|
||||
$owOptrefAlias: '<? $owOptref$',
|
||||
expr: '&',
|
||||
optExpr: '&?',
|
||||
exprAlias: '&expr',
|
||||
$exprAlias: '&$expr$',
|
||||
constructor: '&?'
|
||||
},
|
||||
link: function(scope) {
|
||||
@@ -5134,37 +5141,41 @@ describe('$compile', function() {
|
||||
|
||||
describe('attribute', function() {
|
||||
it('should copy simple attribute', inject(function() {
|
||||
compile('<div><span my-component attr="some text">');
|
||||
compile('<div><span my-component attr="some text" $attr$="some other text">');
|
||||
|
||||
expect(componentScope.attr).toEqual('some text');
|
||||
expect(componentScope.attrAlias).toEqual('some text');
|
||||
expect(componentScope.$attrAlias).toEqual('some other text');
|
||||
expect(componentScope.attrAlias).toEqual(componentScope.attr);
|
||||
}));
|
||||
|
||||
it('should set up the interpolation before it reaches the link function', inject(function() {
|
||||
$rootScope.name = 'misko';
|
||||
compile('<div><span my-component attr="hello {{name}}">');
|
||||
compile('<div><span my-component attr="hello {{name}}" $attr$="hi {{name}}">');
|
||||
expect(componentScope.attr).toEqual('hello misko');
|
||||
expect(componentScope.attrAlias).toEqual('hello misko');
|
||||
expect(componentScope.$attrAlias).toEqual('hi misko');
|
||||
}));
|
||||
|
||||
it('should update when interpolated attribute updates', inject(function() {
|
||||
compile('<div><span my-component attr="hello {{name}}">');
|
||||
compile('<div><span my-component attr="hello {{name}}" $attr$="hi {{name}}">');
|
||||
|
||||
$rootScope.name = 'igor';
|
||||
$rootScope.$apply();
|
||||
|
||||
expect(componentScope.attr).toEqual('hello igor');
|
||||
expect(componentScope.attrAlias).toEqual('hello igor');
|
||||
expect(componentScope.$attrAlias).toEqual('hi igor');
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
describe('object reference', function() {
|
||||
it('should update local when origin changes', inject(function() {
|
||||
compile('<div><span my-component ref="name">');
|
||||
compile('<div><span my-component ref="name" $ref$="name">');
|
||||
expect(componentScope.ref).toBeUndefined();
|
||||
expect(componentScope.refAlias).toBe(componentScope.ref);
|
||||
expect(componentScope.$refAlias).toBe(componentScope.ref);
|
||||
|
||||
$rootScope.name = 'misko';
|
||||
$rootScope.$apply();
|
||||
@@ -5172,16 +5183,18 @@ describe('$compile', function() {
|
||||
expect($rootScope.name).toBe('misko');
|
||||
expect(componentScope.ref).toBe('misko');
|
||||
expect(componentScope.refAlias).toBe('misko');
|
||||
expect(componentScope.$refAlias).toBe('misko');
|
||||
|
||||
$rootScope.name = {};
|
||||
$rootScope.$apply();
|
||||
expect(componentScope.ref).toBe($rootScope.name);
|
||||
expect(componentScope.refAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$refAlias).toBe($rootScope.name);
|
||||
}));
|
||||
|
||||
|
||||
it('should update local when both change', inject(function() {
|
||||
compile('<div><span my-component ref="name">');
|
||||
compile('<div><span my-component ref="name" $ref$="name">');
|
||||
$rootScope.name = {mark:123};
|
||||
componentScope.ref = 'misko';
|
||||
|
||||
@@ -5189,6 +5202,7 @@ describe('$compile', function() {
|
||||
expect($rootScope.name).toEqual({mark:123});
|
||||
expect(componentScope.ref).toBe($rootScope.name);
|
||||
expect(componentScope.refAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$refAlias).toBe($rootScope.name);
|
||||
|
||||
$rootScope.name = 'igor';
|
||||
componentScope.ref = {};
|
||||
@@ -5196,6 +5210,7 @@ describe('$compile', function() {
|
||||
expect($rootScope.name).toEqual('igor');
|
||||
expect(componentScope.ref).toBe($rootScope.name);
|
||||
expect(componentScope.refAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$refAlias).toBe($rootScope.name);
|
||||
}));
|
||||
|
||||
it('should not break if local and origin both change to the same value', inject(function() {
|
||||
@@ -5325,19 +5340,22 @@ describe('$compile', function() {
|
||||
|
||||
describe('optional object reference', function() {
|
||||
it('should update local when origin changes', inject(function() {
|
||||
compile('<div><span my-component optref="name">');
|
||||
compile('<div><span my-component optref="name" $optref$="name">');
|
||||
expect(componentScope.optRef).toBeUndefined();
|
||||
expect(componentScope.optRefAlias).toBe(componentScope.optRef);
|
||||
expect(componentScope.$optRefAlias).toBe(componentScope.optRef);
|
||||
|
||||
$rootScope.name = 'misko';
|
||||
$rootScope.$apply();
|
||||
expect(componentScope.optref).toBe($rootScope.name);
|
||||
expect(componentScope.optrefAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$optrefAlias).toBe($rootScope.name);
|
||||
|
||||
$rootScope.name = {};
|
||||
$rootScope.$apply();
|
||||
expect(componentScope.optref).toBe($rootScope.name);
|
||||
expect(componentScope.optrefAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$optrefAlias).toBe($rootScope.name);
|
||||
}));
|
||||
|
||||
it('should not throw exception when reference does not exist', inject(function() {
|
||||
@@ -5345,6 +5363,7 @@ describe('$compile', function() {
|
||||
|
||||
expect(componentScope.optref).toBeUndefined();
|
||||
expect(componentScope.optrefAlias).toBeUndefined();
|
||||
expect(componentScope.$optrefAlias).toBeUndefined();
|
||||
expect(componentScope.optreference).toBeUndefined();
|
||||
}));
|
||||
});
|
||||
@@ -5362,16 +5381,18 @@ describe('$compile', function() {
|
||||
$rootScope.query = '';
|
||||
$rootScope.$apply();
|
||||
|
||||
compile('<div><span my-component colref="collection | filter:query">');
|
||||
compile('<div><span my-component colref="collection | filter:query" $colref$="collection | filter:query">');
|
||||
|
||||
expect(componentScope.colref).toEqual($rootScope.collection);
|
||||
expect(componentScope.colrefAlias).toEqual(componentScope.colref);
|
||||
expect(componentScope.$colrefAlias).toEqual(componentScope.colref);
|
||||
|
||||
$rootScope.query = 'Gab';
|
||||
$rootScope.$apply();
|
||||
|
||||
expect(componentScope.colref).toEqual([$rootScope.collection[0]]);
|
||||
expect(componentScope.colrefAlias).toEqual([$rootScope.collection[0]]);
|
||||
expect(componentScope.$colrefAlias).toEqual([$rootScope.collection[0]]);
|
||||
}));
|
||||
|
||||
it('should update origin scope when isolate scope changes', inject(function() {
|
||||
@@ -5399,10 +5420,11 @@ describe('$compile', function() {
|
||||
|
||||
describe('one-way binding', function() {
|
||||
it('should update isolate when the identity of origin changes', inject(function() {
|
||||
compile('<div><span my-component ow-ref="obj">');
|
||||
compile('<div><span my-component ow-ref="obj" $ow-ref$="obj">');
|
||||
|
||||
expect(componentScope.owRef).toBeUndefined();
|
||||
expect(componentScope.owRefAlias).toBe(componentScope.owRef);
|
||||
expect(componentScope.$owRefAlias).toBe(componentScope.owRef);
|
||||
|
||||
$rootScope.obj = {value: 'initial'};
|
||||
$rootScope.$apply();
|
||||
@@ -5410,12 +5432,14 @@ describe('$compile', function() {
|
||||
expect($rootScope.obj).toEqual({value: 'initial'});
|
||||
expect(componentScope.owRef).toEqual({value: 'initial'});
|
||||
expect(componentScope.owRefAlias).toBe(componentScope.owRef);
|
||||
expect(componentScope.$owRefAlias).toBe(componentScope.owRef);
|
||||
|
||||
// This changes in both scopes because of reference
|
||||
$rootScope.obj.value = 'origin1';
|
||||
$rootScope.$apply();
|
||||
expect(componentScope.owRef.value).toBe('origin1');
|
||||
expect(componentScope.owRefAlias.value).toBe('origin1');
|
||||
expect(componentScope.$owRefAlias.value).toBe('origin1');
|
||||
|
||||
componentScope.owRef = {value: 'isolate1'};
|
||||
componentScope.$apply();
|
||||
@@ -5426,6 +5450,7 @@ describe('$compile', function() {
|
||||
$rootScope.$apply();
|
||||
expect(componentScope.owRef.value).toBe('isolate1');
|
||||
expect(componentScope.owRefAlias.value).toBe('origin2');
|
||||
expect(componentScope.$owRefAlias.value).toBe('origin2');
|
||||
|
||||
// Change does propagate because object identity changes
|
||||
$rootScope.obj = {value: 'origin3'};
|
||||
@@ -5433,10 +5458,11 @@ describe('$compile', function() {
|
||||
expect(componentScope.owRef.value).toBe('origin3');
|
||||
expect(componentScope.owRef).toBe($rootScope.obj);
|
||||
expect(componentScope.owRefAlias).toBe($rootScope.obj);
|
||||
expect(componentScope.$owRefAlias).toBe($rootScope.obj);
|
||||
}));
|
||||
|
||||
it('should update isolate when both change', inject(function() {
|
||||
compile('<div><span my-component ow-ref="name">');
|
||||
compile('<div><span my-component ow-ref="name" $ow-ref$="name">');
|
||||
|
||||
$rootScope.name = {mark:123};
|
||||
componentScope.owRef = 'misko';
|
||||
@@ -5445,6 +5471,7 @@ describe('$compile', function() {
|
||||
expect($rootScope.name).toEqual({mark:123});
|
||||
expect(componentScope.owRef).toBe($rootScope.name);
|
||||
expect(componentScope.owRefAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$owRefAlias).toBe($rootScope.name);
|
||||
|
||||
$rootScope.name = 'igor';
|
||||
componentScope.owRef = {};
|
||||
@@ -5452,6 +5479,7 @@ describe('$compile', function() {
|
||||
expect($rootScope.name).toEqual('igor');
|
||||
expect(componentScope.owRef).toBe($rootScope.name);
|
||||
expect(componentScope.owRefAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$owRefAlias).toBe($rootScope.name);
|
||||
}));
|
||||
|
||||
describe('initialization', function() {
|
||||
@@ -5648,17 +5676,19 @@ describe('$compile', function() {
|
||||
|
||||
it('should not update origin when identity of isolate changes', inject(function() {
|
||||
$rootScope.name = {mark:123};
|
||||
compile('<div><span my-component ow-ref="name">');
|
||||
compile('<div><span my-component ow-ref="name" $ow-ref$="name">');
|
||||
|
||||
expect($rootScope.name).toEqual({mark:123});
|
||||
expect(componentScope.owRef).toBe($rootScope.name);
|
||||
expect(componentScope.owRefAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$owRefAlias).toBe($rootScope.name);
|
||||
|
||||
componentScope.owRef = 'martin';
|
||||
$rootScope.$apply();
|
||||
expect($rootScope.name).toEqual({mark: 123});
|
||||
expect(componentScope.owRef).toBe('martin');
|
||||
expect(componentScope.owRefAlias).toEqual({mark: 123});
|
||||
expect(componentScope.$owRefAlias).toEqual({mark: 123});
|
||||
}));
|
||||
|
||||
|
||||
@@ -5805,20 +5835,23 @@ describe('$compile', function() {
|
||||
|
||||
describe('optional one-way binding', function() {
|
||||
it('should update local when origin changes', inject(function() {
|
||||
compile('<div><span my-component ow-optref="name">');
|
||||
compile('<div><span my-component ow-optref="name" $ow-optref$="name">');
|
||||
|
||||
expect(componentScope.owOptref).toBeUndefined();
|
||||
expect(componentScope.owOptrefAlias).toBe(componentScope.owOptref);
|
||||
expect(componentScope.$owOptrefAlias).toBe(componentScope.owOptref);
|
||||
|
||||
$rootScope.name = 'misko';
|
||||
$rootScope.$apply();
|
||||
expect(componentScope.owOptref).toBe($rootScope.name);
|
||||
expect(componentScope.owOptrefAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$owOptrefAlias).toBe($rootScope.name);
|
||||
|
||||
$rootScope.name = {};
|
||||
$rootScope.$apply();
|
||||
expect(componentScope.owOptref).toBe($rootScope.name);
|
||||
expect(componentScope.owOptrefAlias).toBe($rootScope.name);
|
||||
expect(componentScope.$owOptrefAlias).toBe($rootScope.name);
|
||||
}));
|
||||
|
||||
it('should not throw exception when reference does not exist', inject(function() {
|
||||
@@ -5826,6 +5859,7 @@ describe('$compile', function() {
|
||||
|
||||
expect(componentScope.owOptref).toBeUndefined();
|
||||
expect(componentScope.owOptrefAlias).toBeUndefined();
|
||||
expect(componentScope.$owOptrefAlias).toBeUndefined();
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -5833,17 +5867,19 @@ describe('$compile', function() {
|
||||
|
||||
describe('executable expression', function() {
|
||||
it('should allow expression execution with locals', inject(function() {
|
||||
compile('<div><span my-component expr="count = count + offset">');
|
||||
compile('<div><span my-component expr="count = count + offset" $expr$="count = count + offset">');
|
||||
$rootScope.count = 2;
|
||||
|
||||
expect(typeof componentScope.expr).toBe('function');
|
||||
expect(typeof componentScope.exprAlias).toBe('function');
|
||||
expect(typeof componentScope.$exprAlias).toBe('function');
|
||||
|
||||
expect(componentScope.expr({offset: 1})).toEqual(3);
|
||||
expect($rootScope.count).toEqual(3);
|
||||
|
||||
expect(componentScope.exprAlias({offset: 10})).toEqual(13);
|
||||
expect($rootScope.count).toEqual(13);
|
||||
expect(componentScope.$exprAlias({offset: 10})).toEqual(23);
|
||||
expect($rootScope.count).toEqual(23);
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -5861,17 +5897,21 @@ describe('$compile', function() {
|
||||
expect(componentScope.$$isolateBindings.attr.mode).toBe('@');
|
||||
expect(componentScope.$$isolateBindings.attr.attrName).toBe('attr');
|
||||
expect(componentScope.$$isolateBindings.attrAlias.attrName).toBe('attr');
|
||||
expect(componentScope.$$isolateBindings.$attrAlias.attrName).toBe('$attr$');
|
||||
expect(componentScope.$$isolateBindings.ref.mode).toBe('=');
|
||||
expect(componentScope.$$isolateBindings.ref.attrName).toBe('ref');
|
||||
expect(componentScope.$$isolateBindings.refAlias.attrName).toBe('ref');
|
||||
expect(componentScope.$$isolateBindings.$refAlias.attrName).toBe('$ref$');
|
||||
expect(componentScope.$$isolateBindings.reference.mode).toBe('=');
|
||||
expect(componentScope.$$isolateBindings.reference.attrName).toBe('reference');
|
||||
expect(componentScope.$$isolateBindings.owRef.mode).toBe('<');
|
||||
expect(componentScope.$$isolateBindings.owRef.attrName).toBe('owRef');
|
||||
expect(componentScope.$$isolateBindings.owRefAlias.attrName).toBe('owRef');
|
||||
expect(componentScope.$$isolateBindings.$owRefAlias.attrName).toBe('$owRef$');
|
||||
expect(componentScope.$$isolateBindings.expr.mode).toBe('&');
|
||||
expect(componentScope.$$isolateBindings.expr.attrName).toBe('expr');
|
||||
expect(componentScope.$$isolateBindings.exprAlias.attrName).toBe('expr');
|
||||
expect(componentScope.$$isolateBindings.$exprAlias.attrName).toBe('$expr$');
|
||||
|
||||
var firstComponentScope = componentScope,
|
||||
first$$isolateBindings = componentScope.$$isolateBindings;
|
||||
|
||||
+118
-86
@@ -3,103 +3,135 @@
|
||||
describe('$$cookieReader', function() {
|
||||
var $$cookieReader, document;
|
||||
|
||||
function deleteAllCookies() {
|
||||
var cookies = document.cookie.split(';');
|
||||
var path = window.location.pathname;
|
||||
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i];
|
||||
var eqPos = cookie.indexOf('=');
|
||||
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
||||
var parts = path.split('/');
|
||||
while (parts.length) {
|
||||
document.cookie = name + '=;path=' + (parts.join('/') || '/') + ';expires=Thu, 01 Jan 1970 00:00:00 GMT';
|
||||
parts.pop();
|
||||
describe('with access to `document.cookie`', function() {
|
||||
|
||||
function deleteAllCookies() {
|
||||
var cookies = document.cookie.split(';');
|
||||
var path = window.location.pathname;
|
||||
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i];
|
||||
var eqPos = cookie.indexOf('=');
|
||||
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
||||
var parts = path.split('/');
|
||||
while (parts.length) {
|
||||
document.cookie = name + '=;path=' + (parts.join('/') || '/') + ';expires=Thu, 01 Jan 1970 00:00:00 GMT';
|
||||
parts.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
document = window.document;
|
||||
deleteAllCookies();
|
||||
expect(document.cookie).toEqual('');
|
||||
beforeEach(function() {
|
||||
document = window.document;
|
||||
deleteAllCookies();
|
||||
expect(document.cookie).toEqual('');
|
||||
|
||||
inject(function(_$$cookieReader_) {
|
||||
inject(function(_$$cookieReader_) {
|
||||
$$cookieReader = _$$cookieReader_;
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
deleteAllCookies();
|
||||
expect(document.cookie).toEqual('');
|
||||
});
|
||||
|
||||
|
||||
describe('get via $$cookieReader()[cookieName]', function() {
|
||||
|
||||
it('should return undefined for nonexistent cookie', function() {
|
||||
expect($$cookieReader().nonexistent).not.toBeDefined();
|
||||
});
|
||||
|
||||
|
||||
it('should return a value for an existing cookie', function() {
|
||||
document.cookie = 'foo=bar=baz;path=/';
|
||||
expect($$cookieReader().foo).toEqual('bar=baz');
|
||||
});
|
||||
|
||||
|
||||
it('should return the the first value provided for a cookie', function() {
|
||||
// For a cookie that has different values that differ by path, the
|
||||
// value for the most specific path appears first. $$cookieReader()
|
||||
// should provide that value for the cookie.
|
||||
document.cookie = 'foo="first"; foo="second"';
|
||||
expect($$cookieReader()['foo']).toBe('"first"');
|
||||
});
|
||||
|
||||
|
||||
it('should decode cookie values that were encoded by puts', function() {
|
||||
document.cookie = 'cookie2%3Dbar%3Bbaz=val%3Due;path=/';
|
||||
expect($$cookieReader()['cookie2=bar;baz']).toEqual('val=ue');
|
||||
});
|
||||
|
||||
|
||||
it('should preserve leading & trailing spaces in names and values', function() {
|
||||
document.cookie = '%20cookie%20name%20=%20cookie%20value%20';
|
||||
expect($$cookieReader()[' cookie name ']).toEqual(' cookie value ');
|
||||
expect($$cookieReader()['cookie name']).not.toBeDefined();
|
||||
});
|
||||
|
||||
|
||||
it('should decode special characters in cookie values', function() {
|
||||
document.cookie = 'cookie_name=cookie_value_%E2%82%AC';
|
||||
expect($$cookieReader()['cookie_name']).toEqual('cookie_value_€');
|
||||
});
|
||||
|
||||
|
||||
it('should not decode cookie values that do not appear to be encoded', function() {
|
||||
// see #9211 - sometimes cookies contain a value that causes decodeURIComponent to throw
|
||||
document.cookie = 'cookie_name=cookie_value_%XX';
|
||||
expect($$cookieReader()['cookie_name']).toEqual('cookie_value_%XX');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('getAll via $$cookieReader()', function() {
|
||||
|
||||
it('should return cookies as hash', function() {
|
||||
document.cookie = 'foo1=bar1;path=/';
|
||||
document.cookie = 'foo2=bar2;path=/';
|
||||
expect($$cookieReader()).toEqual({'foo1':'bar1', 'foo2':'bar2'});
|
||||
});
|
||||
|
||||
|
||||
it('should return empty hash if no cookies exist', function() {
|
||||
expect($$cookieReader()).toEqual({});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should initialize cookie cache with existing cookies', function() {
|
||||
document.cookie = 'existingCookie=existingValue;path=/';
|
||||
expect($$cookieReader()).toEqual({'existingCookie':'existingValue'});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('without access to `document.cookie`', function() {
|
||||
var cookieSpy;
|
||||
|
||||
beforeEach(module(function($provide) {
|
||||
cookieSpy = jasmine.createSpy('cookie').and.throwError('Can\'t touch this!');
|
||||
document = Object.create({}, {'cookie': {get: cookieSpy}});
|
||||
|
||||
$provide.value('$document', [document]);
|
||||
}));
|
||||
|
||||
beforeEach(inject(function(_$$cookieReader_) {
|
||||
$$cookieReader = _$$cookieReader_;
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
deleteAllCookies();
|
||||
expect(document.cookie).toEqual('');
|
||||
});
|
||||
|
||||
|
||||
describe('get via $$cookieReader()[cookieName]', function() {
|
||||
|
||||
it('should return undefined for nonexistent cookie', function() {
|
||||
expect($$cookieReader().nonexistent).not.toBeDefined();
|
||||
});
|
||||
|
||||
|
||||
it('should return a value for an existing cookie', function() {
|
||||
document.cookie = 'foo=bar=baz;path=/';
|
||||
expect($$cookieReader().foo).toEqual('bar=baz');
|
||||
});
|
||||
|
||||
it('should return the the first value provided for a cookie', function() {
|
||||
// For a cookie that has different values that differ by path, the
|
||||
// value for the most specific path appears first. $$cookieReader()
|
||||
// should provide that value for the cookie.
|
||||
document.cookie = 'foo="first"; foo="second"';
|
||||
expect($$cookieReader()['foo']).toBe('"first"');
|
||||
});
|
||||
|
||||
it('should decode cookie values that were encoded by puts', function() {
|
||||
document.cookie = 'cookie2%3Dbar%3Bbaz=val%3Due;path=/';
|
||||
expect($$cookieReader()['cookie2=bar;baz']).toEqual('val=ue');
|
||||
});
|
||||
|
||||
|
||||
it('should preserve leading & trailing spaces in names and values', function() {
|
||||
document.cookie = '%20cookie%20name%20=%20cookie%20value%20';
|
||||
expect($$cookieReader()[' cookie name ']).toEqual(' cookie value ');
|
||||
expect($$cookieReader()['cookie name']).not.toBeDefined();
|
||||
});
|
||||
|
||||
it('should decode special characters in cookie values', function() {
|
||||
document.cookie = 'cookie_name=cookie_value_%E2%82%AC';
|
||||
expect($$cookieReader()['cookie_name']).toEqual('cookie_value_€');
|
||||
});
|
||||
|
||||
it('should not decode cookie values that do not appear to be encoded', function() {
|
||||
// see #9211 - sometimes cookies contain a value that causes decodeURIComponent to throw
|
||||
document.cookie = 'cookie_name=cookie_value_%XX';
|
||||
expect($$cookieReader()['cookie_name']).toEqual('cookie_value_%XX');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('getAll via $$cookieReader()', function() {
|
||||
|
||||
it('should return cookies as hash', function() {
|
||||
document.cookie = 'foo1=bar1;path=/';
|
||||
document.cookie = 'foo2=bar2;path=/';
|
||||
expect($$cookieReader()).toEqual({'foo1':'bar1', 'foo2':'bar2'});
|
||||
});
|
||||
|
||||
|
||||
it('should return empty hash if no cookies exist', function() {
|
||||
it('should return an empty object', function() {
|
||||
expect($$cookieReader()).toEqual({});
|
||||
expect(cookieSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should initialize cookie cache with existing cookies', function() {
|
||||
document.cookie = 'existingCookie=existingValue;path=/';
|
||||
expect($$cookieReader()).toEqual({'existingCookie':'existingValue'});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -732,6 +732,24 @@ describe('basic usage', function() {
|
||||
expect(json).toEqual({id: 123, number: '9876', $myProp: 'still here'});
|
||||
});
|
||||
|
||||
it('should not include $cancelRequest when resource is toJson\'ed', function() {
|
||||
$httpBackend.whenGET('/CreditCard').respond({});
|
||||
|
||||
var CreditCard = $resource('/CreditCard', {}, {
|
||||
get: {
|
||||
method: 'GET',
|
||||
cancellable: true
|
||||
}
|
||||
});
|
||||
|
||||
var card = CreditCard.get();
|
||||
var json = card.toJSON();
|
||||
|
||||
expect(card.$cancelRequest).toBeDefined();
|
||||
expect(json.$cancelRequest).toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
describe('promise api', function() {
|
||||
|
||||
var $rootScope;
|
||||
|
||||
Reference in New Issue
Block a user