# Code coverage report for lib/section/fragment.js

## Statements: 100% (19 / 19) Branches: 100% (0 / 0) Functions: 100% (6 / 6) Lines: 100% (19 / 19) Ignored: none

All files » lib/section/ » fragment.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    671
    1
    1

    1
    772

    1

    104

    99

    105
    105

    1
    99
    99
    99

    1

    58
    58

    58

    1
     var DocumentSection = require("document-section").Section;
    var protoclass      = require("protoclass");
    var utils           = require("../utils");

    /**
     */

    function FragmentSection(nodeFactory, start, end) {
      DocumentSection.call(this, nodeFactory, start, end);
    }

    /**
     */

    DocumentSection.extend(FragmentSection, {

      /**
       */

      rootNode: function() {
        return this.start.parentNode;
      },

      /**
       */

      createMarker: function() {
        return new Marker(this.nodeFactory, utils.getNodePath(this.start), utils.getNodePath(this.end));
      },

      /**
       */

      clone: function() {
        var clone = DocumentSection.prototype.clone.call(this);
        return new FragmentSection(this.nodeFactory, clone.start, clone.end);
      }
    });

    /**
     */

    function Marker(nodeFactory, startPath, endPath) {
      this.nodeFactory = nodeFactory;
      this.startPath   = startPath;
      this.endPath     = endPath;
    }

    /**
     */

    protoclass(Marker, {

      /**
       */

      getSection: function(rootNode) {

        var start = utils.getNodeByPath(rootNode, this.startPath);
        var end   = utils.getNodeByPath(rootNode, this.endPath);

        return new FragmentSection(this.nodeFactory, start, end);
      }
    });

    module.exports = FragmentSection;