Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-ui-proto-blank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Builder UI: the preview now fills a blank named `{{__proto__}}` the same way the CLI does instead of showing it as unfilled while the generated command passes it. (#327)
9 changes: 9 additions & 0 deletions dist/ui-builder.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ui-builder.test.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@
}

const arrayVars = [];
const scalarValues = {};
const scalarValues = Object.create(null);

for (const row of rows) {
const vals = splitValues(row.values, row.source);
Expand All @@ -858,7 +858,7 @@
const results = [];
try {
for (const combo of combos) {
const vals = { ...scalarValues };
const vals = Object.assign(Object.create(null), scalarValues);
arrayVars.forEach((v, i) => { vals[v.name] = combo[i]; });
results.push({ values: { ...vals }, expanded: sharedExpand(text, vals) });
}
Expand Down
10 changes: 10 additions & 0 deletions src/ui-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,16 @@ test('update ignores rows without a name', () => {
assert.equal(h.cli(), 'promptargs "Hello {{name}}" --name=World');
});

test('update fills a variable named __proto__ in the preview like the CLI does', () => {
const h = makeHarness();
h.tmpl.value = 'Hello {{__proto__}}';
h.rows.push({ name: '__proto__', values: 'world' });
h.update();
assert.deepEqual(expandedTexts(h), ['Hello world']);
assert.ok(!h.previewBody.innerHTML.includes('class="unfilled"'), '__proto__ should not be unfilled');
assert.equal(h.cli(), 'promptargs "Hello {{__proto__}}" --__proto__=world');
});

// --- PRESETS -----------------------------------------------------------------

interface Preset {
Expand Down
4 changes: 2 additions & 2 deletions src/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@
}

const arrayVars = [];
const scalarValues = {};
const scalarValues = Object.create(null);

for (const row of rows) {
const vals = splitValues(row.values, row.source);
Expand All @@ -858,7 +858,7 @@
const results = [];
try {
for (const combo of combos) {
const vals = { ...scalarValues };
const vals = Object.assign(Object.create(null), scalarValues);
arrayVars.forEach((v, i) => { vals[v.name] = combo[i]; });
results.push({ values: { ...vals }, expanded: sharedExpand(text, vals) });
}
Expand Down
Loading