Skip to content

Commit cb04e36

Browse files
author
swapnil
committed
adding null checks for e.target and e.target.parentNode
1 parent ab2b923 commit cb04e36

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/AlignmentGuides.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class AlignmentGuides extends Component {
125125
selectBox(e) {
126126
const boundingBox = this.getBoundingBoxElement();
127127
const boundingBoxPosition = boundingBox.current.getBoundingClientRect().toJSON();
128-
if (e.target.id.indexOf('box') >= 0) {
128+
if (e.target && e.target.id.indexOf('box') >= 0) {
129129
const boxDimensions = e.target.getBoundingClientRect().toJSON();
130130
let data = {
131131
x: boxDimensions.x - boundingBoxPosition.x,
@@ -177,7 +177,7 @@ class AlignmentGuides extends Component {
177177
});
178178
}
179179
this.props.onSelect && this.props.onSelect(e, data);
180-
} else if (e.target.parentNode.id.indexOf('box') >= 0) {
180+
} else if (e.target && e.target.parentNode && e.target.parentNode.id.indexOf('box') >= 0) {
181181
const boxDimensions = e.target.parentNode.getBoundingClientRect().toJSON();
182182
let data = {
183183
x: boxDimensions.x - boundingBoxPosition.x,
@@ -233,7 +233,7 @@ class AlignmentGuides extends Component {
233233
}
234234

235235
unSelectBox(e) {
236-
if (e.target && e.target.id.indexOf('box') === -1 && e.target.parentNode.id.indexOf('box') === -1) {
236+
if (e.target && e.target.id.indexOf('box') === -1 && e.target.parentNode && e.target.parentNode.id.indexOf('box') === -1) {
237237
if (typeof this.props.isValidUnselect === 'function' && this.props.isValidUnselect(e) === false) {
238238
return;
239239
}

0 commit comments

Comments
 (0)