var DocumentSection = require("document-section").Section;
var protoclass = require("protoclass");
var utils = require("../utils");
/**
*/
function NodeSection(document, node, _rnode) {
this.node = node;
this.document = document;
}
/**
*/
protoclass(NodeSection, {
/**
*/
rootNode: function() {
return this.node;
},
/**
*/
createMarker: function() {
return new Marker(this.document, utils.getNodePath(this.node));
},
/**
*/
appendChild: function(child) {
this.node.appendChild(child);
},
/**
*/
removeAll: function() {
this.node.innerHTML = "";
},
/**
*/
render: function() {
return this.node;
},
/**
*/
remove: function() {
Iif (this.node.parentNode) this.node.parentNode.removeChild(this.node);
},
/**
*/
clone: function() {
return new NodeSection(this.document, this.node.cloneNode(true));
}
});
/**
*/
function Marker(document, nodePath) {
this.nodePath = nodePath;
this.document = document;
}
/**
*/
protoclass(Marker, {
/**
*/
getSection: function(rootNode) {
var start = utils.getNodeByPath(rootNode, this.nodePath);
return new NodeSection(this.document, start);
}
});
module.exports = NodeSection;
|