Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a5221f3

Browse filesBrowse files
sreeramucaitp
authored andcommitted
fix(merge): regExp should not be treated as a objects when merging.
angular.merge({ key: /regexp/ }) now works the way you'd expect it to. Horray! Closes angular#12419 Closes angular#12409
1 parent 18a2e4f commit a5221f3
Copy full SHA for a5221f3

File tree

Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Open diff view settings
Collapse file

‎src/Angular.js‎

Copy file name to clipboardExpand all lines: src/Angular.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ function baseExtend(dst, objs, deep) {
354354
if (deep && isObject(src)) {
355355
if (isDate(src)) {
356356
dst[key] = new Date(src.valueOf());
357+
} else if (isRegExp(src)) {
358+
dst[key] = new RegExp(src);
357359
} else {
358360
if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};
359361
baseExtend(dst[key], [src], true);
Collapse file

‎test/AngularSpec.js‎

Copy file name to clipboardExpand all lines: test/AngularSpec.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,17 @@ describe('angular', function() {
570570
expect(isDate(dst.date)).toBeTruthy();
571571
expect(dst.date.valueOf()).toEqual(src.date.valueOf());
572572
});
573+
574+
it('should copy regexp by value', function() {
575+
var src = { regexp: /blah/ };
576+
var dst = {};
577+
578+
merge(dst, src);
579+
580+
expect(dst.regexp).not.toBe(src.regexp);
581+
expect(isRegExp(dst.regexp)).toBe(true);
582+
expect(dst.regexp.toString()).toBe(src.regexp.toString());
583+
});
573584
});
574585

575586

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.