Skip to content

Commit

Permalink
Merge pull request #12 from swapnilsg/master
Browse files Browse the repository at this point in the history
adding null checks for e.target and e.target.parentNode
  • Loading branch information
Ilango Rajagopal authored Mar 17, 2020
2 parents ab2b923 + cb04e36 commit c587291
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/AlignmentGuides.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class AlignmentGuides extends Component {
selectBox(e) {
const boundingBox = this.getBoundingBoxElement();
const boundingBoxPosition = boundingBox.current.getBoundingClientRect().toJSON();
if (e.target.id.indexOf('box') >= 0) {
if (e.target && e.target.id.indexOf('box') >= 0) {
const boxDimensions = e.target.getBoundingClientRect().toJSON();
let data = {
x: boxDimensions.x - boundingBoxPosition.x,
Expand Down Expand Up @@ -177,7 +177,7 @@ class AlignmentGuides extends Component {
});
}
this.props.onSelect && this.props.onSelect(e, data);
} else if (e.target.parentNode.id.indexOf('box') >= 0) {
} else if (e.target && e.target.parentNode && e.target.parentNode.id.indexOf('box') >= 0) {
const boxDimensions = e.target.parentNode.getBoundingClientRect().toJSON();
let data = {
x: boxDimensions.x - boundingBoxPosition.x,
Expand Down Expand Up @@ -233,7 +233,7 @@ class AlignmentGuides extends Component {
}

unSelectBox(e) {
if (e.target && e.target.id.indexOf('box') === -1 && e.target.parentNode.id.indexOf('box') === -1) {
if (e.target && e.target.id.indexOf('box') === -1 && e.target.parentNode && e.target.parentNode.id.indexOf('box') === -1) {
if (typeof this.props.isValidUnselect === 'function' && this.props.isValidUnselect(e) === false) {
return;
}
Expand Down

0 comments on commit c587291

Please sign in to comment.