Skip to content
Eugene Lazutkin edited this page Jun 14, 2016 · 1 revision

heya-dom can be installed with npm (newer versions instal packages using a flat structure) or bower. The former puts packages into node_modules/, the latter puts into bower_components/. In examples below we assume that npm was used.

AMD

AMD is the easiest option, because it takes care of all dependencies. Example (based on tests.html):

<!DOCTYPE html>
<html>
  <head>
    <title>Example</title>
    <script>
      require.config({
        baseUrl: ".",
        packages: [
          {name: "heya-dom", location: "node_modules/heya-dom"}
        ],
        paths: {
          domReady: "http://cdnjs.cloudflare.com/ajax/libs/require-domReady/2.0.1/domReady.min"
        }
      });
      require(
        ["heya-dom/build", "domReady!"],
        function(build){
          // code that uses build()
        }
      );
    </script>
  </head>
  <body>
    <!-- some HTML stuff -->
  </body>
</html>

The map of AMD modules:

File name Returns Defines Description
create.js create See create
build.js build See build
hyperscript.js hyperscript See hyperscript
fromHtml.js fromHtml See fromHtml

Globals

Using globals is easy too, but require to be careful with dependencies:

<!DOCTYPE html>
<html>
  <head>
    <title>Example</title>
    <script src="node_modules/heya-dom/dist/create.js"></script>
    <script src="node_modules/heya-dom/dist/build.js"></script>
    <script>
      var build = heya.dom.build;
      // code that uses build()
    </script>
  </head>
  <body>
    <!-- some HTML stuff -->
  </body>
</html>

By default, heya-dom uses heya.dom global namespace. Mapping of files to globals:

File name Global Description
dist/create.js heya.dom.create See create
dist/build.js heya.dom.build See build
dist/hyperscript.js heya.dom.hyperscript See hyperscript
dist/fromHtml.js heya.dom.fromHtml See fromHtml

Dependencies

Implicitly dom does not depend on any other package. Following internal dependencies are exist between files in dist/:

  • create.js — no dependencies.
  • build.jscreate.js
  • hyperscript.jscreate.js
  • fromHtml.js — no dependencies.
Clone this wiki locally