marko
Version:
UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.
100 lines (83 loc) • 2.14 kB
JavaScript
"use strict";var hasTextContent = require("./is-text-only");
function VNode() {}
VNode.prototype = {
bY_: function (finalChildCount, ownerComponent) {
this.cm_ = finalChildCount;
this.cn_ = 0;
this.ce_ = null;
this.co_ = null;
this.cb_ = null;
this.cc_ = null;
this._O_ = ownerComponent;
},
get aC_() {
var firstChild = this.ce_;
if (firstChild && firstChild.cd_) {
var nestedFirstChild = firstChild.aC_;
// The first child is a DocumentFragment node.
// If the DocumentFragment node has a first child then we will return that.
// Otherwise, the DocumentFragment node is not *really* the first child and
// we need to skip to its next sibling
return nestedFirstChild || firstChild.cp_;
}
return firstChild;
},
get cp_() {
var nextSibling = this.cc_;
if (nextSibling) {
if (nextSibling.cd_) {
var firstChild = nextSibling.aC_;
return firstChild || nextSibling.cp_;
}
} else {
var parentNode = this.cb_;
if (parentNode && parentNode.cd_) {
return parentNode.cp_;
}
}
return nextSibling;
},
bR_: function (child) {
this.cn_++;
if (hasTextContent(this.cg_)) {
if (child.cq_) {
this.ch_ += child.bZ_;
} else {
throw TypeError();
}
} else {
var lastChild = this.co_;
child.cb_ = this;
if (lastChild) {
lastChild.cc_ = child;
} else {
this.ce_ = child;
}
this.co_ = child;
}
return child;
},
cj_: function finishChild() {
if (this.cn_ === this.cm_ && this.cb_) {
return this.cb_.cj_();
} else {
return this;
}
}
// ,toJSON: function() {
// var clone = Object.assign({
// nodeType: this.nodeType
// }, this);
//
// for (var k in clone) {
// if (k.startsWith('_')) {
// delete clone[k];
// }
// }
// delete clone._nextSibling;
// delete clone._lastChild;
// delete clone.parentNode;
// return clone;
// }
};
module.exports = VNode;