Code coverage report for lib/section/fragment.js

Statements: 63.16% (12 / 19)      Branches: 100% (0 / 0)      Functions: 50% (3 / 6)      Lines: 63.16% (12 / 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 14           1           1                           1 1             1                 1                           1  
var DocumentSection = require("document-section").Section;
var protoclass      = require("protoclass");
var utils           = require("../utils");
 
/**
 */
 
function FragmentSection(document, start, end) {
  DocumentSection.call(this, document, start, end);
}
 
/**
 */
 
DocumentSection.extend(FragmentSection, {
 
  /**
   */
 
  rootNode: function() {
    return this.start.parentNode;
  },
 
  /**
   */
 
  createMarker: function() {
    return new Marker(this.document, utils.getNodePath(this.start), utils.getNodePath(this.end));
  },
 
  /**
   */
 
  clone: function() {
    var clone = DocumentSection.prototype.clone.call(this);
    return new FragmentSection(this.document, clone.start, clone.end);
  }
});
 
/**
 */
 
function Marker(document, startPath, endPath) {
  this.document = document;
  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.document, start, end);
  }
});
 
module.exports = FragmentSection;