Skip to content

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

@leifoolsen

Description

@leifoolsen

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);
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions