marko
Version:
UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.
71 lines (53 loc) • 1.74 kB
JavaScript
;var FLAG_WILL_RERENDER_IN_BROWSER = 1;
// var FLAG_HAS_RENDER_BODY = 2;
function nextComponentIdProvider(out) {
var prefix = out.global.componentIdPrefix || out.global.widgetIdPrefix || "s"; // "s" is for server (we use "b" for the browser)
var nextId = 0;
// eslint-disable-next-line no-constant-condition
return function nextComponentId() {
return prefix + nextId++;
};
}
function attachBubblingEvent(
componentDef,
handlerMethodName,
isOnce,
extraArgs)
{
if (handlerMethodName) {
if (extraArgs) {
var component = componentDef.s_;
var eventIndex = component.Z_++;
// If we are not going to be doing a rerender in the browser
// then we need to actually store the extra args with the UI component
// so that they will be serialized down to the browser.
// If we are rerendering in the browser then we just need to
// increment ___bubblingDomEventsExtraArgsCount to keep track of
// where the extra args will be found when the UI component is
// rerendered in the browser
if (!(componentDef.u_ & FLAG_WILL_RERENDER_IN_BROWSER)) {
if (eventIndex === 0) {
component.X_ = [extraArgs];
} else {
component.X_.push(extraArgs);
}
}
return (
handlerMethodName +
" " +
componentDef.id +
" " +
isOnce +
" " +
eventIndex);
} else {
return handlerMethodName + " " + componentDef.id + " " + isOnce;
}
}
}
exports._R_ = nextComponentIdProvider;
exports._I_ = true;
exports._S_ = attachBubblingEvent;
exports._P_ = function noop() {};
exports._Q_ = function noop() {};
// eslint-disable-next-line no-constant-condition