File tree 2 files changed +10
-3
lines changed
2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -35,14 +35,14 @@ function extend(from, to) {
35
35
if ( from === null || typeof from !== 'object' ) {
36
36
return from ;
37
37
}
38
- if ( from . constructor !== Object && from . constructor !== Array ) {
39
- return from ;
40
- }
41
38
if ( from . constructor === Date || from . constructor === Function ||
42
39
from . constructor === String || from . constructor === Number ||
43
40
from . constructor === Boolean ) {
44
41
return new from . constructor ( from ) ;
45
42
}
43
+ if ( from . constructor !== Object && from . constructor !== Array ) {
44
+ return from ;
45
+ }
46
46
to = to || new from . constructor ( ) ;
47
47
for ( var name in from ) {
48
48
to [ name ] = to [ name ] ? extend ( from [ name ] , null ) : to [ name ] ;
Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ describe('extend', function() {
26
26
var copy = util . extend ( null , { } ) ;
27
27
assert . strictEqual ( copy , null ) ;
28
28
} ) ;
29
+
30
+ it ( 'should return a new Date for Date input' , function ( ) {
31
+ var now = new Date ( ) ;
32
+ var copy = util . extend ( now , { } ) ;
33
+ assert . notStrictEqual ( copy , now ) ;
34
+ assert . strictEqual ( copy . toString ( ) , now . toString ( ) ) ;
35
+ } ) ;
29
36
} ) ;
30
37
31
38
describe ( 'arrayize' , function ( ) {
You can’t perform that action at this time.
0 commit comments