Skip to content

Commit 5b43b8c

Browse files
committed
add mapbox-gl CSS when registering mapbox basePlotModule
... to avoid console warning on subplot instantiation
1 parent 1ee02da commit 5b43b8c

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/plots/mapbox/constants.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = {
4242
// a subset of node_modules/mapbox-gl/dist/mapbox-gl.css
4343
styleRules: {
4444
map: 'overflow:hidden;position:relative;',
45-
'missing-css': 'display:none',
45+
'missing-css': 'display:none;',
46+
'canary': 'background-color:salmon;'
4647
}
4748
};

src/plots/mapbox/index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ var getSubplotCalcData = require('../../plots/get_data').getSubplotCalcData;
1515
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
1616

1717
var createMapbox = require('./mapbox');
18-
var constants = require('./constants');
1918

2019
var MAPBOX = 'mapbox';
2120

22-
for(var k in constants.styleRules) {
23-
Lib.addStyleRule('.mapboxgl-' + k, constants.styleRules[k]);
24-
}
21+
var constants = exports.constants = require('./constants');
2522

2623
exports.name = MAPBOX;
2724

src/registry.js

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var Loggers = require('./lib/loggers');
1212
var noop = require('./lib/noop');
1313
var pushUnique = require('./lib/push_unique');
1414
var isPlainObject = require('./lib/is_plain_object');
15+
var addStyleRule = require('./lib/dom').addStyleRule;
1516
var ExtendModule = require('./lib/extend');
1617

1718
var basePlotAttributes = require('./plots/attributes');
@@ -267,6 +268,15 @@ function registerTraceModule(_module) {
267268
if(_module.layoutAttributes) {
268269
extendFlat(exports.traceLayoutAttributes, _module.layoutAttributes);
269270
}
271+
272+
// add mapbox-gl CSS here to avoid console warning on instantiation
273+
var basePlotModule = _module.basePlotModule;
274+
if(basePlotModule.name === 'mapbox') {
275+
var styleRules = basePlotModule.constants.styleRules;
276+
for(var k in styleRules) {
277+
addStyleRule('.mapboxgl-' + k, styleRules[k]);
278+
}
279+
}
270280
}
271281

272282
function registerSubplot(_module) {

0 commit comments

Comments
 (0)