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

Simple Example fails #152

Open
Krutsch opened this issue Jan 18, 2024 · 0 comments
Open

Simple Example fails #152

Krutsch opened this issue Jan 18, 2024 · 0 comments

Comments

@Krutsch
Copy link

Krutsch commented Jan 18, 2024

The Example in readme:

import Critters from 'critters';

const critters = new Critters({
  // optional configuration (see below)
});

const html = `
  <style>
    .red { color: red }
    .blue { color: blue }
  </style>
  <div class="blue">I'm Blue</div>
`;

const inlined = await critters.process(html);

console.log(inlined);
// "<style>.blue{color:blue}</style><div class=\"blue\">I'm Blue</div>"

fails with this message:

file:///C:/Users/.../node_modules/critters/dist/critters.mjs:519
    document.documentElement.setAttribute('data-critters-container', '');
                             ^

TypeError: Cannot read properties of undefined (reading 'setAttribute')
    at createDocument (file:///C:/Users/.../node_modules/critters/dist/critters.mjs:519:30)
    at Critters.process (file:///C:/Users/.../node_modules/critters/dist/critters.mjs:1123:22)
    at file:///C:/Users/.../test.js:15:32
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:120:12)

Device: Windows 11, Node.js version 21.6.0

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

1 participant