@@ -26,16 +26,20 @@ var Lib = require('../lib');
26
26
* - name {string}
27
27
* name of the key linking the container in question
28
28
* - handleItemDefaults {function}
29
- * defaults method to be called on each item in the array container in question,
29
+ * defaults method to be called on each item in the array container in question
30
30
*
31
+ * Its arguments are:
32
+ * - itemIn {object} item in user layout
33
+ * - itemOut {object} item in full layout
34
+ * - parentObj {object} (as in closure)
35
+ * - opts {object} (as in closure)
36
+ * - itemOpts {object}
37
+ * - itemIsNotPlainObject {boolean}
31
38
* N.B.
32
39
*
33
40
* - opts is passed to handleItemDefaults so it can also store
34
41
* links to supplementary data (e.g. fullData for layout components)
35
42
*
36
- * - opts.itemIsNotPlainObject is mutated on every pass in case so logic
37
- * in handleItemDefaults relies on that fact.
38
- *
39
43
*/
40
44
module . exports = function handleArrayContainerDefaults ( parentObjIn , parentObjOut , opts ) {
41
45
var name = opts . name ;
@@ -45,17 +49,15 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut
45
49
46
50
for ( var i = 0 ; i < contIn . length ; i ++ ) {
47
51
var itemIn = contIn [ i ] ,
48
- itemOut = { } ;
52
+ itemOut = { } ,
53
+ itemOpts = { } ;
49
54
50
55
if ( ! Lib . isPlainObject ( itemIn ) ) {
51
- opts . itemIsNotPlainObject = true ;
56
+ itemOpts . itemIsNotPlainObject = true ;
52
57
itemIn = { } ;
53
58
}
54
- else {
55
- opts . itemIsNotPlainObject = false ;
56
- }
57
59
58
- opts . handleItemDefaults ( itemIn , itemOut , parentObjOut , opts ) ;
60
+ opts . handleItemDefaults ( itemIn , itemOut , parentObjOut , opts , itemOpts ) ;
59
61
60
62
itemOut . _input = itemIn ;
61
63
itemOut . _index = i ;
0 commit comments