Skip to content

Commit

Permalink
fix(deps): update d3-zoom, d3-selection to fix vuln (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrem authored Nov 29, 2022
1 parent a0f0e1e commit a16bc6a
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 101 deletions.
8 changes: 5 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ module.exports = {
'^.+\\.jsx?$': 'babel-jest',
'\\.(ts|tsx)$': 'ts-jest',
},
// Ensure we transform `d3-*` package sources to CommonJS too.
transformIgnorePatterns: ['node_modules/(?!(d3-.+))'],
moduleNameMapper: {
'.*\\.(css|less|styl|scss|sass)$': '<rootDir>/jest/mocks/cssModule.js',
},
setupFilesAfterEnv: ['<rootDir>/jest/setup.ts'],
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
Expand All @@ -20,7 +25,4 @@ module.exports = {
lines: 90,
},
},
moduleNameMapper: {
'.*\\.(css|less|styl|scss|sass)$': '<rootDir>/jest/mocks/cssModule.js',
},
};
212 changes: 121 additions & 91 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"@types/d3-hierarchy": "^1.1.8",
"clone": "^2.1.1",
"d3-hierarchy": "^1.1.9",
"d3-selection": "^1.4.2",
"d3-selection": "^3.0.0",
"d3-shape": "^1.3.7",
"d3-zoom": "^1.8.3",
"d3-zoom": "^3.0.0",
"dequal": "^2.0.2",
"uuid": "^8.3.1"
},
Expand Down
11 changes: 6 additions & 5 deletions src/Tree/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { SyntheticEvent } from 'react';
import React from 'react';
import { tree as d3tree, hierarchy, HierarchyPointNode } from 'd3-hierarchy';
import { select, event } from 'd3-selection';
import { select } from 'd3-selection';
import { zoom as d3zoom, zoomIdentity } from 'd3-zoom';
import { dequal as deepEqual } from 'dequal/lite';
import clone from 'clone';
Expand Down Expand Up @@ -152,16 +152,17 @@ class Tree extends React.Component<TreeProps, TreeState> {
d3zoom()
.scaleExtent(zoomable ? [scaleExtent.min, scaleExtent.max] : [zoom, zoom])
// TODO: break this out into a separate zoom handler fn, rather than inlining it.
.filter(() => {
if (hasInteractiveNodes)
.filter((event: any) => {
if (hasInteractiveNodes) {
return (
event.target.classList.contains(this.svgInstanceRef) ||
event.target.classList.contains(this.gInstanceRef) ||
event.shiftKey
);
}
return true;
})
.on('zoom', () => {
.on('zoom', (event: any) => {
g.attr('transform', event.transform);
if (typeof onUpdate === 'function') {
// This callback is magically called not only on "zoom", but on "drag", as well,
Expand Down

0 comments on commit a16bc6a

Please sign in to comment.