@@ -15,59 +15,62 @@ const assign = function (target, source, handler) {
15
15
return target
16
16
}
17
17
18
- export default function mergeData ( target , source ) {
19
- // Shallow copy target
20
- target = assign ( { } , target )
18
+ export default function mergeData ( ) {
19
+ const args = [ ] . slice . call ( arguments )
20
+ const target = assign ( { } , args [ 0 ] )
21
+ const sources = args . slice ( 1 )
21
22
22
- // Merge
23
- assign ( target , source , propName => {
24
- const targetValue = target [ propName ]
25
- const sourceValue = source [ propName ]
26
- if ( targetValue ) {
27
- switch ( propName ) {
28
- // append
29
- case 'staticClass' :
30
- target [ propName ] = ( targetValue + ' ' + sourceValue ) . trim ( )
31
- break
32
- // override
33
- case 'attrs' :
34
- case 'domProps' :
35
- case 'scopedSlots' :
36
- case 'staticStyle' :
37
- case 'props' :
38
- case 'hook' :
39
- case 'transition' :
40
- assign ( targetValue , sourceValue )
41
- break
42
- // expand
43
- case 'class' :
44
- case 'style' :
45
- case 'directives' :
46
- target [ propName ] = [ ] . concat ( sourceValue , targetValue )
47
- break
48
- // expand
49
- case 'on' :
50
- case 'nativeOn' :
51
- assign ( targetValue , sourceValue , listenerName => {
52
- if ( targetValue [ listenerName ] ) {
53
- targetValue [ listenerName ] = [ ] . concat (
54
- sourceValue [ listenerName ] ,
55
- targetValue [ listenerName ]
56
- )
57
- } else {
58
- targetValue [ listenerName ] = sourceValue [ listenerName ]
59
- }
60
- } )
61
- break
62
- // override
63
- default :
64
- target [ propName ] = source [ propName ]
65
- break
23
+ for ( const i in sources ) {
24
+ const source = sources [ i ]
25
+ assign ( target , source , propName => {
26
+ const targetValue = target [ propName ]
27
+ const sourceValue = source [ propName ]
28
+ if ( targetValue ) {
29
+ switch ( propName ) {
30
+ // append
31
+ case 'staticClass' :
32
+ target [ propName ] = ( targetValue + ' ' + sourceValue ) . trim ( )
33
+ break
34
+ // override
35
+ case 'attrs' :
36
+ case 'domProps' :
37
+ case 'scopedSlots' :
38
+ case 'staticStyle' :
39
+ case 'props' :
40
+ case 'hook' :
41
+ case 'transition' :
42
+ assign ( targetValue , sourceValue )
43
+ break
44
+ // expand
45
+ case 'class' :
46
+ case 'style' :
47
+ case 'directives' :
48
+ target [ propName ] = [ ] . concat ( sourceValue , targetValue )
49
+ break
50
+ // expand
51
+ case 'on' :
52
+ case 'nativeOn' :
53
+ assign ( targetValue , sourceValue , listenerName => {
54
+ if ( targetValue [ listenerName ] ) {
55
+ targetValue [ listenerName ] = [ ] . concat (
56
+ sourceValue [ listenerName ] ,
57
+ targetValue [ listenerName ]
58
+ )
59
+ } else {
60
+ targetValue [ listenerName ] = sourceValue [ listenerName ]
61
+ }
62
+ } )
63
+ break
64
+ // override
65
+ default :
66
+ target [ propName ] = source [ propName ]
67
+ break
68
+ }
69
+ } else {
70
+ target [ propName ] = sourceValue
66
71
}
67
- } else {
68
- target [ propName ] = sourceValue
69
- }
70
- } )
72
+ } )
73
+ }
71
74
72
75
return target
73
76
}
0 commit comments