Skip to content

Commit 5de6ff0

Browse files
committed
split container opts from item opts in handleArrayContainerDefaults
1 parent 9de2f77 commit 5de6ff0

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

src/components/annotations/annotation_defaults.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ var Axes = require('../../plots/cartesian/axes');
1616
var attributes = require('./attributes');
1717

1818

19-
module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, opts) {
19+
module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, opts, itemOpts) {
2020
opts = opts || {};
21+
itemOpts = itemOpts || {};
2122

2223
function coerce(attr, dflt) {
2324
return Lib.coerce(annIn, annOut, attributes, attr, dflt);
2425
}
2526

26-
var visible = coerce('visible', !opts.itemIsNotPlainObject);
27+
var visible = coerce('visible', !itemOpts.itemIsNotPlainObject);
2728

2829
if(!visible) return annOut;
2930

src/components/shapes/shape_defaults.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ var attributes = require('./attributes');
1616
var helpers = require('./helpers');
1717

1818

19-
module.exports = function handleShapeDefaults(shapeIn, shapeOut, fullLayout, opts) {
19+
module.exports = function handleShapeDefaults(shapeIn, shapeOut, fullLayout, opts, itemOpts) {
2020
opts = opts || {};
21+
itemOpts = itemOpts || {};
2122

2223
function coerce(attr, dflt) {
2324
return Lib.coerce(shapeIn, shapeOut, attributes, attr, dflt);
2425
}
2526

26-
var visible = coerce('visible', !opts.itemIsNotPlainObject);
27+
var visible = coerce('visible', !itemOpts.itemIsNotPlainObject);
2728

2829
if(!visible) return shapeOut;
2930

src/plots/array_container_defaults.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -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
*/
4044
module.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

Comments
 (0)