regor 1.6.6 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/regor.es2015.cjs.js +133 -31
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +133 -31
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +133 -31
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +133 -31
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +133 -31
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +133 -31
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +132 -30
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +132 -30
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +132 -30
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -262,12 +262,15 @@ createApp(appContext, template, config)
|
|
|
262
262
|
Regor preprocesses table-related templates to keep markup valid when using
|
|
263
263
|
components in table structures.
|
|
264
264
|
|
|
265
|
-
- Supported table containers: `table`, `
|
|
265
|
+
- Supported table containers: `table`, `caption`, `colgroup`, `thead`,
|
|
266
|
+
`tbody`, `tfoot`.
|
|
266
267
|
- Component tags directly under row containers are normalized to valid hosts.
|
|
267
268
|
- Component tags directly under `<tr>` are normalized to `<td>` hosts (except
|
|
268
269
|
native `<td>` / `<th>`).
|
|
270
|
+
- Component tags directly under `<colgroup>` are normalized to `<col>` hosts
|
|
271
|
+
(except native `<col>`).
|
|
269
272
|
- Regor preserves valid table markup while supporting component-based rows and
|
|
270
|
-
cells in table templates.
|
|
273
|
+
cells, captions, sections, column groups, and columns in table templates.
|
|
271
274
|
|
|
272
275
|
Example:
|
|
273
276
|
|
package/dist/regor.es2015.cjs.js
CHANGED
|
@@ -6278,19 +6278,50 @@ var parseTagNameRange = (tagText, isClosing) => {
|
|
|
6278
6278
|
while (i < tagText.length && (tagText[i] === " " || tagText[i] === "\n")) ++i;
|
|
6279
6279
|
if (i >= tagText.length || !isNameChar(tagText[i])) return null;
|
|
6280
6280
|
const start = i;
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6281
|
+
let hasUppercase = false;
|
|
6282
|
+
while (i < tagText.length && isNameChar(tagText[i])) {
|
|
6283
|
+
const c = tagText.charCodeAt(i);
|
|
6284
|
+
if (c >= 65 && c <= 90) {
|
|
6285
|
+
hasUppercase = true;
|
|
6286
|
+
}
|
|
6287
|
+
++i;
|
|
6288
|
+
}
|
|
6289
|
+
return { start, end: i, hasUppercase };
|
|
6290
|
+
};
|
|
6291
|
+
var isTableScopeTag = (tagName) => {
|
|
6292
|
+
switch (tagName) {
|
|
6293
|
+
case "table":
|
|
6294
|
+
case "thead":
|
|
6295
|
+
case "tbody":
|
|
6296
|
+
case "tfoot":
|
|
6297
|
+
return true;
|
|
6298
|
+
default:
|
|
6299
|
+
return false;
|
|
6300
|
+
}
|
|
6301
|
+
};
|
|
6302
|
+
var isRowParentTag = (tagName) => {
|
|
6303
|
+
switch (tagName) {
|
|
6304
|
+
case "thead":
|
|
6305
|
+
case "tbody":
|
|
6306
|
+
case "tfoot":
|
|
6307
|
+
return true;
|
|
6308
|
+
default:
|
|
6309
|
+
return false;
|
|
6310
|
+
}
|
|
6311
|
+
};
|
|
6312
|
+
var isTableDirectAllowed = (tagName) => {
|
|
6313
|
+
switch (tagName) {
|
|
6314
|
+
case "caption":
|
|
6315
|
+
case "colgroup":
|
|
6316
|
+
case "thead":
|
|
6317
|
+
case "tbody":
|
|
6318
|
+
case "tfoot":
|
|
6319
|
+
case "tr":
|
|
6320
|
+
return true;
|
|
6321
|
+
default:
|
|
6322
|
+
return false;
|
|
6323
|
+
}
|
|
6324
|
+
};
|
|
6294
6325
|
var voidElements = /* @__PURE__ */ new Set([
|
|
6295
6326
|
"area",
|
|
6296
6327
|
"base",
|
|
@@ -6307,12 +6338,62 @@ var voidElements = /* @__PURE__ */ new Set([
|
|
|
6307
6338
|
"track",
|
|
6308
6339
|
"wbr"
|
|
6309
6340
|
]);
|
|
6341
|
+
var getTableAliasHost = (tagName) => {
|
|
6342
|
+
switch (tagName) {
|
|
6343
|
+
case "caption":
|
|
6344
|
+
return "captionx";
|
|
6345
|
+
case "thead":
|
|
6346
|
+
return "theadx";
|
|
6347
|
+
case "tbody":
|
|
6348
|
+
return "tbodyx";
|
|
6349
|
+
case "tfoot":
|
|
6350
|
+
return "tfootx";
|
|
6351
|
+
case "tr":
|
|
6352
|
+
return "trx";
|
|
6353
|
+
case "td":
|
|
6354
|
+
return "tdx";
|
|
6355
|
+
case "th":
|
|
6356
|
+
return "thx";
|
|
6357
|
+
case "colgroup":
|
|
6358
|
+
return "colgroupx";
|
|
6359
|
+
case "col":
|
|
6360
|
+
return "colx";
|
|
6361
|
+
default:
|
|
6362
|
+
return null;
|
|
6363
|
+
}
|
|
6364
|
+
};
|
|
6365
|
+
var getTableAliasTag = (host) => {
|
|
6366
|
+
switch (host) {
|
|
6367
|
+
case "captionx":
|
|
6368
|
+
return "caption";
|
|
6369
|
+
case "theadx":
|
|
6370
|
+
return "thead";
|
|
6371
|
+
case "tbodyx":
|
|
6372
|
+
return "tbody";
|
|
6373
|
+
case "tfootx":
|
|
6374
|
+
return "tfoot";
|
|
6375
|
+
case "trx":
|
|
6376
|
+
return "tr";
|
|
6377
|
+
case "tdx":
|
|
6378
|
+
return "td";
|
|
6379
|
+
case "thx":
|
|
6380
|
+
return "th";
|
|
6381
|
+
case "colgroupx":
|
|
6382
|
+
return "colgroup";
|
|
6383
|
+
case "colx":
|
|
6384
|
+
return "col";
|
|
6385
|
+
default:
|
|
6386
|
+
return void 0;
|
|
6387
|
+
}
|
|
6388
|
+
};
|
|
6389
|
+
var closeTag = (tagText, tagName) => `${tagText}</${tagName}>`;
|
|
6310
6390
|
var expandSelfClosingTag = (tagText, tagName) => `${tagText.slice(0, tagText.length - 2)}></${tagName}>`;
|
|
6311
6391
|
var preprocess = (template) => {
|
|
6312
|
-
var _a;
|
|
6392
|
+
var _a, _b;
|
|
6313
6393
|
let i = 0;
|
|
6314
6394
|
const out = [];
|
|
6315
6395
|
const stack = [];
|
|
6396
|
+
const ignoredClosingTags = [];
|
|
6316
6397
|
let tableScopeDepth = 0;
|
|
6317
6398
|
while (i < template.length) {
|
|
6318
6399
|
const lt = template.indexOf("<", i);
|
|
@@ -6351,12 +6432,21 @@ var preprocess = (template) => {
|
|
|
6351
6432
|
continue;
|
|
6352
6433
|
}
|
|
6353
6434
|
const tagName = rawTag.slice(range.start, range.end);
|
|
6435
|
+
const nativeTagName = range.hasUppercase ? "" : tagName;
|
|
6354
6436
|
if (isClosing) {
|
|
6437
|
+
const ignoredClosing = ignoredClosingTags[ignoredClosingTags.length - 1];
|
|
6438
|
+
if ((ignoredClosing == null ? void 0 : ignoredClosing.tagName) === tagName) {
|
|
6439
|
+
ignoredClosingTags.pop();
|
|
6440
|
+
if (ignoredClosing.emit) out.push(rawTag);
|
|
6441
|
+
i = tagEnd + 1;
|
|
6442
|
+
continue;
|
|
6443
|
+
}
|
|
6355
6444
|
const top = stack[stack.length - 1];
|
|
6356
6445
|
if (top) {
|
|
6357
6446
|
stack.pop();
|
|
6358
6447
|
out.push(top.replacementHost ? `</${top.replacementHost}>` : rawTag);
|
|
6359
|
-
if (
|
|
6448
|
+
if (!top.isTableAlias && isTableScopeTag(top.effectiveTag))
|
|
6449
|
+
--tableScopeDepth;
|
|
6360
6450
|
} else {
|
|
6361
6451
|
out.push(rawTag);
|
|
6362
6452
|
}
|
|
@@ -6367,35 +6457,47 @@ var preprocess = (template) => {
|
|
|
6367
6457
|
const parent = stack[stack.length - 1];
|
|
6368
6458
|
let replacementHost = null;
|
|
6369
6459
|
if (tableScopeDepth === 0) {
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
} else if (rowParentTags.has((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
|
|
6374
|
-
replacementHost = tagName === "tr" ? null : "tr";
|
|
6460
|
+
replacementHost = getTableAliasHost(nativeTagName);
|
|
6461
|
+
} else if (isRowParentTag((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
|
|
6462
|
+
replacementHost = nativeTagName === "tr" ? null : "tr";
|
|
6375
6463
|
} else if ((parent == null ? void 0 : parent.effectiveTag) === "table") {
|
|
6376
|
-
replacementHost =
|
|
6464
|
+
replacementHost = isTableDirectAllowed(nativeTagName) ? null : "tr";
|
|
6377
6465
|
} else if ((parent == null ? void 0 : parent.effectiveTag) === "tr") {
|
|
6378
|
-
replacementHost =
|
|
6379
|
-
}
|
|
6380
|
-
|
|
6466
|
+
replacementHost = nativeTagName === "td" || nativeTagName === "th" ? null : "td";
|
|
6467
|
+
} else if ((parent == null ? void 0 : parent.effectiveTag) === "colgroup") {
|
|
6468
|
+
replacementHost = nativeTagName === "col" ? null : "col";
|
|
6469
|
+
}
|
|
6470
|
+
const aliasTag = getTableAliasTag(replacementHost);
|
|
6471
|
+
const isTableAlias = aliasTag !== void 0;
|
|
6472
|
+
const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || nativeTagName);
|
|
6473
|
+
const shouldCloseVoidAlias = !!replacementHost && aliasTag === nativeTagName && voidElements.has(nativeTagName);
|
|
6474
|
+
const shouldIgnoreClosingTag = !selfClosing && !!replacementHost && voidElements.has(replacementHost) && !shouldCloseVoidAlias;
|
|
6475
|
+
const shouldIgnoreNativeVoidClosingTag = !selfClosing && !replacementHost && voidElements.has(nativeTagName);
|
|
6381
6476
|
if (replacementHost) {
|
|
6382
|
-
const
|
|
6383
|
-
const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${isAlias ? `r-${tagName}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
|
|
6477
|
+
const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${aliasTag ? `r-${aliasTag}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
|
|
6384
6478
|
out.push(
|
|
6385
|
-
shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : rewrittenTag
|
|
6479
|
+
shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : shouldCloseVoidAlias ? closeTag(rewrittenTag, replacementHost) : rewrittenTag
|
|
6386
6480
|
);
|
|
6387
6481
|
} else {
|
|
6388
6482
|
out.push(
|
|
6389
6483
|
shouldExpandSelfClosing ? expandSelfClosingTag(rawTag, tagName) : rawTag
|
|
6390
6484
|
);
|
|
6391
6485
|
}
|
|
6392
|
-
if (
|
|
6393
|
-
|
|
6486
|
+
if (shouldIgnoreClosingTag) {
|
|
6487
|
+
ignoredClosingTags.push({ tagName, emit: false });
|
|
6488
|
+
} else if (shouldCloseVoidAlias && !selfClosing) {
|
|
6489
|
+
ignoredClosingTags.push({ tagName, emit: false });
|
|
6490
|
+
} else if (shouldIgnoreNativeVoidClosingTag) {
|
|
6491
|
+
ignoredClosingTags.push({ tagName, emit: true });
|
|
6492
|
+
}
|
|
6493
|
+
if (!selfClosing && !shouldCloseVoidAlias && !shouldIgnoreClosingTag && !shouldIgnoreNativeVoidClosingTag && !voidElements.has(replacementHost != null ? replacementHost : nativeTagName)) {
|
|
6494
|
+
const effectiveTag = (_b = aliasTag != null ? aliasTag : replacementHost) != null ? _b : nativeTagName || tagName;
|
|
6394
6495
|
stack.push({
|
|
6395
6496
|
replacementHost,
|
|
6396
|
-
effectiveTag
|
|
6497
|
+
effectiveTag,
|
|
6498
|
+
isTableAlias
|
|
6397
6499
|
});
|
|
6398
|
-
if (
|
|
6500
|
+
if (!isTableAlias && isTableScopeTag(effectiveTag)) ++tableScopeDepth;
|
|
6399
6501
|
}
|
|
6400
6502
|
i = tagEnd + 1;
|
|
6401
6503
|
}
|