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

## Statements: 100% (16 / 16) Branches: 100% (0 / 0) Functions: 100% (6 / 6) Lines: 100% (16 / 16) 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
    67
    681

    1
    640

    1

    79

    89

    80
    80

    1
    89
    89
    89

    1

    48

    48

    1

     var DocumentSection = require("document-section").Section,
    protoclass          = require("protoclass"),
    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),
        end       = utils.getNodeByPath(rootNode, this.endPath);

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

    module.exports = FragmentSection;