9.0.0 • Published 6 years ago

server-html v9.0.0

Weekly downloads
4
License
ISC
Repository
-
Last release
6 years ago

Server HTML

This module lets you parse HTML and HTML files to use a DOM-like interface to prepare HTML on your server in a browser-like fashion.

A very small subset of the DOM is supported along with some additional convenience methods, if you would like to contribute more update this list, tests and documentation and submit a pull request.

The module has a single dependency without additional dependencies.

How to use

const Page = require('page-html) const rawHTML = fs.readFileSync('./my-page.html') const document = Page.parse(rawHTML)

Methods bound to the root element

document.getElementById('a-child-id') document.getElementsByTagName('a') document.getFirstElementByTagName('a') document.appendChild(child) document.createElement('a') document.removeChild(child) document.removeElementsById('child1', 'child2', 'child3') document.setAttribute('disabled', true) document.setInnerText('this is the text') document.classList.contains('css-class) document.classList.add('css-class) document.classList.remove('css-class) document.classList.item(index) document.classList.toggle('css-class)s)

Methods bound to elements

const el = document.getElementById('an-id) el.getElementById('a-child-id') el.getElementsByTagName('a') el.getFirstElementByTagName('a') el.appendChild(child) el.removeChild(child) el.removeElementsById('child1', 'child2', 'child3') el.setAttribute('disabled', true) el.setInnerText('this is the text') el.classList.contains('css-class) el.classList.add('css-class) el.classList.remove('css-class) el.classList.item(index) el.classList.toggle('css-class)s)

Contribute some of the DOM

  • your contribution will be public domain
  • your code must be formatted with StandardJS
9.0.0

6 years ago

8.0.0

6 years ago

7.0.0

6 years ago

6.0.0

6 years ago

5.0.0

6 years ago

4.0.0

6 years ago

3.0.0

6 years ago

2.0.0

6 years ago

1.0.20

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago