psergus / ngWYSIWYG

true angular WYSIWYG
MIT License
63 stars 42 forks source link

Cannot read property 'tagName' of undefined #58

Open UrVerySpecial opened 8 years ago

UrVerySpecial commented 8 years ago

Hi, first of all, I really appreciate for this module.

I found bug(maybe..).

  1. insert image
  2. click image
  3. then, resizer is displayed
  4. remove image by 'back space'
  5. the resizer still remains
  6. then 'TypeError: Cannot read property 'tagName' of undefined' error occurred

I founding solution, but if you already have, fix it please.

regards, kang

UrVerySpecial commented 8 years ago

ngpImageResizer.js

    function removeResizer(event) {
        if (!resizerContainer.parentNode) {
            return;
        }
        if (event && event.target && event.target.tagName === 'IMG') {
            return;
        }
        resizerContainer.style.display = 'none';
        lastVerticalCursorPosition = null;
    }

this code

if (event && event.target.tagName === 'IMG') 
{
    return;
}

to

if (event && event.target && event.target.tagName === 'IMG') {
    return;
}

will be fix, but it's not perfect solution. I think resizer have to hide when image is deleted.