Skip to content

Commit 1c6b292

Browse files
committed
fill in layoutArrayContainer via Register
- instead of relying on a hard-coded list
1 parent b9f2c8e commit 1c6b292

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/plot_api/register.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,9 @@ function registerTransformModule(newModule) {
8989
}
9090

9191
function registerComponentModule(newModule) {
92-
Registry.componentsRegistry[newModule.name] = newModule;
92+
if(typeof newModule.name !== 'string') {
93+
throw new Error('Component module *name* must be a string.');
94+
}
95+
96+
Registry.registerComponent(newModule);
9397
}

src/plots/plots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ plots.extendObjectWithContainers = function(dest, src, containerPaths) {
16141614
};
16151615

16161616
plots.dataArrayContainers = ['transforms'];
1617-
plots.layoutArrayContainers = ['annotations', 'shapes', 'images', 'sliders', 'updatemenus'];
1617+
plots.layoutArrayContainers = Registry.layoutArrayContainers;
16181618

16191619
/*
16201620
* Extend a trace definition. This method:

src/registry.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ var Lib = require('./lib');
1313
var basePlotAttributes = require('./plots/attributes');
1414

1515
exports.modules = {};
16-
exports.allTypes = [];
1716
exports.allCategories = {};
17+
exports.allTypes = [];
1818
exports.subplotsRegistry = {};
1919
exports.transformsRegistry = {};
2020
exports.componentsRegistry = {};
21+
exports.layoutArrayContainers = [];
2122

2223
/**
2324
* register a module as the handler for a trace type
@@ -83,6 +84,16 @@ exports.registerSubplot = function(_module) {
8384
exports.subplotsRegistry[plotType] = _module;
8485
};
8586

87+
exports.registerComponent = function(_module) {
88+
var name = _module.name;
89+
90+
exports.componentsRegistry[name] = _module;
91+
92+
if(_module.layoutAttributes && _module.layoutAttributes._isLinkedToArray) {
93+
Lib.pushUnique(exports.layoutArrayContainers, name);
94+
}
95+
};
96+
8697
/**
8798
* Get registered module using trace object or trace type
8899
*

0 commit comments

Comments
 (0)