UNPKG

marko

Version:

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

63 lines (53 loc) 1.72 kB
"use strict";var getRenderId = require("../../../runtime/html/get-render-id"); var FLAG_WILL_RERENDER_IN_BROWSER = 1; // var FLAG_HAS_RENDER_BODY = 2; function nextComponentIdProvider(out) { var prefix = getRenderId(out.global) || "s"; // "s" is for server (we use "b" for the browser) var nextId = 0; return function nextComponentId() { return prefix + nextId++; }; } function attachBubblingEvent( componentDef, handlerMethodName, isOnce, extraArgs) { if (handlerMethodName) { if (extraArgs) { var component = componentDef.s_; var eventIndex = component._a_++; // 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.Z_ = [extraArgs]; } else { component.Z_.push(extraArgs); } } return ( handlerMethodName + " " + componentDef.id + " " + isOnce + " " + eventIndex); } else { return handlerMethodName + " " + componentDef.id + " " + isOnce; } } } exports._U_ = nextComponentIdProvider; exports._L_ = true; exports._V_ = attachBubblingEvent; exports._S_ = function noop() {}; exports._T_ = function noop() {}; // eslint-disable-next-line no-constant-condition