Remove deprecated methods / options (#9622)

This commit is contained in:
Florian Bischof
2025-05-06 20:07:11 +02:00
committed by GitHub
parent 1e9fa63171
commit dd4b28aef8
20 changed files with 25 additions and 89 deletions

View File

@ -634,9 +634,6 @@ describe('Events', () => {
expect(spy2.calledWith({
type: 'test2',
target: parent,
// layer should be deprecated in the future
// in favor of sourceTarget
layer: obj,
sourceTarget: obj,
propagatedFrom: obj
})).to.be.true;

View File

@ -42,15 +42,6 @@ describe('DomEvent.DoubleTapSpec.js', () => {
expect(spy.notCalled).to.be.true;
});
it('does not fire dblclick when detail !== 1', () => {
UIEventSimulator.fire('click', container, {detail: 0}); // like in IE
clock.tick(100);
UIEventSimulator.fire('click', container, {detail: 0});
clock.tick(100);
expect(spy.notCalled).to.be.true;
});
it('does not fire dblclick after removeListener', () => {
DomEvent.off(container, 'dblclick', spy);

View File

@ -599,20 +599,13 @@ describe('DomEvent', () => {
});
describe('#preventDefault', () => {
function isPrevented(e) {
if ('defaultPrevented' in e) {
return e.defaultPrevented;
}
return !e.returnValue; // IE<11
}
it('prevents the default action of event', (done) => {
DomEvent.on(el, 'click', (e) => {
expect(isPrevented(e)).not.to.be.true; // control case
expect(e.defaultPrevented).not.to.be.true; // control case
DomEvent.preventDefault(e);
expect(isPrevented(e)).to.be.true;
expect(e.defaultPrevented).to.be.true;
done();
});

View File

@ -154,7 +154,7 @@ describe('Marker#toGeoJSON', () => {
describe('Circle#toGeoJSON', () => {
it('returns a 2D Point object', () => {
const circle = new Circle([10, 20], 100);
const circle = new Circle([10, 20], {radius: 100});
expect(circle.toGeoJSON().geometry).to.eql({
type: 'Point',
coordinates: [20, 10]
@ -162,7 +162,7 @@ describe('Circle#toGeoJSON', () => {
});
it('returns a 3D Point object', () => {
const circle = new Circle([10, 20, 30], 100);
const circle = new Circle([10, 20, 30], {radius: 100});
expect(circle.toGeoJSON().geometry).to.eql({
type: 'Point',
coordinates: [20, 10, 30]
@ -170,7 +170,7 @@ describe('Circle#toGeoJSON', () => {
});
it('should allow specific precisions', () => {
const circle = new Circle([10.1234, 20.1234, 30.1234], 100);
const circle = new Circle([10.1234, 20.1234, 30.1234], {radius: 100});
expect(circle.toGeoJSON(3).geometry).to.eql({
type: 'Point',
coordinates: [20.123, 10.123, 30.123]

View File

@ -110,23 +110,23 @@ describe('ImageOverlay', () => {
it('should update the z-index of the image if it has allready been added to the map', () => {
const overlay = imageOverlay('', imageBounds);
overlay.addTo(map);
expect(overlay._image.style.zIndex).to.eql('1'); // Number type in IE
expect(overlay._image.style.zIndex).to.eql('1');
overlay.setZIndex('10');
expect(overlay._image.style.zIndex).to.eql('10'); // Number type in IE
expect(overlay._image.style.zIndex).to.eql('10');
});
it('should set the z-index of the image when it is added to the map', () => {
const overlay = imageOverlay('', imageBounds);
overlay.setZIndex('10');
overlay.addTo(map);
expect(overlay._image.style.zIndex).to.eql('10'); // Number type in IE
expect(overlay._image.style.zIndex).to.eql('10');
});
it('should use the z-index specified in options', () => {
const overlay = imageOverlay('', imageBounds, {zIndex: 20});
overlay.addTo(map);
expect(overlay._image.style.zIndex).to.eql('20'); // Number type in IE
expect(overlay._image.style.zIndex).to.eql('20');
});
it('should be fluent', () => {

View File

@ -103,7 +103,7 @@ describe('Popup', () => {
// toggle popup on marker1
group.fire('click', {
latlng: center,
layer: marker1
propagatedFrom: marker1
});
expect(map.hasLayer(group._popup)).to.be.true;
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 1.');
@ -111,7 +111,7 @@ describe('Popup', () => {
// toggle popup on marker2
group.fire('click', {
latlng: [54.6, 38.2],
layer: marker2
propagatedFrom: marker2
});
expect(map.hasLayer(group._popup)).to.be.true;
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 2.');
@ -133,7 +133,7 @@ describe('Popup', () => {
// toggle popup on marker1
group.fire('click', {
latlng: center,
layer: marker1
propagatedFrom: marker1
});
expect(map.hasLayer(group._popup)).to.be.true;
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 1.');
@ -141,7 +141,7 @@ describe('Popup', () => {
// toggle popup on marker2
group.fire('click', {
latlng: [54.6, 38.2],
layer: marker2
propagatedFrom: marker2
});
expect(map.hasLayer(group._popup)).to.be.true;
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 2.');

View File

@ -17,10 +17,7 @@ describe('VideoOverlay', () => {
removeMapContainer(map, container);
});
it('create VideoOverlay', function () {
this.timeout(10000); // This test takes longer than usual in IE
it('create VideoOverlay', () => {
const videoUrls = [
'https://www.mapbox.com/bites/00188/patricia_nasa.webm',
'https://www.mapbox.com/bites/00188/patricia_nasa.mp4'

View File

@ -33,7 +33,7 @@ describe('Icon.Default', () => {
[ // valid
'url("http://localhost:8000/base/dist/images/marker-icon.png")', // Firefox
'url(\'http://localhost:8000/base/dist/images/marker-icon.png\')',
'url(http://localhost:8000/base/dist/images/marker-icon.png)', // IE, Edge
'url(http://localhost:8000/base/dist/images/marker-icon.png)'
].map(stripUrl).forEach((str) => { expect(str).to.equal(properPath); });
[ // invalid

View File

@ -1,5 +1,5 @@
import {expect} from 'chai';
import {Browser, CRS, DomUtil, Map, TileLayer, Util, LatLng} from 'leaflet';
import {Browser, CRS, Map, TileLayer, Util, LatLng} from 'leaflet';
import sinon from 'sinon';
import {createContainer, removeMapContainer} from '../../SpecHelper.js';
@ -442,8 +442,7 @@ describe('TileLayer', () => {
});
});
const _describe = 'crossOrigin' in DomUtil.create('img') ? describe : describe.skip; // skip in IE<11
_describe('crossOrigin option', () => {
describe('crossOrigin option', () => {
beforeEach(() => {
map.setView([0, 0], 2);
});

View File

@ -21,13 +21,6 @@ describe('Circle', () => {
const circle = new Circle([0, 0]);
expect(circle.getRadius()).to.eql(10);
});
it('throws error if radius is NaN', () => {
expect(() => {
new Circle([0, 0], NaN);
}).to.throw('Circle radius cannot be NaN');
});
});
describe('#getBounds', () => {

View File

@ -188,9 +188,6 @@ export const Layers = Control.extend({
container = this._container = DomUtil.create('div', className),
collapsed = this.options.collapsed;
// makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released
container.setAttribute('aria-haspopup', true);
DomEvent.disableClickPropagation(container);
DomEvent.disableScrollPropagation(container);

View File

@ -296,7 +296,6 @@ export const Events = {
_propagateEvent(e) {
for (const p of Object.values(this._eventParents ?? {})) {
p.fire(e.type, {
layer: e.target,
propagatedFrom: e.target,
...e
}, true);

View File

@ -29,8 +29,6 @@ be the same as the `target`.
@property propagatedFrom: Object
For propagated events, the last object that propagated the event to its
event parent.
@property layer: Object
**Deprecated.** The same as `propagatedFrom`.
@miniclass KeyboardEvent (Event objects)

View File

@ -219,22 +219,10 @@ export function stop(e) {
}
// @function getPropagationPath(ev: DOMEvent): Array
// Compatibility polyfill for [`Event.composedPath()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath).
// Returns an array containing the `HTMLElement`s that the given DOM event
// should propagate to (if not stopped).
export function getPropagationPath(ev) {
if (ev.composedPath) {
return ev.composedPath();
}
const path = [];
let el = ev.target;
while (el) {
path.push(el);
el = el.parentNode;
}
return path;
return ev.composedPath();
}
@ -278,9 +266,6 @@ export function getWheelDelta(e) {
(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines
(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages
(e.deltaX || e.deltaZ) ? 0 : // Skip horizontal/depth wheel events
e.wheelDelta ? (e.wheelDeltaY || e.wheelDelta) / 2 : // Legacy IE pixels
(e.detail && Math.abs(e.detail) < 32765) ? -e.detail * 20 : // Legacy Moz lines
e.detail ? e.detail / -32765 * 60 : // Legacy Moz pages
0;
}

View File

@ -154,11 +154,6 @@ export const Draggable = Evented.extend({
document.body.classList.add('leaflet-dragging');
this._lastTarget = e.target ?? e.srcElement;
// IE and Edge do not give the <use> element, so fetch it
// if necessary
if (window.SVGElementInstance && this._lastTarget instanceof window.SVGElementInstance) {
this._lastTarget = this._lastTarget.correspondingUseElement;
}
this._lastTarget.classList.add('leaflet-drag-target');
}

View File

@ -8,9 +8,8 @@ import {toTransformation} from '../../geometry/Transformation.js';
*
* A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
*
* Leaflet 1.0.x complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic),
* which is a breaking change from 0.7.x behaviour. If you are using a `TileLayer`
* with this CRS, ensure that there are two 256x256 pixel tiles covering the
* Leaflet complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic).
* If you are using a `TileLayer` with this CRS, ensure that there are two 256x256 pixel tiles covering the
* whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90),
* or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set.
*/

View File

@ -500,7 +500,7 @@ Layer.include({
// prevent map click
DomEvent.stop(e);
const target = e.layer ?? e.target;
const target = e.propagatedFrom ?? e.target;
if (this._popup._source === target && !(target instanceof Path)) {
// treat it like a marker and figure out
// if we should toggle it open/closed

View File

@ -444,7 +444,7 @@ Layer.include({
return;
}
this._tooltip._source = e.layer ?? e.target;
this._tooltip._source = e.propagatedFrom ?? e.target;
this.openTooltip(this._tooltip.options.sticky ? e.latlng : undefined);
},

View File

@ -31,7 +31,8 @@ export const IconDefault = Icon.extend({
},
_getIconUrl(name) {
if (typeof IconDefault.imagePath !== 'string') { // Deprecated, backwards-compatibility only
// only detect once
if (!IconDefault.imagePath) {
IconDefault.imagePath = this._detectIconPath();
}

View File

@ -24,11 +24,7 @@ import {Earth} from '../../geo/crs/CRS.Earth.js';
export const Circle = CircleMarker.extend({
initialize(latlng, options, legacyOptions) {
if (typeof options === 'number') {
// Backwards compatibility with 0.7.x factory (latlng, radius, options?)
options = {...legacyOptions, radius: options};
}
initialize(latlng, options) {
Util.setOptions(this, options);
this._latlng = toLatLng(latlng);
@ -104,10 +100,6 @@ export const Circle = CircleMarker.extend({
// @factory L.circle(latlng: LatLng, options?: Circle options)
// Instantiates a circle object given a geographical point, and an options object
// which contains the circle radius.
// @alternative
// @factory L.circle(latlng: LatLng, radius: Number, options?: Circle options)
// Obsolete way of instantiating a circle, for compatibility with 0.7.x code.
// Do not use in new applications or plugins.
export function circle(latlng, options, legacyOptions) {
return new Circle(latlng, options, legacyOptions);
}