# Code coverage report for lib/utils/index.js

## Statements: 100% (12 / 12) Branches: 100% (0 / 0) Functions: 100% (2 / 2) Lines: 100% (12 / 12) Ignored: none

All files » lib/utils/ » index.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    241

    1

    313
    313

    199
    199
    199

    313

    279
    279
    135

    279

     var createDocumentSection = require("document-section");

    module.exports = {
      getNodePath: function (node) {
        var path = [], p = node.parentNode, c = node;
        while (p) {

          // need to slice since some browsers don't support indexOf for child nodes
          path.unshift(Array.prototype.slice.call(p.childNodes).indexOf(c));
          c = p;
          p = p.parentNode;
        }

        return path;
      },
      getNodeByPath: function (node, path) {
        var c = node;
        for (var i = 0, n = path.length; i < n; i++) {
          c = c.childNodes[path[i]];
        }
        return c;
      },
      createSingleSection: require("./singleNodeSection")
    }