JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q14737F
  • License MIT

a minimal DOM patcher for HTML-over-the-wire

Package Exports

  • nanowire
  • nanowire/dist/index.js
  • nanowire/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nanowire) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Nanowire

Nanowire is a minimal a minimal DOM patcher for HTML-over-the-wire.

How to use

  1. Enclose the element to be updated in a <nw-frame> tag with a unique ID.
  2. Give the following arguments to the apply function,
    1. The DOM node or document that is the ancestor of the "nw-frame" to be updated,
    2. Text containing "nw-frame" tags surrounding the updated content.

The following HTML is displayed first,

<nw-frame id="frame">
Hello?
</nw-frame>

and then the following code is executed,

import { apply } from 'nanowire';
apply(document, '<nw-frame id="frame">Hello, World!</nw-frame>');

the result is as follows.

<nw-frame id="frame">
Hello, World!
</nw-frame>

You can apply server-side rendered HTML as updates.

fetch('your API').then(res => res.text()).then(text => apply(document, text));

Example

See the example.

# in this repository.
$ cd example
$ yarn serve

LICENSE

MIT License(see LICENSE file).