File size: 1,202 Bytes
edaa6b9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import { escapeToBuffer, raw, stringBufferToString } from "../utils/html.js";
import { html } from "../helper/html/index.js";
import { PERMALINK } from "./constants.js";
import { isValidAttributeName } from "./utils.js";
import { Fragment, attributeToBuffer, markRenderedJSX } from "./base.js";
import { jsxDEV } from "./jsx-dev-runtime.js";
//#region src/jsx/jsx-runtime.ts
const jsxTemplate = (strings, ...values) => {
const result = html(strings, ...values);
return result instanceof Promise ? result.then(markRenderedJSX) : markRenderedJSX(result);
};
const jsxAttr = (key, v) => {
if (!isValidAttributeName(key)) return raw("");
if (typeof v === "string") {
const buffer = [`${key}="`];
escapeToBuffer(v, buffer);
return raw(buffer[0] + "\"");
}
let value = v;
if (typeof value === "function" && (key === "action" || key === "formaction")) value = PERMALINK in value ? value[PERMALINK] : void 0;
const buffer = [""];
attributeToBuffer(buffer, "", key, value);
return buffer.length === 1 ? raw(buffer[0]) : stringBufferToString(buffer, void 0);
};
const jsxEscape = (value) => value;
//#endregion
export { Fragment, jsxDEV as jsx, jsxAttr, jsxEscape, jsxTemplate, jsxDEV as jsxs };
|