Skip to content

Commit d07ae70

Browse files
committed
improve fullLayout._has()
- allow fullLayout._has(/*trace type*/) to work - use registry category hash object (instead of categories.indexOf) to find categories in fullLayout._modules
1 parent bb02281 commit d07ae70

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/plots/plots.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -627,24 +627,22 @@ plots.createTransitionData = function(gd) {
627627
// whether a certain plot type is present on plot
628628
// or trace has a category
629629
plots._hasPlotType = function(category) {
630-
// check plot
631-
var basePlotModules = this._basePlotModules || [];
632630
var i;
633631

632+
// check base plot modules
633+
var basePlotModules = this._basePlotModules || [];
634634
for(i = 0; i < basePlotModules.length; i++) {
635-
var _module = basePlotModules[i];
636-
637-
if(_module.name === category) return true;
635+
if(basePlotModules[i].name === category) return true;
638636
}
639637

640-
// check trace
638+
// check trace modules
641639
var modules = this._modules || [];
642-
643640
for(i = 0; i < modules.length; i++) {
644-
var modulei = modules[i];
645-
if(modulei.categories && modulei.categories.indexOf(category) >= 0) {
646-
return true;
647-
}
641+
var name = modules[i].name;
642+
if(name === category) return true;
643+
// N.B. this is modules[i] along with 'categories' as a hash object
644+
var _module = Registry.modules[name];
645+
if(_module && _module.categories[category]) return true;
648646
}
649647

650648
return false;

0 commit comments

Comments
 (0)