Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 372e31a

Browse files
alexdmillerIgorMinar
authored andcommitted
docs(guide/migration): clarify some confusing points
Closes #6756
1 parent 6bf3a12 commit 372e31a

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

docs/content/guide/migration.ngdoc

+45-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ below should still apply, but you may want to consult the
2727
<li>{@link guide/migration#ngroute-has-been-moved-into-its-own-module ngRoute has been moved into its own module}</li>
2828
<li>{@link guide/migration#templates-no-longer-automatically-unwrap-promises Templates no longer automatically unwrap promises}</li>
2929
<li>{@link guide/migration#syntax-for-named-wildcard-parameters-changed-in Syntax for named wildcard parameters changed in <code>$route</code>}</li>
30-
<li>{@link guide/migration#you-can-only-bind-one-expression-to You can only bind one expression to <code>*[src]</code> or <code>*[ng-src]</code>}</li>
30+
<li>{@link guide/migration#you-can-only-bind-one-expression-to You can only bind one expression to <code>*[src]</code>, <code>*[ng-src]</code> or <code>action</code>}</li>
3131
<li>{@link guide/migration#interpolations-inside-dom-event-handlers-are-now-disallowed Interpolations inside DOM event handlers are now disallowed}</li>
3232
<li>{@link guide/migration#directives-cannot-end-with--start-or--end Directives cannot end with -start or -end}</li>
3333
<li>{@link guide/migration#in-$q,-promisealways-has-been-renamed-promisefinally In $q, promise.always has been renamed promise.finally}</li>
@@ -50,6 +50,7 @@ below should still apply, but you may want to consult the
5050
<li>{@link guide/migration#you-cannot-bind-to-select[multiple] You cannot bind to select[multiple]}</li>
5151
<li>{@link guide/migration#uncommon-region-specific-local-files-were-removed-from-i18n Uncommon region-specific local files were removed from i18n}</li>
5252
<li>{@link guide/migration#services-can-now-return-functions Services can now return functions}</li>
53+
<li>{@link guide/migration#modifying-the-dom-outside-digest-cycle Modifying the DOM outside digest cycle}</li>
5354
</ul>
5455

5556

@@ -139,17 +140,18 @@ $routeProvider.when('/Book1/:book/Chapter/:chapter/:highlight*/edit',
139140
See [04cebcc1](https://github.com/angular/angular.js/commit/04cebcc133c8b433a3ac5f72ed19f3631778142b).
140141

141142

142-
## You can only bind one expression to `*[src]` or `*[ng-src]`
143+
## You can only bind one expression to `*[src]`, `*[ng-src]` or `action`
143144

144145
With the exception of `<a>` and `<img>` elements, you cannot bind more than one expression to the
145-
`src` attribute of elements.
146+
`src` or `action` attribute of elements.
146147

147148
This is one of several improvements to security introduces by Angular 1.2.
148149

149150
Concatenating expressions makes it hard to understand whether some combination of concatenated
150151
values are unsafe to use and potentially subject to XSS vulnerabilities. To simplify the task of
151152
auditing for XSS issues, we now require that a single expression be used for `*[src/ng-src]`
152-
bindings such as bindings for `iframe[src]`, `object[src]`, etc.
153+
bindings such as bindings for `iframe[src]`, `object[src]`, etc. In addition, this requirement is
154+
enforced for `form` tags with `action` attributes.
153155

154156
<table class="table table-bordered code-table">
155157
<thead>
@@ -542,9 +544,45 @@ See [1adf29af](https://github.com/angular/angular.js/commit/1adf29af13890d612868
542544

543545
## Isolate scope only exposed to directives with `scope` property
544546

545-
Directives without isolate scope do not get the isolate scope from an isolate directive on the
546-
same element. If your code depends on this behavior (non-isolate directive needs to access state
547-
from within the isolate scope), change the isolate directive to use scope locals to pass these explicitly.
547+
If you declare a scope option on a directive, that directive will have an
548+
[isolate scope](https://github.com/angular/angular.js/wiki/Understanding-Scopes). In Angular 1.0, if a
549+
directive with an isolate scope is used on an element, all directives on that same element have access
550+
to the same isolate scope. For example, say we have the following directives:
551+
552+
```
553+
// This directive declares an isolate scope.
554+
.directive('isolateScope', function() {
555+
return {
556+
scope: {},
557+
link: function($scope) {
558+
console.log('one = ' + $scope.$id);
559+
}
560+
};
561+
})
562+
563+
// This directive does not.
564+
.directive('nonIsolateScope', function() {
565+
return {
566+
link: function($scope) {
567+
console.log('two = ' + $scope.$id);
568+
}
569+
};
570+
});
571+
```
572+
573+
Now what happens if we use both directives on the same element?
574+
575+
```
576+
<div isolate-scope non-isolate-scope></div>
577+
```
578+
579+
In Angular 1.0, the nonIsolateScope directive will have access to the isolateScope directive’s scope. The
580+
log statements will print the same id, because the scope is the same. But in Angular 1.2, the nonIsolateScope
581+
will not use the same scope as isolateScope. Instead, it will inherit the parent scope. The log statements
582+
will print different id’s.
583+
584+
If your code depends on the Angular 1.0 behavior (non-isolate directive needs to access state
585+
from within the isolate scope), change the isolate directive to use scope locals to pass these explicitly:
548586

549587
**Before**
550588

0 commit comments

Comments
 (0)