@@ -26,16 +26,20 @@ var Lib = require('../lib');
2626 * - name {string}
2727 * name of the key linking the container in question
2828 * - 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
3030 *
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}
3138 * N.B.
3239 *
3340 * - opts is passed to handleItemDefaults so it can also store
3441 * links to supplementary data (e.g. fullData for layout components)
3542 *
36- * - opts.itemIsNotPlainObject is mutated on every pass in case so logic
37- * in handleItemDefaults relies on that fact.
38- *
3943 */
4044module . exports = function handleArrayContainerDefaults ( parentObjIn , parentObjOut , opts ) {
4145 var name = opts . name ;
@@ -45,17 +49,15 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut
4549
4650 for ( var i = 0 ; i < contIn . length ; i ++ ) {
4751 var itemIn = contIn [ i ] ,
48- itemOut = { } ;
52+ itemOut = { } ,
53+ itemOpts = { } ;
4954
5055 if ( ! Lib . isPlainObject ( itemIn ) ) {
51- opts . itemIsNotPlainObject = true ;
56+ itemOpts . itemIsNotPlainObject = true ;
5257 itemIn = { } ;
5358 }
54- else {
55- opts . itemIsNotPlainObject = false ;
56- }
5759
58- opts . handleItemDefaults ( itemIn , itemOut , parentObjOut , opts ) ;
60+ opts . handleItemDefaults ( itemIn , itemOut , parentObjOut , opts , itemOpts ) ;
5961
6062 itemOut . _input = itemIn ;
6163 itemOut . _index = i ;
0 commit comments