title: PhpStorm: Unresolved variable readyState
body: <p>I'm using <a href="https://codepen.io/chriscoyier/pen/tIuBL" rel="nofollow noreferrer">this code</a> in order to add a filter field to all my tables. This filter is added to my navbar using JavaScript.</p>
  
  <pre><code>  // Table filter.
    // Source: https://codepen.io/chriscoyier/pen/tIuBL
    (function(document) {
      'use strict';
  
      var LightTableFilter = (function(Arr) {
  
        var _input;
  
        function _onInputEvent(e) {
          _input = e.target;
          var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
          Arr.forEach.call(tables, function(table) {
            Arr.forEach.call(table.tBodies, function(tbody) {
              Arr.forEach.call(tbody.rows, _filter);
            });
          });
        }
  
        function _filter(row) {
          var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
          row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
        }
  
        return {
          init: function() {
            var inputs = document.getElementsByClassName('light-table-filter');
            Arr.forEach.call(inputs, function(input) {
              input.oninput = _onInputEvent;
            });
          }
        };
      })(Array.prototype);
  
      document.addEventListener('readystatechange', function() {
        if (document.readyState === 'complete') {
          LightTableFilter.init();
        }
      });
  
    })(document);
  </code></pre>
  
  <p>The code itself works perfectly.</p>
  
  <p>However, PhpStorm adds a warning to <code>document.readyState</code> saying that it's an <code>unresolved variable</code>.</p>
  
  <p>Is PhpStorm missing some information? I downloaded and installed it yesterday, so it should be the most recent version.</p>
  
  <hr>
  
  <p>I fixed it by replacing the following code:</p>
  
  <pre><code>document.addEventListener('readystatechange', function() {
    if (document.readyState === 'complete') {
      LightTableFilter.init();
    }
  });
  </code></pre>
  
  <p>With this:</p>
  
  <pre><code>  document.addEventListener("DOMContentLoaded", function (event) {
        LightTableFilter.init();
    })
  </code></pre>