JSPM

  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q10693F
  • License MIT

A minimal DOM implementation

Package Exports

  • dom-lite

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 (dom-lite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@version    0.2.0
@date       2015-01-16
@stability  2 - Unstable

DOM lite – Build Coverage

A minimal DOM implementation

Examples

var document = require("dom-lite").document;

var el = document.createElement("h1");
el.id = 123;
el.className = "large";

var fragment = document.createDocumentFragment();
var text1 = document.createTextNode("hello");
var text2 = document.createTextNode(" world");

fragment.appendChild(text1);
fragment.appendChild(text2);
el.appendChild(fragment);

el.toString();
// <h1 id="123" class="large">hello world</h1>
el.outerHTML;
// <h1 id="123" class="large">hello world</h1>
el.innerHTML;
// hello world

Implemented features

Node

  • nodeName
  • nodeValue
  • parentNode
  • ownerDocument
  • childNodes
  • textContent
  • firstChild
  • lastChild
  • previousSibling
  • nextSibling
  • innerHTML() - Read Only
  • outerHTML() - Read Only
  • hasChildNodes()
  • appendChild()
  • insertBefore()
  • removeChild()
  • replaceChild()
  • cloneNode()

DocumentFragment

Extends Node.

  • nodeType

HTMLElement

Extends Node.

  • attributes
  • nodeType
  • localName
  • tagName
  • style
  • className
  • hasAttribute()
  • getAttribute()
  • setAttribute()
  • removeAttribute()
  • getElementById()
  • getElementsByTagName()
  • querySelector() - Only simple selectors
  • querySelectorAll() - Only simple selectors

Text

Extends Node.

  • nodeType
  • data

Comment

Extends Node.

  • nodeType
  • data

Document

Extends Node.

  • nodeType
  • createElement()
  • createElementNS()
  • createTextNode()
  • createComment()
  • createDocumentFragment()
  • getElementById()
  • getElementsByTagName()
  • querySelector()
  • querySelectorAll()

Coding Style Guidelines

  • Use tabs for indentation, align with spaces
  • Use lowerCamelCase for method and variable names
  • Use UpperCamelCase for constructor names
  • Commit files with Unix-style line endings
  • Do not use spaces in file and directory names Consider substituting a dash (-) where you would normally use spaces.
  • Rebase before pushing
  • Fix tests before push or pull request

Licence

Copyright (c) 2014 Lauri Rooden <lauri@rooden.ee>
The MIT License