0.1.0-7 • Published 3 years ago

domsday v0.1.0-7

Weekly downloads
1
License
MIT
Repository
-
Last release
3 years ago

domsday

Lightweight DOM-like nodes that don't try to be too clever.

import Node from 'domsday'

Node.fromString('<div>qwe</div>')
/* =>
Node { nodeType: DOCUMENT_NODE, children: [
  Node { nodeType: ELEMENT_NODE children: [
    Node { nodeType: TEXT_NODE, text: 'qwe' },
  ]},
], type: DOCUMENT_NODE }
*/

Get node types with:

import { ELEMENT_NODE } from 'domsday/src/node-types'

Features in depth

Preserves original chars

domsday mixed line endings, mixed tabs and spaces, original newlines and whatever other freaky stuff you're into.

For example:

Node.fromString('<!DOCTYPE html>\n\they')
/* => Node { type: DOCUMENT_NODE, children: [
  Node { type: DOCUMENT_TYPE_NODE, contents: ' html' },
  Node { type: TEXT_NODE, text: '\n\they' },
]}
*/

The objective of this is to keep builds as closest to originals as possible.

Doesn't cleanup outdated .children references

A Node instance .children is an array with no protection. When a child Node changes parent, references to it in previous parent are still kept.

For our purposes we usually don't care about this, and we save doing unnecessary things.

0.1.0-12

3 years ago

0.1.0-11

4 years ago

0.1.0-10

4 years ago

0.1.0-9

4 years ago

0.1.0-8

4 years ago

0.1.0-7

4 years ago

0.1.0-6

4 years ago

0.1.0-5

4 years ago

0.1.0-4

4 years ago

0.1.0-3

4 years ago

0.1.0-2

4 years ago

0.1.0-1

4 years ago

0.1.0-0

4 years ago