html-element

A simple HTMLElement shim on the server.

MIT 19 个版本
安装
npm install html-element
yarn add html-element
pnpm add html-element
bun add html-element
README

html-element

A simple HTMLElement shim on the server.

This is a partial implementation of HTMLElement, to get client-side templates (such as hyperscript) working in node!

The current implementation is fully compatible with hyperscript.

Upgrading from v1.x

As of v2.0.0 (Aug 2016), html-element no longer affects the global namespace by default. If you currently rely on require('html-element') to create globals such as document and Element, you should instead require('html-element/global-shim') when upgrading to v2.

For non-global usage, you can import objects directly from the main package, e.g.:

var document = require('html-element').document;

or

import { Element } from 'html-element';

Supported methods

  • createElement(nodeName)
  • createTextNode(value)
  • appendChild(node)
  • replaceChild(node)
  • removeChild(node)
  • insertBefore(new, existing)
  • toString()
  • setAttribute(name, value)
  • getAttribute(name)
  • setProperty(name, value)
  • getProperty(name)
  • innerHTML()
  • outerHTML()
  • textContent()
  • addEventListener(eventType, listenerFunc)
  • removeEventListener(eventType, listenerFunc)
  • dispatchEvent(event)

Setters update existing objects, otherwise create anew;

Properties

  • innerHTML
  • outerHTML
  • textContent
  • attribute.value
  • attribute.name
  • everything else

TODO / Missing features

  • Your PR to make this a more accurate implementation

License

MIT

版本列表
2.3.1 2020-02-05
2.3.0 2019-05-22
2.2.0 2016-12-18
2.1.1 2016-08-31
2.1.0 2016-08-27
2.0.0 2016-08-24
1.5.1 2016-06-30
1.5.0 2016-03-07
1.4.0 2015-06-05
1.3.0 2014-01-18
1.2.8 2013-10-17
1.2.7 2013-10-12
1.2.6 2013-09-23
1.2.5 2013-02-28
1.2.4 2013-02-28
1.2.3 2013-02-28
1.2.2 2013-02-28
1.2.0 2013-02-28
1.1.0 2013-02-27