* Break the reference to the options of the Class prototype
* Refactor test and .setOptions
* Revert: Merge https://github.com/Leaflet/Leaflet into class_options
* Fixes bug: if tooltip is sticky and permanent it was not following the mouse
* Add tests
* Use fastframe
* fix whitespace
Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
* Add check if map container has the leaflet_id
* Fix lint
* Use private _container
* Add test for _handleGeolocationError
* Update test text
* Change text of test
* Fix overlapping permanent tooltip on bindTooltip
Fix overlapping permanent tooltip on bindTooltip
* Update test
* Fix lint errors
* Using sinon.spy on a function of layer
* unwrap spy in the test
* move spy restore
undefined/null/false are not considered as special case anymore,
`layer` argument is always required, as per docs.
Previous excessive tolerance may lead to real errors get masked.
* Evented:_off: get rid of redundant condition
* Evented:_off: minor optimization of case when remove happens in fire
* Evented:_off: prevent removing all listeners when false fn argument specified (by mistake)
* Evented:_on,_off: ignore non-function listeners passed
* Evented:_on,_off: throw on wrong types passed
* Evented: console.warn on common errors
* Class.extend: do not modify source props.options
`extend` method had side effects:
- (if parent prototype has options) props.options got rewritten
- (if parent does not have options) props.options object was used directly
that behavior was undesirable, as it prevented to reuse props.
E.g. this case had unexpected behavior:
var props = {
// ...
// some useful props and methods
}
var MyLine = L.Polyline.extend(props);
var MyGon = L.Polygon.extend(props);
var line = new MyLine([]);
var gon = new MyGon([]);
console.log(line.options.fill, gon.options.fill);
// Output expected: false, true
// Output before fix: false, false
* Class.extend: do not modify source props object
Previously 'statics' and 'includes' were removed,
that prevented source props reusing
* GeoJSON.latLngToCoords: do not force default precision value
Rely on default value defined in `formatNum` itself.
Specify all related docs.
Document `precision` argument of `latLngsToCoords` function.
* Util.formatNum: allow to skip processing specifying `false` as precision
This is most necessary for cases where `formatNum` is called indirectly,
e.g. by GeoJSON functions.
* Reimplement DoubleTap simulation in more simple and reliable way
Base handler on 'click' event instead of 'touch*' / 'pointer*'.
Ensure that simulated 'dblclicks' are fired only when needed.
ATM it's safe to use in any known browser, with or without touch support,
and it is equally efficient with or without pointer events.
Additionally: reduce `delay` value to 200, as it is closer to actually observed.
* Don't try to guess whether DoubleTap handler is needed or not
..as it is safe to use in either case.
This change is required to support following cases:
- Desktop Chrome + touch emulation (via dev tools)
- Android Firefox 70+ with mouse
* Add tests for DomEvent.DoubleTap.js
* Minor refactoring of DomEvent.DoubleTap.js
Reduce polluting of obj with private properties of Leaflet
* DomEvent.DoubleTapSpec.js: test if disableClickPropagation respected
* Reimplement disableClickPropagation in more simple and reliable way
Original approach was even simpler 5a7420dd1a43474cccaa8cdefa4f324452d18f36
But was reworked in 5c1a34979ecb34e596abeffc4342d7926f6434fa to be compatible with IE<9
Todo: return to original after we drop support for legacy IE
* Get rid of skipped() in stopPropagation
It was originated from here: caece94467ac56dd78ea3afa7600093914735464
The only purpose of skipped there - neutralize flaws of former limited implementation of
disableClickPropagation, so it is not needed anymore.
* Reimplement preventing of double-processing of Canvas events in more simple and reliable way.
(fakeStop was used there for sole purpose here - do not pass events to map)
Remove unused functions fakeStop / skipped.
* Revert "DomEventSpec.js: test to ensure stopPropagation does not break disableClickPropagation logic"
This reverts commit 63a280993d0aca1a3196bd9d80986d0f2385e9ee.
Remove test case which is not useful after disableClickPropagation reimplemented
* Remove excessive check
After previous refactoring corresponding events are stopped naturally
* DomEvent.disableClickPropagation: prevent contextmenu as well
* tests: IE<11 does not understand const/let
* tests: specify all required initEvent arguments for (IE)
Otherwise we get: TypeError: Argument not optional
* tests: add profiles to emulate legacy IE versions in IE11
I can confirm that only IE10 profile is working.
Sample commandline:
npm run test-nolint -- --browsers IE,IE10
* tests: consider that style.zIndex is Number type in IE
* tests: set container height explicitly to fix 6 tests failing in IE
in IE when container.style.height is not set, container.clientWidth is always 0, despite container.style.width value.
* tests: fix #preventDefault in IE
Event properties is not preserved across different listeners calls in IE,
so we have to make all checks in the same listener.
Also: control case added.
Note: previously here used to be different implementation that was also reliable,
as it relied on return value of https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
```
function dispatchClick(el) { // return: cancelled
if (document.createEvent) {
var e = document.createEvent('MouseEvents');
e.initMouseEvent('click', true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
return el.dispatchEvent(e);
} else if (el.fireEvent) { // IE<11
return el.fireEvent('onclick');
}
}
it('prevents the default action of event', function () {
expect(dispatchClick(el)).to.be.ok(); // control case
L.DomEvent.on(el, 'click', L.DomEvent.preventDefault);
expect(dispatchClick(el)).to.not.be.ok();
});
```
* tests: skip crossOrigin-related tests in IE<11
https://caniuse.com/mdn-html_elements_img_crossorigin
* Map: fix contextmenu default-preventing when there are >1 target candidates
_fireDOMEvent gets 2 separate targets lists
- from _findEventTargets - has only targets with listeners
- from canvas (passed in argument) - may contain targets without listeners too
Previous code was incorrect as it checked random (first) target, and if happened not to have listeners -
the issue was triggered: preventDefault was not called (despite existing listeners on other targets in list).
* MapSpec.js: fix contextmenu-preventing test in IE
* Control.Layers: clean up (continue e287b5ec1531238aaf4c4e5f5bfee51b5a577954)
* Control.Layers: stop relying on Browser `android` and `touch` properties
- `android` is useless here, as there are a lot of non-android touch devices (including desktop ones)
- `touch` is useless, as mouse can be used on touch-screen too
Now these usecases are covered:
- `mouseenter/leave` are handled on touch devices too
- If Layers control created with {collapsed:false}, and than it collapsed explicitly
[using .collapse() method], it's now possible to expand it back with click.
* Control.LayersSpec.js: add test for toggle focus
* Control.Layers: fix unexpected layer switch when expanding control on touch
Most browsers produce compatibility mouseenter for touch event, but not all,
so we listen for click also.
The problem is that these compatibility events come all in single batch, so
same touch induces expand and then immediate input switching.
To avoid this we temporarily prevent click on layers section.
Note: more straight-forward way would be relying on e.sourceCapabilities.firesTouchEvents,
but atm it has rather low support: https://caniuse.com/#feat=mdn-api_inputdevicecapabilities_firestouchevents
* Fix issue #6662 and #6664
* Add unit test for Path weight set error
* Simplify Polyline weight set test case
* Alternative fix for setting weight after empty Polyline is added to the map
* Add unit test for setting weight after empty Polygon is added to the map
* Return when empty Polyline is being rendered
* More general formulation for test
* Minor refactoring to make tests more uniform
Co-authored-by: fodor0205 <fodor0205@gmail.com>
Co-authored-by: johndoe <johnd0e@mail.ua>
* Update panInside
Rewrite of panInside to correct issue #7445. Now correctly deals with cases where the padding exceeds half of the display bounds.
* Update panInside tests
Add a test for panInside specifically for issue #7445.
* Clarify last panInside test
Added comments and temp var to clarify the test intention.
* Improve readability of panInside test
Integrated suggested changes from @johnd0e
* tests: prevent warnings from webserver
Like this:
03 02 2021 08:16:25.848:WARN [web-server]: 404: /000
(also seen as unexpected newlines in progress log)
* MapSpec.js: make quotation marks consistent
* MapSpec.js: minor simplification
* MapSpec.js: fix tests containing expectations in callbacks
Also the tests wasn't completely valid, cause it's too late to attach 'zoomend' listener
after pinch already finished.
That was not failing only because of bug in prosthetic-hand.
* DomEventSpec.js: use on/off instead of add/removeListener aliases
* DomEventSpec.js: use happen.click instead of custom function (for uniformity)
* DomEventSpec.js: minor refactoring
Make use of more `sinon` features (for uniformity with other tests)
* DomEventSpec.js: tests for disableScrollPropagation and disableClickPropagation
DomEvent.js: fix typo
* DomEventSpec.js: test to ensure stopPropagation does not break disableClickPropagation logic
Test case for #1963