mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
refactor: cleanup dynamic tag runtime
This commit is contained in:
parent
705df0fb71
commit
d793ebfc4b
@ -10,24 +10,10 @@ import {
|
||||
writeScope,
|
||||
} from "./writer";
|
||||
|
||||
const voidElements = new Set([
|
||||
"area",
|
||||
"base",
|
||||
"br",
|
||||
"col",
|
||||
"embed",
|
||||
"hr",
|
||||
"img",
|
||||
"input",
|
||||
"link",
|
||||
"meta",
|
||||
"param",
|
||||
"source",
|
||||
"track",
|
||||
"wbr",
|
||||
]);
|
||||
const voidElementsReg =
|
||||
/^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
||||
interface RenderBodyObject {
|
||||
[x: string]: unknown;
|
||||
[x: PropertyKey]: unknown;
|
||||
renderBody: Renderer;
|
||||
}
|
||||
|
||||
@ -53,7 +39,7 @@ export function dynamicTagInput(
|
||||
nextScopeId();
|
||||
write(`<${tag}${attrs(input)}>`);
|
||||
|
||||
if (!voidElements.has(tag)) {
|
||||
if (!voidElementsReg.test(tag)) {
|
||||
if (renderBody) {
|
||||
renderBody();
|
||||
}
|
||||
@ -91,14 +77,11 @@ export function dynamicTagArgs(
|
||||
|
||||
if (typeof tag === "string") {
|
||||
nextScopeId();
|
||||
write(`<${tag}${attrs(args[0] as Record<string, unknown>)}></${tag}>`);
|
||||
write(`<${tag}${attrs(args[0] as Record<string, unknown>)}>`);
|
||||
|
||||
// if (!voidElements.has(tag)) {
|
||||
// if (renderBody) {
|
||||
// renderBody();
|
||||
// }
|
||||
// write(`</${tag}>`);
|
||||
// }
|
||||
if (!voidElementsReg.test(tag)) {
|
||||
write(`</${tag}>`);
|
||||
}
|
||||
|
||||
return futureScope;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user