marko
Version:
UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.
99 lines (83 loc) • 2.12 kB
JavaScript
"use strict"; /* jshint newcap:false */
function VNode() {}
VNode.prototype = {
bU_: function (finalChildCount, ownerComponent) {
this.ch_ = finalChildCount;
this.ci_ = 0;
this.c__ = null;
this.cj_ = null;
this.bX_ = null;
this.bY_ = null;
this._L_ = ownerComponent;
},
get az_() {
var firstChild = this.c__;
if (firstChild && firstChild.bZ_) {
var nestedFirstChild = firstChild.az_;
// 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.ck_;
}
return firstChild;
},
get ck_() {
var nextSibling = this.bY_;
if (nextSibling) {
if (nextSibling.bZ_) {
var firstChild = nextSibling.az_;
return firstChild || nextSibling.ck_;
}
} else {
var parentNode = this.bX_;
if (parentNode && parentNode.bZ_) {
return parentNode.ck_;
}
}
return nextSibling;
},
bN_: function (child) {
this.ci_++;
if (this.cb_ === "textarea") {
if (child.cl_) {
this.cc_ += child.cm_;
} else {
throw TypeError();
}
} else {
var lastChild = this.cj_;
child.bX_ = this;
if (lastChild) {
lastChild.bY_ = child;
} else {
this.c__ = child;
}
this.cj_ = child;
}
return child;
},
ce_: function finishChild() {
if (this.ci_ === this.ch_ && this.bX_) {
return this.bX_.ce_();
} 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;