forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix($routeProvider): do not deep-copy route definition objects
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 angular#14478 Closes angular#14699 Closes angular#14750
- Loading branch information
Showing
6 changed files
with
119 additions
and
28 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
/* global shallowCopy: true */ | ||
|
||
/** | ||
* Creates a shallow copy of an object, an array or a primitive. | ||
* | ||
* Assumes that there are no proto properties for objects. | ||
*/ | ||
function shallowCopy(src, dst) { | ||
if (isArray(src)) { | ||
dst = dst || []; | ||
|
||
for (var i = 0, ii = src.length; i < ii; i++) { | ||
dst[i] = src[i]; | ||
} | ||
} else if (isObject(src)) { | ||
dst = dst || {}; | ||
|
||
for (var key in src) { | ||
if (!(key.charAt(0) === '$' && key.charAt(1) === '$')) { | ||
dst[key] = src[key]; | ||
} | ||
} | ||
} | ||
|
||
return dst || src; | ||
} |
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
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