UNPKG

marko

Version:

UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.

59 lines (46 loc) 1.46 kB
"use strict"; var GlobalComponentsContext = require("./GlobalComponentsContext"); function ComponentsContext(out, parentComponentsContext) { var globalComponentsContext; var componentDef; if (parentComponentsContext) { globalComponentsContext = parentComponentsContext.p_; componentDef = parentComponentsContext.o_; var nestedContextsForParent; if ( !(nestedContextsForParent = parentComponentsContext._e_)) { nestedContextsForParent = parentComponentsContext._e_ = []; } nestedContextsForParent.push(this); } else { globalComponentsContext = out.global.b_; if (globalComponentsContext === undefined) { out.global.b_ = globalComponentsContext = new GlobalComponentsContext(out); } } this.p_ = globalComponentsContext; this.b_ = []; this.r_ = out; this.o_ = componentDef; this._e_ = undefined; this.v_ = parentComponentsContext && parentComponentsContext.v_; } ComponentsContext.prototype = { ah_: function (host) { var componentDefs = this.b_; ComponentsContext._K_(componentDefs, host); this.r_.emit("aR_"); // Reset things stored in global since global is retained for // future renders this.r_.global.b_ = undefined; return componentDefs; } }; function getComponentsContext(out) { return out.b_ || (out.b_ = new ComponentsContext(out)); } module.exports = exports = ComponentsContext; exports.T_ = getComponentsContext;