Socket
Book a DemoInstallSign in
Socket

can-zone-jsdom

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-zone-jsdom

__can-zone-jsdom__ is a [Zone plugin](https://github.com/canjs/can-zone) that provides a DOM implementation backed by [jsdom](https://github.com/jsdom/jsdom).

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
2
Created
Source

can-zone-jsdom

can-zone-jsdom is a Zone plugin that provides a DOM implementation backed by jsdom.

Build Status npm version

Install

npm install can-zone-jsdom --save

Usage

The most common way to use can-zone-jsdom is to provide a HTML page as the entry point. This page will be loaded in a new JSDOM context, and its scripts executed. Below shows using the plugin within an Express app.

const Zone = require('can-zone');
const express = require('express');
const app = express();

const dom = require('can-zone-jsdom');
const requests = require('done-ssr/zones/requests');

app.use(express.static('build', { index: false }));
app.use(express.static('.'));

app.get('*', async (request, response) => {
  var zone = new Zone([
    // Overrides XHR, fetch
    requests(request),

    // Sets up a DOM
    dom(request, {
      root: __dirname + '/../build',
      html: 'index.html'
    })
  ]);

  const { html } = await zone.run();
  response.end(html);
});

app.listen(8080);

See this guide for a more full featured example using incremental rendering within a React app.

License

MIT

FAQs

Package last updated on 08 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts