jsdomify icon indicating copy to clipboard operation
jsdomify copied to clipboard

"element instanceof HTMLElement" throws "HTMLElement is not defined"

Open leifoolsen opened this issue 8 years ago • 2 comments

Hello, I just upgraded jsdomify from version 2.1.0 to 3.0.0 and code working in 2.1.0 now fails. Maybe there is something from JsDom that is not propery loaded in 3.0.0?

Testcase:

import jsdomify from 'jsdomify';
const describe = require('mocha').describe;
const it = require('mocha').it;
const expect = require('chai').expect;

describe('jsdomify-3-failing-test', () => {

  const fixture = `
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Fixture</title>
</head>
<body>
  <div id="mount">
  </div>
</body>
</html>`;

  const acceptOnlyHTMLElelemnt = element => {
    if(element) {
      if (!(element instanceof HTMLElement)) {
        throw new TypeError('element parameter must be an HTMLElement');
      }
    }
  };

  before ( () => {
    jsdomify.create(fixture);
  });

  after ( () => {
    jsdomify.destroy();
  });

  it('should accept HTMLElement', function () {
    const element = document.querySelector('#mount');

    expect(() => {
      acceptOnlyHTMLElelemnt(element);
    }).to.not.throw(Error);

    expect(() => {
      acceptOnlyHTMLElelemnt('bar');
    }).to.throw(TypeError);
  });
});

leifoolsen avatar Aug 27 '16 18:08 leifoolsen

Hey @leifoolsen , I've noticed JSDOM pushed a few changes and fixes to HTMLCollections, so I've updated our dependency as well.

Can you pull down [email protected] and see if you still have this issue?

dmatteo avatar Sep 06 '16 21:09 dmatteo

Still the same error: "ReferenceError: HTMLElement is not defined" jsdom-9.5.0, jsdomify-3.1.0

leifoolsen avatar Sep 07 '16 20:09 leifoolsen