Skip to content

Commit c8d6501

Browse files
authored
remove detectmissingcss method (#193)
Resolves #74 * detectmissingcss * remove unused t from tests; remove detect css test * reduce childnodes check from 3 to 2. * remove skipcssstub * remoe unused t from arguments * undo remove t from arguments * add t argument back in * change test calls for t argument
1 parent 4b753d2 commit c8d6501

17 files changed

Lines changed: 73 additions & 136 deletions

bench/gl-stats.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
window.performance.now = () => now;
1010
</script>
1111
<script src="../dist/maplibre-gl.js"></script>
12-
<style>.mapboxgl-canary { background-color: salmon; }</style>
1312
</head>
1413
<body style="margin: 0; padding: 0"><div id="map" style="width: 500px; height: 500px"></div></body>
1514
<script>

src/css/maplibre-gl.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
height: 100%;
1717
}
1818

19-
.mapboxgl-canary {
20-
background-color: salmon;
21-
}
22-
2319
.mapboxgl-canvas-container.mapboxgl-interactive,
2420
.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass {
2521
cursor: -webkit-grab;

src/ui/map.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ class Map extends Camera {
270270
handlers: HandlerManager;
271271

272272
_container: HTMLElement;
273-
_missingCSSCanary: HTMLElement;
274273
_canvasContainer: HTMLElement;
275274
_controlContainer: HTMLElement;
276275
_controlPositions: {[_: string]: HTMLElement};
@@ -2283,24 +2282,10 @@ class Map extends Camera {
22832282
return [width, height];
22842283
}
22852284

2286-
_detectMissingCSS(): void {
2287-
const computedColor = window.getComputedStyle(this._missingCSSCanary).getPropertyValue('background-color');
2288-
if (computedColor !== 'rgb(250, 128, 114)') {
2289-
warnOnce('This page appears to be missing CSS declarations for ' +
2290-
'Mapbox GL JS, which may cause the map to display incorrectly. ' +
2291-
'Please ensure your page includes mapbox-gl.css, as described ' +
2292-
'in https://www.mapbox.com/mapbox-gl-js/api/.');
2293-
}
2294-
}
2295-
22962285
_setupContainer() {
22972286
const container = this._container;
22982287
container.classList.add('mapboxgl-map');
22992288

2300-
const missingCSSCanary = this._missingCSSCanary = DOM.create('div', 'mapboxgl-canary', container);
2301-
missingCSSCanary.style.visibility = 'hidden';
2302-
this._detectMissingCSS();
2303-
23042289
const canvasContainer = this._canvasContainer = DOM.create('div', 'mapboxgl-canvas-container', container);
23052290
if (this._interactive) {
23062291
canvasContainer.classList.add('mapboxgl-interactive');
@@ -2607,7 +2592,6 @@ class Map extends Camera {
26072592
if (extension) extension.loseContext();
26082593
removeNode(this._canvasContainer);
26092594
removeNode(this._controlContainer);
2610-
removeNode(this._missingCSSCanary);
26112595
this._container.classList.remove('mapboxgl-map');
26122596

26132597
PerformanceUtils.clearMetrics();

test/unit/ui/handler/box_zoom.test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import Map from '../../../../src/ui/map';
44
import DOM from '../../../../src/util/dom';
55
import simulate from '../../../util/simulate_interaction';
66

7-
function createMap(t, clickTolerance) {
8-
t.stub(Map.prototype, '_detectMissingCSS');
7+
function createMap(clickTolerance) {
98
return new Map({container: DOM.create('div', '', window.document.body), clickTolerance});
109
}
1110

1211
test('BoxZoomHandler fires boxzoomstart and boxzoomend events at appropriate times', (t) => {
13-
const map = createMap(t);
12+
const map = createMap();
1413

1514
const boxzoomstart = t.spy();
1615
const boxzoomend = t.spy();
@@ -38,7 +37,7 @@ test('BoxZoomHandler fires boxzoomstart and boxzoomend events at appropriate tim
3837
});
3938

4039
test('BoxZoomHandler avoids conflicts with DragPanHandler when disabled and reenabled (#2237)', (t) => {
41-
const map = createMap(t);
40+
const map = createMap();
4241

4342
map.boxZoom.disable();
4443
map.boxZoom.enable();
@@ -81,7 +80,7 @@ test('BoxZoomHandler avoids conflicts with DragPanHandler when disabled and reen
8180
});
8281

8382
test('BoxZoomHandler does not begin a box zoom if preventDefault is called on the mousedown event', (t) => {
84-
const map = createMap(t);
83+
const map = createMap();
8584

8685
map.on('mousedown', e => e.preventDefault());
8786

@@ -108,7 +107,7 @@ test('BoxZoomHandler does not begin a box zoom if preventDefault is called on th
108107
});
109108

110109
test('BoxZoomHandler does not begin a box zoom on spurious mousemove events', (t) => {
111-
const map = createMap(t);
110+
const map = createMap();
112111

113112
const boxzoomstart = t.spy();
114113
const boxzoomend = t.spy();
@@ -136,7 +135,7 @@ test('BoxZoomHandler does not begin a box zoom on spurious mousemove events', (t
136135
});
137136

138137
test('BoxZoomHandler does not begin a box zoom until mouse move is larger than click tolerance', (t) => {
139-
const map = createMap(t, 4);
138+
const map = createMap(4);
140139

141140
const boxzoomstart = t.spy();
142141
const boxzoomend = t.spy();

test/unit/ui/handler/dblclick_zoom.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import Map from '../../../../src/ui/map';
44
import DOM from '../../../../src/util/dom';
55
import simulate from '../../../util/simulate_interaction';
66

7-
function createMap(t) {
8-
t.stub(Map.prototype, '_detectMissingCSS');
7+
function createMap() {
98
return new Map({container: DOM.create('div', '', window.document.body)});
109
}
1110

test/unit/ui/handler/drag_pan.test.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import Map from '../../../../src/ui/map';
44
import DOM from '../../../../src/util/dom';
55
import simulate from '../../../util/simulate_interaction';
66

7-
function createMap(t, clickTolerance, dragPan) {
8-
t.stub(Map.prototype, '_detectMissingCSS');
7+
function createMap(clickTolerance, dragPan) {
98
return new Map({
109
container: DOM.create('div', '', window.document.body),
1110
clickTolerance: clickTolerance || 0,
@@ -17,7 +16,7 @@ function createMap(t, clickTolerance, dragPan) {
1716
const buttons = 1;
1817

1918
test('DragPanHandler fires dragstart, drag, and dragend events at appropriate times in response to a mouse-triggered drag', (t) => {
20-
const map = createMap(t);
19+
const map = createMap();
2120

2221
const dragstart = t.spy();
2322
const drag = t.spy();
@@ -50,7 +49,7 @@ test('DragPanHandler fires dragstart, drag, and dragend events at appropriate ti
5049
});
5150

5251
test('DragPanHandler captures mousemove events during a mouse-triggered drag (receives them even if they occur outside the map)', (t) => {
53-
const map = createMap(t);
52+
const map = createMap();
5453

5554
const dragstart = t.spy();
5655
const drag = t.spy();
@@ -83,7 +82,7 @@ test('DragPanHandler captures mousemove events during a mouse-triggered drag (re
8382
});
8483

8584
test('DragPanHandler fires dragstart, drag, and dragend events at appropriate times in response to a touch-triggered drag', (t) => {
86-
const map = createMap(t);
85+
const map = createMap();
8786
const target = map.getCanvas();
8887

8988
const dragstart = t.spy();
@@ -117,7 +116,7 @@ test('DragPanHandler fires dragstart, drag, and dragend events at appropriate ti
117116
});
118117

119118
test('DragPanHandler prevents mousemove events from firing during a drag (#1555)', (t) => {
120-
const map = createMap(t);
119+
const map = createMap();
121120

122121
const mousemove = t.spy();
123122
map.on('mousemove', mousemove);
@@ -138,7 +137,7 @@ test('DragPanHandler prevents mousemove events from firing during a drag (#1555)
138137
});
139138

140139
test('DragPanHandler ends a mouse-triggered drag if the window blurs', (t) => {
141-
const map = createMap(t);
140+
const map = createMap();
142141

143142
const dragend = t.spy();
144143
map.on('dragend', dragend);
@@ -157,7 +156,7 @@ test('DragPanHandler ends a mouse-triggered drag if the window blurs', (t) => {
157156
});
158157

159158
test('DragPanHandler ends a touch-triggered drag if the window blurs', (t) => {
160-
const map = createMap(t);
159+
const map = createMap();
161160
const target = map.getCanvas();
162161

163162
const dragend = t.spy();
@@ -177,7 +176,7 @@ test('DragPanHandler ends a touch-triggered drag if the window blurs', (t) => {
177176
});
178177

179178
test('DragPanHandler requests a new render frame after each mousemove event', (t) => {
180-
const map = createMap(t);
179+
const map = createMap();
181180
const requestFrame = t.spy(map.handlers, '_requestFrame');
182181

183182
simulate.mousedown(map.getCanvas());
@@ -197,7 +196,7 @@ test('DragPanHandler requests a new render frame after each mousemove event', (t
197196

198197
test('DragPanHandler can interleave with another handler', (t) => {
199198
// https://github.com/mapbox/mapbox-gl-js/issues/6106
200-
const map = createMap(t);
199+
const map = createMap();
201200

202201
const dragstart = t.spy();
203202
const drag = t.spy();
@@ -244,7 +243,7 @@ test('DragPanHandler can interleave with another handler', (t) => {
244243

245244
['ctrl', 'shift'].forEach((modifier) => {
246245
test(`DragPanHandler does not begin a drag if the ${modifier} key is down on mousedown`, (t) => {
247-
const map = createMap(t);
246+
const map = createMap();
248247
t.ok(map.dragRotate.isEnabled());
249248

250249
const dragstart = t.spy();
@@ -278,7 +277,7 @@ test('DragPanHandler can interleave with another handler', (t) => {
278277
});
279278

280279
test(`DragPanHandler still ends a drag if the ${modifier} key is down on mouseup`, (t) => {
281-
const map = createMap(t);
280+
const map = createMap();
282281
t.ok(map.dragRotate.isEnabled());
283282

284283
const dragstart = t.spy();
@@ -313,7 +312,7 @@ test('DragPanHandler can interleave with another handler', (t) => {
313312
});
314313

315314
test('DragPanHandler does not begin a drag on right button mousedown', (t) => {
316-
const map = createMap(t);
315+
const map = createMap();
317316
map.dragRotate.disable();
318317

319318
const dragstart = t.spy();
@@ -347,7 +346,7 @@ test('DragPanHandler does not begin a drag on right button mousedown', (t) => {
347346
});
348347

349348
test('DragPanHandler does not end a drag on right button mouseup', (t) => {
350-
const map = createMap(t);
349+
const map = createMap();
351350
map.dragRotate.disable();
352351

353352
const dragstart = t.spy();
@@ -399,7 +398,7 @@ test('DragPanHandler does not end a drag on right button mouseup', (t) => {
399398
});
400399

401400
test('DragPanHandler does not begin a drag if preventDefault is called on the mousedown event', (t) => {
402-
const map = createMap(t);
401+
const map = createMap();
403402

404403
map.on('mousedown', e => e.preventDefault());
405404

@@ -429,7 +428,7 @@ test('DragPanHandler does not begin a drag if preventDefault is called on the mo
429428
});
430429

431430
test('DragPanHandler does not begin a drag if preventDefault is called on the touchstart event', (t) => {
432-
const map = createMap(t);
431+
const map = createMap();
433432
const target = map.getCanvas();
434433

435434
map.on('touchstart', e => e.preventDefault());
@@ -460,7 +459,7 @@ test('DragPanHandler does not begin a drag if preventDefault is called on the to
460459
});
461460

462461
test('DragPanHandler does not begin a drag if preventDefault is called on the touchstart event (delegated)', (t) => {
463-
const map = createMap(t);
462+
const map = createMap();
464463
const target = map.getCanvas();
465464

466465
t.stub(map, 'getLayer')

0 commit comments

Comments
 (0)