Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"original.cloneNode is not a function" using hyperhtml with basichtml #400

Closed
Golmote opened this issue Jun 27, 2020 · 2 comments
Closed

Comments

@Golmote
Copy link

Golmote commented Jun 27, 2020

Hello,

I'm encountering an error that seems quite similar to the one described in #190, except I'm using basichtml.

Below is the Minimal, Reproducible Example I could come up with. Am I doing something wrong that I can't see?

import {Document} from "basichtml";
import hyper from "hyperhtml";

it('should work', () => {
    global.window = global;
    global.document = new Document();

    const root = document.createElement('div');
    const cls = 'foo';

    // This test passes
    expect(() => {
        hyper(root)`<div class="foo"></div>`;
    }).not.toThrow();

    // This test fails
    // TypeError: original.cloneNode is not a function
    // Tagger.attribute (node_modules/hyperhtml/cjs/objects/Updates.js:176:34)
    expect(() => {
        hyper(root)`<div class=${cls}></div>`;
    }).not.toThrow();
});

(I run that test using Jest. hyperhtml and basichtml are both in their latest versions, 2.32.2 and 2.3.0, respectively.)

@WebReflection
Copy link
Owner

the whole library is tested via basicHTML https://github.com/WebReflection/hyperHTML/blob/master/test/test.js and I've just tried this on top:

const root = document.createElement('div');
const cls = 'foo';
console.log(hyperHTML(root)`<div class="foo"></div>` === root);
console.log(hyperHTML(root)`<div class=${cls}></div>` === root);

it works without issues.

@Golmote
Copy link
Author

Golmote commented Jun 27, 2020

After more digging, TIL that Jest runs the tests in a jsdom environment by default...

So if anyone runs into this issue, the fix seems to be setting Jest's testEnvironment to "node".

Thank you for your time!

@Golmote Golmote closed this as completed Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants