@barefootjs/test 0.34.0 → 0.35.0
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/dist/index.js +65 -11
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -189438,6 +189438,12 @@ class BindingScope {
|
|
|
189438
189438
|
}
|
|
189439
189439
|
}
|
|
189440
189440
|
|
|
189441
|
+
// ../jsx/src/ir-to-client-js/safe-html.ts
|
|
189442
|
+
function safeHtml(expr) {
|
|
189443
|
+
return expr;
|
|
189444
|
+
}
|
|
189445
|
+
var EMPTY_MARKUP = safeHtml("''");
|
|
189446
|
+
|
|
189441
189447
|
// ../jsx/src/ir-to-client-js/html-template.ts
|
|
189442
189448
|
function splitTemplateInterpolations(inner) {
|
|
189443
189449
|
const parts = [];
|
|
@@ -189626,8 +189632,6 @@ function collectAstPropRefs(node, propNames, out) {
|
|
|
189626
189632
|
walkWithScope(node, (n, parent, shadowed) => {
|
|
189627
189633
|
if (shadowed || !propNames.has(n.text))
|
|
189628
189634
|
return;
|
|
189629
|
-
if (parent && import_typescript7.default.isShorthandPropertyAssignment(parent) && parent.name === n)
|
|
189630
|
-
return;
|
|
189631
189635
|
if (isNonValuePosition(n, parent))
|
|
189632
189636
|
return;
|
|
189633
189637
|
out.add(n.text);
|
|
@@ -191449,6 +191453,7 @@ var CLIENT_EXPORTS = new Set([
|
|
|
191449
191453
|
"isSSRPortal",
|
|
191450
191454
|
"findSiblingSlot",
|
|
191451
191455
|
"cleanupPortalPlaceholder",
|
|
191456
|
+
"trackPosition",
|
|
191452
191457
|
"createSearchParams",
|
|
191453
191458
|
"queryHref",
|
|
191454
191459
|
"formatDate",
|
|
@@ -192768,7 +192773,8 @@ var BROWSER_ONLY_CLIENT_APIS = new Set([
|
|
|
192768
192773
|
"createPortal",
|
|
192769
192774
|
"isSSRPortal",
|
|
192770
192775
|
"findSiblingSlot",
|
|
192771
|
-
"cleanupPortalPlaceholder"
|
|
192776
|
+
"cleanupPortalPlaceholder",
|
|
192777
|
+
"trackPosition"
|
|
192772
192778
|
]);
|
|
192773
192779
|
function importsBrowserOnlyClientApi(ctx) {
|
|
192774
192780
|
for (const imp of ctx.imports) {
|
|
@@ -194841,9 +194847,8 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194841
194847
|
function visit2(n, parent) {
|
|
194842
194848
|
if (import_typescript14.default.isIdentifier(n) && propDepsMap.has(n.text)) {
|
|
194843
194849
|
const isObjectKey = parent && import_typescript14.default.isPropertyAssignment(parent) && parent.name === n;
|
|
194844
|
-
const isShorthand = parent && import_typescript14.default.isShorthandPropertyAssignment(parent) && parent.name === n;
|
|
194845
194850
|
const isAccessName = parent && import_typescript14.default.isPropertyAccessExpression(parent) && parent.name === n;
|
|
194846
|
-
if (!isObjectKey && !
|
|
194851
|
+
if (!isObjectKey && !isAccessName) {
|
|
194847
194852
|
const deps = propDepsMap.get(n.text);
|
|
194848
194853
|
if (deps && deps.size > 0) {
|
|
194849
194854
|
if (!acc)
|
|
@@ -195321,8 +195326,7 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
|
|
|
195321
195326
|
children.push({
|
|
195322
195327
|
type: "expression",
|
|
195323
195328
|
expr,
|
|
195324
|
-
templateExpr
|
|
195325
|
-
escapeInClientTemplate: true,
|
|
195329
|
+
templateExpr,
|
|
195326
195330
|
typeInfo: null,
|
|
195327
195331
|
reactive: false,
|
|
195328
195332
|
slotId: null,
|
|
@@ -195333,26 +195337,76 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
|
|
|
195333
195337
|
}
|
|
195334
195338
|
const selectedForLiteral = (optValue) => AttrValueOf.expression(`(${expr}) === ${JSON.stringify(optValue)}`, templateExpr !== undefined ? { templateExpr: `(${templateExpr}) === ${JSON.stringify(optValue)}` } : undefined);
|
|
195335
195339
|
const selectedForExpr = (optExpr, optTemplateExpr) => AttrValueOf.expression(`(${expr}) === (${optExpr})`, templateExpr !== undefined || optTemplateExpr !== undefined ? { templateExpr: `(${templateExpr ?? expr}) === (${optTemplateExpr ?? optExpr})` } : undefined);
|
|
195340
|
+
const matchConditions = [];
|
|
195341
|
+
let optionSetIsDynamic = false;
|
|
195336
195342
|
const distribute = (nodes) => {
|
|
195337
195343
|
for (const n of nodes) {
|
|
195344
|
+
if (n.type === "text")
|
|
195345
|
+
continue;
|
|
195338
195346
|
if (n.type === "element" && n.tag === "option") {
|
|
195339
|
-
if (n.attrs.some((a) => a.name === "selected"))
|
|
195347
|
+
if (n.attrs.some((a) => a.name === "selected")) {
|
|
195348
|
+
optionSetIsDynamic = true;
|
|
195340
195349
|
continue;
|
|
195350
|
+
}
|
|
195341
195351
|
const optValue = n.attrs.find((a) => a.name === "value");
|
|
195342
|
-
if (!optValue)
|
|
195352
|
+
if (!optValue) {
|
|
195353
|
+
optionSetIsDynamic = true;
|
|
195343
195354
|
continue;
|
|
195355
|
+
}
|
|
195344
195356
|
if (optValue.value.kind === "literal") {
|
|
195345
|
-
|
|
195357
|
+
const selected = selectedForLiteral(optValue.value.value);
|
|
195358
|
+
n.attrs.push({ name: "selected", value: selected, loc: n.loc });
|
|
195359
|
+
matchConditions.push(selected);
|
|
195346
195360
|
} else if (optValue.value.kind === "expression") {
|
|
195347
195361
|
const selected = selectedForExpr(optValue.value.expr, optValue.value.templateExpr);
|
|
195348
195362
|
n.attrs.push({ name: "selected", value: selected, loc: n.loc });
|
|
195363
|
+
matchConditions.push(selected);
|
|
195364
|
+
} else {
|
|
195365
|
+
optionSetIsDynamic = true;
|
|
195349
195366
|
}
|
|
195350
|
-
} else if (n.type === "fragment" || n.type === "
|
|
195367
|
+
} else if (n.type === "fragment" || n.type === "element" && n.tag === "optgroup") {
|
|
195368
|
+
distribute(n.children);
|
|
195369
|
+
} else if (n.type === "loop") {
|
|
195370
|
+
optionSetIsDynamic = true;
|
|
195351
195371
|
distribute(n.children);
|
|
195372
|
+
} else {
|
|
195373
|
+
optionSetIsDynamic = true;
|
|
195352
195374
|
}
|
|
195353
195375
|
}
|
|
195354
195376
|
};
|
|
195355
195377
|
distribute(children);
|
|
195378
|
+
if (optionSetIsDynamic || matchConditions.length === 0)
|
|
195379
|
+
return;
|
|
195380
|
+
if (isMultiSelection(attrs))
|
|
195381
|
+
return;
|
|
195382
|
+
const orExpr = matchConditions.map((c) => `(${c.expr})`).join(" || ");
|
|
195383
|
+
const orTemplateExpr = matchConditions.some((c) => c.templateExpr !== undefined) ? matchConditions.map((c) => `(${c.templateExpr ?? c.expr})`).join(" || ") : undefined;
|
|
195384
|
+
children.unshift({
|
|
195385
|
+
type: "element",
|
|
195386
|
+
tag: "option",
|
|
195387
|
+
attrs: [
|
|
195388
|
+
{ name: "value", value: AttrValueOf.literal(""), loc: valueAttr.loc },
|
|
195389
|
+
{ name: "disabled", value: AttrValueOf.booleanAttr(), loc: valueAttr.loc },
|
|
195390
|
+
{ name: "hidden", value: AttrValueOf.booleanAttr(), loc: valueAttr.loc },
|
|
195391
|
+
{
|
|
195392
|
+
name: "selected",
|
|
195393
|
+
value: AttrValueOf.expression(`!(${orExpr})`, orTemplateExpr !== undefined ? { templateExpr: `!(${orTemplateExpr})` } : undefined),
|
|
195394
|
+
loc: valueAttr.loc
|
|
195395
|
+
}
|
|
195396
|
+
],
|
|
195397
|
+
events: [],
|
|
195398
|
+
ref: null,
|
|
195399
|
+
children: [],
|
|
195400
|
+
slotId: null,
|
|
195401
|
+
needsScope: false,
|
|
195402
|
+
loc: valueAttr.loc
|
|
195403
|
+
});
|
|
195404
|
+
}
|
|
195405
|
+
function isMultiSelection(attrs) {
|
|
195406
|
+
if (attrs.some((a) => a.name === "multiple"))
|
|
195407
|
+
return true;
|
|
195408
|
+
const sizeAttr = attrs.find((a) => a.name === "size");
|
|
195409
|
+
return sizeAttr?.value.kind === "literal" && Number(sizeAttr.value.value) > 1;
|
|
195356
195410
|
}
|
|
195357
195411
|
function transformHtmlElement(node, ctx, tagName) {
|
|
195358
195412
|
const { attrs, events, ref } = processAttributes(node.openingElement.attributes, ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/test",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Test utilities for BarefootJS - IR-based component testing without a browser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"directory": "packages/test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@barefootjs/jsx": "0.
|
|
42
|
+
"@barefootjs/jsx": "0.35.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.0.0"
|