This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix($routeProvider): do not deep-copy route definition objects #14750
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deep-copying route definition objects can break specific custom implementations of `$sce` (used to trust a `templateUrl` as RESOURCE_URL). The purpose of copying route definition objects was to guard against the user's modifying the route definition object after route registration, while still capturing inherited properties. As suggested by @IgorMinar in angular#14699 (comment), we can achieve both _and_ support custom `$sce` implementations, by shallow-copying instead. This is an alternative implementation for angular#14699, which avoids the breaking change. Fixes 14478 Closes 14699
@@ -1,6 +1,6 @@ | |||
'use strict'; | |||
|
|||
describe('$route', function() { | |||
fdescribe('$route', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fdescribe
|
||
inject(function($location, $rootScope, $route, $sce) { | ||
var sceWrappedUrl = $sce.trustAsResourceUrl('foo.html'); | ||
$routeProvider.when('/foo', {templateUrl: sceWrappedUrl}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the $routeProvider
registration in the inject and not the module block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I couldn't access $sce
during config 😟
LGTM. If you needed another one. :> |
gkalpak
force-pushed
the
fix-ngRoute-shallow-copy-rdo
branch
from
June 10, 2016 10:19
b24e09e
to
fdcbc50
Compare
LGTM |
gkalpak
added a commit
that referenced
this pull request
Jun 10, 2016
Deep-copying route definition objects can break specific custom implementations of `$sce` (used to trust a `templateUrl` as RESOURCE_URL). The purpose of copying route definition objects was to guard against the user's modifying the route definition object after route registration, while still capturing inherited properties. As suggested by @IgorMinar in #14699 (comment), we can achieve both _and_ support custom `$sce` implementations, by shallow-copying instead. This is an alternative implementation for #14699, which avoids the breaking change. Fixes #14478 Closes #14699 Closes #14750
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix
What is the current behavior? (You can also link to an open issue here)
When registering a route, route definition objects are deep-copied, which breaks specific custom implementations of
$sce
(used to trust atemplateUrl
as RESOURCE_URL).What is the new behavior (if this is a feature change)?
When registering a route, route definition objects are shallow-copied, which doesn't break custom implementations of
$sce
.Does this PR introduce a breaking change?
No
Please check if the PR fulfills these requirements
Docs have been added / updated (for bug fixes / features)Other information:
Deep-copying route definition objects can break specific custom implementations of
$sce
(used to trust atemplateUrl
as RESOURCE_URL. The purpose of copying route definition objects was to guard against the user's modifying the route definition object after route registration, while still capturing inherited properties.As suggested by @IgorMinar in #14699 (comment), we can achieve both and support custom
$sce
implementations, by shallow-copying instead.This is an alternative implementation for #14699, which avoids the breaking change.
Fixes #14478
Closes #14699