From 8df6be67fd37c8523981c106a596797a63a7edb4 Mon Sep 17 00:00:00 2001 From: Richard Hull Date: Thu, 30 Nov 2017 10:14:27 -0500 Subject: [PATCH] [fix] Use 'deep-equal' to compare whether arrays are equal Using `JSON.stringify()`, when a marker has a popup created with `L.popup()`, rather than a straight string, then the following error is thrown: Uncaught TypeError: Converting circular structure to JSON at JSON.stringify () at isArraysEqual See https://github.com/YUzhva/react-leaflet-markercluster/issues/55 --- dist/react-leaflet-markercluster.js | 8 ++++++-- dist/react-leaflet-markercluster.min.js | 2 +- package-lock.json | 5 ++--- package.json | 3 +++ src/react-leaflet-markercluster.js | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dist/react-leaflet-markercluster.js b/dist/react-leaflet-markercluster.js index 4553eca..3231c88 100644 --- a/dist/react-leaflet-markercluster.js +++ b/dist/react-leaflet-markercluster.js @@ -20,6 +20,10 @@ var _leaflet = require('leaflet'); var _leaflet2 = _interopRequireDefault(_leaflet); +var _deepEqual = require('deep-equal'); + +var _deepEqual2 = _interopRequireDefault(_deepEqual); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -42,7 +46,7 @@ function havingDeprecatedProps(markers) { // NOTE: Helpers function isArraysEqual(firstArray, secondArray) { - return JSON.stringify(firstArray) === JSON.stringify(secondArray); + return firstArray.length === secondArray.length && (0, _deepEqual2.default)(firstArray, secondArray); } function removeMarkersWithSameCoordinates(markers) { @@ -252,4 +256,4 @@ MarkerClusterGroup.propTypes = { MarkerClusterGroup.defaultProps = { markers: [] -}; +}; \ No newline at end of file diff --git a/dist/react-leaflet-markercluster.min.js b/dist/react-leaflet-markercluster.min.js index 562466a..5e1a1a5 100644 --- a/dist/react-leaflet-markercluster.min.js +++ b/dist/react-leaflet-markercluster.min.js @@ -1 +1 @@ -"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}function _inherits(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)}function havingDeprecatedProps(e){return-1!==e.findIndex(function(e){return e.lat||e.lng})}function isArraysEqual(e,r){return JSON.stringify(e)===JSON.stringify(r)}function removeMarkersWithSameCoordinates(e){var r=[e[0]];return e.forEach(function(e){JSON.stringify(r).includes(JSON.stringify(e))||r.push(e)}),r}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,r){for(var t=0;t