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

[Feature] vm.isContext #18315

Closed
Industrial opened this issue Sep 17, 2022 · 9 comments · Fixed by #23202
Closed

[Feature] vm.isContext #18315

Industrial opened this issue Sep 17, 2022 · 9 comments · Fixed by #23202
Assignees
Labels
bug Something isn't working node API polyfill Related to various "node:*" modules APIs node compat

Comments

@Industrial
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I can't get jsdom to work.

error: Error: Not implemented: isContext
  throw new Error(message);
        ^
    at notImplemented (https://deno.land/std@0.154.0/node/_utils.ts:23:9)
    at Object.isContext (https://deno.land/std@0.154.0/node/vm.ts:62:3)
    at new Window (file:///home/tom/.cache/deno/npm/registry.npmjs.org/jsdom/20.0.0/lib/jsdom/browser/Window.js:252:10)
    at exports.createWindow (file:///home/tom/.cache/deno/npm/registry.npmjs.org/jsdom/20.0.0/lib/jsdom/browser/Window.js:97:10)
    at new JSDOM (file:///home/tom/.cache/deno/npm/registry.npmjs.org/jsdom/20.0.0/lib/api.js:36:20)
    at file:///home/tom/Code/code9/deno/test-fresh/components/Container.test.tsx:10:36

Describe the solution you'd like
Implement vm.isContext (and probably vm.createContext)

Describe alternatives you've considered
https://deno.land/manual@v1.25.3/jsx_dom/linkedom
https://deno.land/manual@v1.25.3/jsx_dom/deno_dom

@lino-levan
Copy link
Contributor

The following is a quote from https://deno.land/manual@v1.26.1/node

Node has some built-in modules (e.g. like vm) that are effectively incompatible with the scope of Deno and therefore there aren't easy ways to provide a polyfill of the functionality in Deno.

It sounds to me like the Deno team do not plan to ever support vm which is quite sad.

@bartlomieju
Copy link
Member

vm might be implemented once we get support for ShadowRealm

@lino-levan
Copy link
Contributor

Could you provide some context on ShadowRealm? Is there an issue / PR about this?

@lino-levan
Copy link
Contributor

Oh never mind, I found #13239, which is an issue tracking support. Linking this here for future reference.

@andreubotella
Copy link
Contributor

Could you provide some context on ShadowRealm? Is there an issue / PR about this?

It's a JS API proposal that's currently being worked on: https://github.com/tc39/proposal-shadowrealm

Unlike most new JS APIs that Deno implements automatically because they ship in V8, this one requires some work to support in the internals of Deno. You can follow the work at #13239 (although the work recently had to be rolled back in #16366 because it was blocking certain refactors; it should hopefully be relanded in a couple weeks).

However, vm needs some more support in deno_core (and maybe deno_runtime) than ShadowRealm needs, because you cannot cross objects across the realm boundary with ShadowRealm but you can with vm. This would need a lot of checking that everything is handled correctly, and that certain realm interactions happen properly, that wouldn't be needed with ShadowRealm.

@gregmagdits
Copy link

There is a page in the Deno documentation that states that JSDOM works with Deno, however running the example code on the site generates the same error reported by the OP. The documentation should be updated until this issue is addressed.

@zuisong
Copy link
Contributor

zuisong commented Nov 28, 2022

https://github.com/zuisong/happy-dom-deno

import { Window } from 'npm:happy-dom-deno';

const window = new Window();
const document = window.document;

document.body.innerHTML = '<div class="container"></div>';

const container = document.querySelector('.container');
const button = document.createElement('button');

container.appendChild(button);

// Outputs "<div class="container"><button></button></div>"
console.log(document.body.innerHTML);

@john-griffin
Copy link

Here are my current findings on JSDOM https://github.com/john-griffin/deno-dom-test

@guy-borderless
Copy link

for running with @mozilla/readability I could only get it working with deno-dom-wasm.

import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts"
import { Readability } from "npm:@mozilla/readability"

 const document = new DOMParser().parseFromString(
    htmlString,
    "text/html",
  )!
  const reader = new Readability(document)

Would love to have happy-dom and jsdom support for readability.js support.

@bartlomieju bartlomieju added the node API polyfill Related to various "node:*" modules APIs label Mar 4, 2024
@bartlomieju bartlomieju self-assigned this Mar 12, 2024
@bartlomieju bartlomieju assigned littledivy and unassigned bartlomieju Apr 2, 2024
satyarohith pushed a commit that referenced this issue Apr 11, 2024
Implement contextified objects in `node:vm`

Fixes #23186
Fixes #22395
Fixes #20607
Fixes #18299
Fixes #19395
Fixes #18315
Fixes #18319
Fixes #23183
littledivy added a commit to littledivy/deno that referenced this issue Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node API polyfill Related to various "node:*" modules APIs node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants