Skip to content

Commit

Permalink
fix: look up selection origDef using original name not varName (#5561)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvind authored and domoritz committed Nov 17, 2019
1 parent 7e0dbd1 commit 50429d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/compile/selection/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function parseUnitSelection(model: UnitModel, selDefs: Dict<SelectionDef>
const selCmpts: Dict<SelectionComponent<any /* this has to be "any" so typing won't fail in test files*/>> = {};
const selectionConfig = model.config.selection;

for (let name in selDefs) {
for (const name in selDefs) {
if (!hasOwnProperty(selDefs, name)) {
continue;
}
Expand Down Expand Up @@ -43,10 +43,10 @@ export function parseUnitSelection(model: UnitModel, selDefs: Dict<SelectionDef>
}
}

name = varName(name);
const selCmpt = (selCmpts[name] = {
const safeName = varName(name);
const selCmpt = (selCmpts[safeName] = {
...selDef,
name: name,
name: safeName,
events: isString(selDef.on) ? parseSelector(selDef.on, 'scope') : selDef.on
} as any);

Expand Down
10 changes: 10 additions & 0 deletions test/compile/selection/inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ describe('Inputs Selection Transform', () => {
fields: ['nested.a'],
on: 'click',
bind: {input: 'range', min: 0, max: 10, step: 1}
},
'space separated': {
type: 'single',
bind: {input: 'range', min: 0, max: 10, step: 1}
},
'dash-separated': {
type: 'single',
bind: {input: 'range', min: 0, max: 10, step: 1}
}
});

Expand All @@ -87,6 +95,8 @@ describe('Inputs Selection Transform', () => {
expect(inputs.has(selCmpts['nine'])).toBeTruthy();
expect(inputs.has(selCmpts['ten'])).toBeTruthy();
expect(inputs.has(selCmpts['eleven'])).toBeTruthy();
expect(inputs.has(selCmpts['space_separated'])).toBeTruthy();
expect(inputs.has(selCmpts['dash_separated'])).toBeTruthy();
});

it('adds widget binding for default projection', () => {
Expand Down

0 comments on commit 50429d3

Please sign in to comment.