mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
refactor: prepare for renderBody/event interop from tags to class
This commit is contained in:
parent
4da726c7aa
commit
c8849980bb
4
packages/marko/src/node_modules/@internal/components-entry/index.js
generated
vendored
4
packages/marko/src/node_modules/@internal/components-entry/index.js
generated
vendored
@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var warp10 = require("warp10");
|
||||
var w10NOOP = require("warp10/constants").NOOP;
|
||||
var safeJSONRegExp = /<\/|\u2028|\u2029/g;
|
||||
var IGNORE_GLOBAL_TYPES = new Set(["undefined", "function", "symbol"]);
|
||||
var DEFAULT_RUNTIME_ID = "M";
|
||||
@ -70,13 +71,14 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
||||
var customEvents = component.___customEvents;
|
||||
var scope = component.___scope;
|
||||
var bubblingDomEvents = component.___bubblingDomEvents;
|
||||
var renderBody = input.renderBody;
|
||||
|
||||
var state;
|
||||
var serializedProps;
|
||||
var undefinedPropNames;
|
||||
|
||||
if (flags & FLAG_WILL_RERENDER_IN_BROWSER) {
|
||||
if (typeof input.renderBody === "function") {
|
||||
if (typeof renderBody === "function" && renderBody.toJSON && renderBody.toJSON() === w10NOOP) {
|
||||
flags |= FLAG_HAS_RENDER_BODY;
|
||||
input.renderBody = undefined;
|
||||
}
|
||||
|
||||
@ -16,9 +16,12 @@ const {
|
||||
nextScopeId,
|
||||
} = tagsAPI;
|
||||
|
||||
// const w10NOOP = require("warp10/constants").NOOP;
|
||||
const w10NOOP = require("warp10/constants").NOOP;
|
||||
const RENDER_BODY_TO_JSON = function () {
|
||||
return { ___isTagsAPI: true };
|
||||
// TODO: this should instead return an object that contains getRegistryInfo
|
||||
// then in the dom-compat, handle that object to lookup the function in the registry
|
||||
// (we also need to do this for events)
|
||||
return w10NOOP;
|
||||
};
|
||||
|
||||
const isMarko6 = (fn) => !!fn.___isTagsAPI;
|
||||
@ -32,7 +35,7 @@ export default dynamicTag5.___runtimeCompat = function tagsToVdom(
|
||||
if (tagsRenderer ? isMarko5(tagsRenderer) : isMarko5(renderBody))
|
||||
return tagsRenderer;
|
||||
|
||||
if (renderBody) {
|
||||
if (!tagsRenderer && renderBody) {
|
||||
renderBody.toJSON = RENDER_BODY_TO_JSON;
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,11 @@ export {
|
||||
|
||||
export { createTemplate } from "./template";
|
||||
|
||||
export { register, makeSerializable, serializedScope } from "./serializer";
|
||||
export {
|
||||
register,
|
||||
makeSerializable,
|
||||
serializedScope,
|
||||
getRegistryInfo,
|
||||
} from "./serializer";
|
||||
|
||||
export { pushContext, popContext, getInContext } from "../common/context";
|
||||
|
||||
@ -39,6 +39,10 @@ export function register<T>(
|
||||
return entry as Serializable<T>;
|
||||
}
|
||||
|
||||
export function getRegistryInfo(entry: Serializable<unknown>) {
|
||||
return [entry[SYMBOL_REGISTRY_ID], entry[SYMBOL_SCOPE]];
|
||||
}
|
||||
|
||||
export function makeSerializable<T>(
|
||||
object: T,
|
||||
serialize: (s: Serializer, accessor: string | number) => void
|
||||
|
||||
@ -69,6 +69,7 @@ export default {
|
||||
|
||||
if (hasInteractiveChild) {
|
||||
(currentProgramPath.node.extra ?? {}).hasInteractiveChild = true;
|
||||
// TODO: should check individual inputs to see if they are intersecting with state
|
||||
}
|
||||
},
|
||||
exit(tag: t.NodePath<t.MarkoTag>) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user