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 = {
bV_: function (finalChildCount, ownerComponent) {
this.cj_ = finalChildCount;
this.ck_ = 0;
this.cb_ = null;
this.cl_ = null;
this.bZ_ = null;
this.c__ = null;
this._M_ = ownerComponent;
},
get aA_() {
var firstChild = this.cb_;
if (firstChild && firstChild.ca_) {
var nestedFirstChild = firstChild.aA_;
// 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.cm_;
}
return firstChild;
},
get cm_() {
var nextSibling = this.c__;
if (nextSibling) {
if (nextSibling.ca_) {
var firstChild = nextSibling.aA_;
return firstChild || nextSibling.cm_;
}
} else {
var parentNode = this.bZ_;
if (parentNode && parentNode.ca_) {
return parentNode.cm_;
}
}
return nextSibling;
},
bO_: function (child) {
this.ck_++;
if (hasTextContent(this.cd_)) {
if (child.cn_) {
this.ce_ += child.bW_;
} else {
throw TypeError();
}
} else {
var lastChild = this.cl_;
child.bZ_ = this;
if (lastChild) {
lastChild.c__ = child;
} else {
this.cb_ = child;
}
this.cl_ = child;
}
return child;
},
cg_: function finishChild() {
if (this.ck_ === this.cj_ && this.bZ_) {
return this.bZ_.cg_();
} 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;