587 Commits

Author SHA1 Message Date
Falke Design
a340c086c2
Break the reference to the options of the Class prototype (#7459)
* Break the reference to the options of the Class prototype

* Refactor test and .setOptions

* Revert: Merge https://github.com/Leaflet/Leaflet into class_options
2021-12-02 20:02:49 +02:00
Falke Design
30d91b1769
Fix Bug: permanent & sticky tooltip (#7563)
* 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>
2021-12-02 20:01:17 +02:00
Falke Design
e7d5a3725f
Locate - locationfound: Add check if map container has leaflet_id / is existing (#7813)
* 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
2021-12-02 19:59:14 +02:00
Falke Design
e8b87eacf5
bindTooltip should unbind existent tooltip (#7633)
* 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
2021-12-02 19:51:38 +02:00
johnd0e
0a61e9065b
Tests: simplify .near and .nearLatlng usage (#7820) 2021-11-27 13:08:04 +02:00
Andrew Cherniavskii
2e8638761c
[GridLayer] redraw tiles properly after changing maxNativeZoom (#6443) 2021-11-26 17:39:17 +02:00
johnd0e
05fa5802a6
New TapHold handler instead of legacy Tap (#7026)
* Replace legacy over-functional Tap handler with much simpler TapHold handler

as currently it is needed only for single purpose: emulate `contextmenu` on iOS.

* `tapHold` map option can be forced now

Anyway, this option is not meant to be explicit,
any overriding is useful for debug purposes only.

* Remove Map.Tap

* Get rid of deprecated initMouseEvent

Use MouseEvent constructor.

Note: some properties are commented out, as they may vary between browsers.

Ref:
- https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
- https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent

Compatibility:
- https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent#browser_compatibility

Some legacy browsers lacks support, but here we care only about iOS Safari.
(Anyway it can be solved with polyfill)

* Add tests for Map.TapHold.js
2021-11-26 13:38:24 +02:00
johnd0e
38c0c55ff0
Fix #7439 for mousemove (#7809)
We need pass event to map when canvas does not have targets
2021-11-26 13:07:16 +02:00
Falke Design
4dadf840af
Fix Popup keepInView if the map needs to panned over a long distance (#7792)
* Fix keepInView recursion #5035

* Fix test

Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
2021-11-25 20:34:19 +02:00
Falke Design
c6c82f07c5
Add keepInView test (#7790) 2021-11-25 19:25:43 +02:00
johnd0e
5eca46962d
add/removePointerListener: tolerate wrong event names (#7808) 2021-11-25 16:47:35 +02:00
johnd0e
dd1ab61bd1
Fixup #7068 and add test (#7781) 2021-11-16 00:48:08 +02:00
Philipp Loose
7cb3c0e43b
Tests for L.GeoJSON static functions (#7147) 2021-11-11 17:19:46 +03:00
johnd0e
315e4d7bde
Class.include: keep parent options (#7756)
And add a couple of related tests
2021-11-08 19:16:42 +02:00
Jon Koops
98fb4ab3a5
Lint all files unless explicitly ignored (#7757)
* Lint all files unless explicitly ignored

* Only ignore some code in the docs
2021-11-08 19:14:11 +02:00
Jon Koops
b4a1556132
Run tests on Internet Explorer 11 (#7741)
Co-authored-by: johndoe <johnd0e@mail.ua>
2021-11-06 13:15:40 +01:00
johnd0e
5b9458e82e
Change undefined argument handling in Layer/hasLayer() and LayerGroup/hasLayer() (#6999)
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.
2021-11-05 14:29:35 +02:00
johnd0e
9e03bc5f59
Restore DomEvent.off(el) functionality when calling with one arg (#7125) 2021-11-05 14:18:25 +02:00
johnd0e
36d4858bf3
Evented: protect from common errors (+tests) (#7518)
* 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
2021-11-05 12:28:00 +02:00
Jon Koops
1703e9354e
Fix indentation issues in Karma config (#7743) 2021-11-04 20:10:12 +02:00
johnd0e
89f99708b0
Fixup #7736 (#7742) 2021-11-04 16:27:34 +02:00
johnd0e
541a0f1ec1
Tests: remove non-functional Firefox setting (#7736)
dom.w3c_pointer_events.enabled does not exist in recent Firefox
Anyway, it is not really useful after 0ae68f4658cb1cd85e6e0c67a24b12e5e6282e22
2021-11-04 14:17:39 +02:00
johnd0e
7b15104f2f
Avoid modifying source props object in Class.extend (#6766)
* 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
2021-11-03 19:39:42 +02:00
johnd0e
cc9f327b41
Allow to prevent round-off errors, caused by formatNum (#7100)
* 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.
2021-11-03 19:07:54 +02:00
johnd0e
f2d625fcad
DomEvent.Pointer: process touch events only (#7059) 2021-11-03 16:43:16 +02:00
johnd0e
cfcff71adb
DomEvent.Pointer: simplify and cover by tests (#7415) 2021-11-03 13:15:44 +02:00
Jon Koops
8cfe1c3dc7
Drop PhantomJS from test suite (#7724) 2021-11-01 19:46:11 +02:00
johnd0e
83d23b90cf
Add test case for #7439 (#7721)
To prevent regressions like e87ed0cea0ac06199dbb9b1c56817d45901792fd
2021-11-01 18:27:50 +02:00
johnd0e
7b9b4a33c0
Reimplement DoubleTap simulation in more simple and reliable way (#7027)
* 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
2021-11-01 17:32:50 +02:00
johnd0e
e87ed0cea0
More reliable disableClickPropagation (#7439)
* 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
2021-11-01 14:02:42 +02:00
Falke Design
7ef9ae95d6
Change Tooltip class from leaflet-clickable to leaflet-interactive (#7719) 2021-11-01 12:57:59 +02:00
johnd0e
61eb5f1dca
DivOverlay/Popup/Tooltip refactoring and fixes (#7540) 2021-11-01 12:56:38 +02:00
johnd0e
f018e2de2c
Fix tests failing in IE (#7461)
* 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
2021-11-01 11:21:17 +02:00
johnd0e
ef928c5268
DomEventSpec.js: add more tests (#7126) 2021-11-01 11:06:15 +02:00
johnd0e
4c590a2b76
Map: fix contextmenu default-preventing when there are >1 target candidates (#7544)
* 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
2021-11-01 10:57:42 +02:00
johnd0e
0ae68f4658
Correct Browser.touch (and more related changes) (#7029)
* Simplify touch detection

1. Detect touch in recommended way
   Ref: https://www.chromestatus.com/feature/4764225348042752
   More: https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/KV6kqDJpYiE/YFM28ZNBBAAJ

2. Drop legacy Firefox touch support
   It is deprecated since Gecko 25.
   https://developer.mozilla.org/en-US/docs/Web/API/DocumentTouch

* Introduce `Browser.touchNative`, separated from `Browser.touch`

Bring `Browser.touch` description to reality.
Add brief note about pointer->touch processing in Leaflet.

* DomEvent: do not use pointer wrapper when native touch events are available
2021-11-01 10:32:06 +02:00
johnd0e
404e1b9474
Control.Layers: stop relying on Browser android and touch properties (#7057)
* 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
2021-11-01 10:28:24 +02:00
johnd0e
12ac953023
Tooltip: make Map.openTooltip to consider interactive option (like Layer.openTooltip) (#7531) 2021-11-01 10:24:39 +02:00
johnd0e
d8b851e11f
Prevent click on popup tip from firing on map. (#7541) 2021-11-01 10:23:06 +02:00
Jon Koops
da32372b9f
Upgrade to latest version of Rollup (#7677)
* Upgrade to latest version of Rollup

* add esModule: false for legacy compat

Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
2021-10-29 21:39:13 +03:00
Niels Holt
2eb73c4757
Fix Path.setStyle bug (replacing #6671) (#6941)
* 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>
2021-10-29 17:36:57 +03:00
Falke Design
1ec39cf539
BoxZoom: Reset _moved flag after cancel with ESC (#7597)
* Reset _moved flag after cancel with ESC

* Call _resetState directly

* Add BoxZoom cancel test
2021-07-01 17:21:27 +03:00
daverayment
73e13ce3cb
Update panInside (#7469)
* 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
2021-03-05 11:20:33 +02:00
johnd0e
1653f97dcf
Fix map spec (#7451)
* 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
2021-02-08 14:34:35 +02:00
johnd0e
fdcb54d71a
Fix typos in GridLayerSpec.js (#7450)
tilelayer -> gridlayer
2021-02-08 14:33:44 +02:00
johnd0e
94a5618ac2
mocha: enforce forbid-only rule in the continuous integration (#7448)
https://mochajs.org/#-forbid-only
2021-02-08 14:33:31 +02:00
johnd0e
9330d75bd6
Map.TouchZoomSpec.js: refactor (#7447)
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.
2021-02-08 14:32:29 +02:00
johnd0e
cb90037284
DomEventSpec.js: add tests (#7438)
* 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
2021-02-08 14:30:21 +02:00
Lubomír Bucek
92ff0a1461
TileLayer feature: add space to character regex for template to allow Object keys with it (#7216) 2020-11-18 15:25:14 +01:00
Tim Gates
38e04e3900
docs: Fix simple typo, somplicity -> simplicity (#7284)
There is a small typo in spec/suites/map/MapSpec.js.

Should read `simplicity` rather than `somplicity`.
2020-09-21 18:42:54 +02:00