Skip to content

Comments

Zero division fix (on leaflet.0.8-dev branch)#65

Closed
olzraiti wants to merge 3 commits intomakinacorpus:leaflet0.8-devfrom
olzraiti:leaflet.0.8-dev-zero-division-fix
Closed

Zero division fix (on leaflet.0.8-dev branch)#65
olzraiti wants to merge 3 commits intomakinacorpus:leaflet0.8-devfrom
olzraiti:leaflet.0.8-dev-zero-division-fix

Conversation

@olzraiti
Copy link
Contributor

If the map was mounted to a node that's not in the DOM (which is not so rare for example in React environment), an error was thrown because pattern.getComputedTextLength() resulted in 0, which caused a division by zero. I fixed the bug by checking if the map is rendered in the body.

You can reproduce the bug like this:

document.createElement("div").appendChild(mapContainerNode);
map.invalidateSize();

@olzraiti
Copy link
Contributor Author

I updated the code to just fix with 1 instead of 0. Much more fool proof and works on every case.

@olzraiti
Copy link
Contributor Author

Closed by #79

@olzraiti olzraiti closed this Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant