Skip to content

Commit a16bc6a

Browse files
authored
fix(deps): update d3-zoom, d3-selection to fix vuln (#415)
1 parent a0f0e1e commit a16bc6a

File tree

4 files changed

+134
-101
lines changed

4 files changed

+134
-101
lines changed

jest.config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ module.exports = {
66
'^.+\\.jsx?$': 'babel-jest',
77
'\\.(ts|tsx)$': 'ts-jest',
88
},
9+
// Ensure we transform `d3-*` package sources to CommonJS too.
10+
transformIgnorePatterns: ['node_modules/(?!(d3-.+))'],
11+
moduleNameMapper: {
12+
'.*\\.(css|less|styl|scss|sass)$': '<rootDir>/jest/mocks/cssModule.js',
13+
},
914
setupFilesAfterEnv: ['<rootDir>/jest/setup.ts'],
1015
collectCoverageFrom: [
1116
'src/**/*.{js,jsx,ts,tsx}',
@@ -20,7 +25,4 @@ module.exports = {
2025
lines: 90,
2126
},
2227
},
23-
moduleNameMapper: {
24-
'.*\\.(css|less|styl|scss|sass)$': '<rootDir>/jest/mocks/cssModule.js',
25-
},
2628
};

package-lock.json

Lines changed: 121 additions & 91 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@
6666
"@types/d3-hierarchy": "^1.1.8",
6767
"clone": "^2.1.1",
6868
"d3-hierarchy": "^1.1.9",
69-
"d3-selection": "^1.4.2",
69+
"d3-selection": "^3.0.0",
7070
"d3-shape": "^1.3.7",
71-
"d3-zoom": "^1.8.3",
71+
"d3-zoom": "^3.0.0",
7272
"dequal": "^2.0.2",
7373
"uuid": "^8.3.1"
7474
},

src/Tree/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { SyntheticEvent } from 'react';
1+
import React from 'react';
22
import { tree as d3tree, hierarchy, HierarchyPointNode } from 'd3-hierarchy';
3-
import { select, event } from 'd3-selection';
3+
import { select } from 'd3-selection';
44
import { zoom as d3zoom, zoomIdentity } from 'd3-zoom';
55
import { dequal as deepEqual } from 'dequal/lite';
66
import clone from 'clone';
@@ -152,16 +152,17 @@ class Tree extends React.Component<TreeProps, TreeState> {
152152
d3zoom()
153153
.scaleExtent(zoomable ? [scaleExtent.min, scaleExtent.max] : [zoom, zoom])
154154
// TODO: break this out into a separate zoom handler fn, rather than inlining it.
155-
.filter(() => {
156-
if (hasInteractiveNodes)
155+
.filter((event: any) => {
156+
if (hasInteractiveNodes) {
157157
return (
158158
event.target.classList.contains(this.svgInstanceRef) ||
159159
event.target.classList.contains(this.gInstanceRef) ||
160160
event.shiftKey
161161
);
162+
}
162163
return true;
163164
})
164-
.on('zoom', () => {
165+
.on('zoom', (event: any) => {
165166
g.attr('transform', event.transform);
166167
if (typeof onUpdate === 'function') {
167168
// This callback is magically called not only on "zoom", but on "drag", as well,

0 commit comments

Comments
 (0)