title: Why am I getting "Uncaught TypeError: Cannot read property 'nodeName' of null" in my script?
body: <p>I am using the imageUploaded.js library and I am getting an error in the chrome dev.
  I have pasted a larger snippet of the code below, but the line that is highlighted in chrome for the error is:</p>
  
  <pre><code>if ( elem.nodeName === 'img' ) {
  </code></pre>
  
  <p>I understand basic js, but can't follow exactly what's happening in this library, so I'm not sure what this error means or how to fix it.</p>
  
  <pre><code>  ImagesLoaded.prototype = new EventEmitter();
  
    ImagesLoaded.prototype.options = {};
  
    ImagesLoaded.prototype.getImages = function() {
      this.images = [];
  
      // filter &amp; find items if we have an item selector
      for ( var i=0, len = this.elements.length; i &lt; len; i++ ) {
        var elem = this.elements[i];
        // filter siblings
        if ( elem.nodeName === 'img' ) {
          this.addImage( elem );
        }
        // find children
        // no non-element nodes, #143
        var nodeType = elem.nodeType;
        if ( !nodeType || !( nodeType === 1 || nodeType === 9 || nodeType === 11 ) ) {
          continue;
        }
        var childElems = elem.querySelectorAll('img');
        // concat childElems to filterFound array
        for ( var j=0, jLen = childElems.length; j &lt; jLen; j++ ) {
          var img = childElems[j];
          this.addImage( img );
        }
      }
    };
  </code></pre>