Skip to content

Commit

Permalink
fix: lint issues from #5440 (#5446)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored Aug 23, 2023
1 parent 01ab11a commit c98e176
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions __tests__/integration/api-chart-on-component-click.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ describe('chart.on', () => {
await finished;
const [fired, resolve] = createPromise();
chart.on(`legend-category-item-marker:${ChartEvent.CLICK}`, resolve);
dispatchFirstShapeEvent(canvas, 'legend-category-item-marker', 'click', { detail: 1 });
dispatchFirstShapeEvent(canvas, 'legend-category-item-marker', 'click', {
detail: 1,
});
await fired;
});

it('chart.on("legend-category-item-label:click", callback) should emit events', async () => {
await finished;
const [fired, resolve] = createPromise();
chart.on(`legend-category-item-label:${ChartEvent.CLICK}`, resolve);
dispatchFirstShapeEvent(canvas, 'legend-category-item-label', 'click', { detail: 1 });
dispatchFirstShapeEvent(canvas, 'legend-category-item-label', 'click', {
detail: 1,
});
await fired;
});

Expand Down
8 changes: 4 additions & 4 deletions __tests__/plots/api/chart-on-component-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const componentNames = [
// tick
'axis-tick-item',
// axis label
'axis-label-item'
]
'axis-label-item',
];

export function chartOnComponentClick(context) {
const { container, canvas } = context;
Expand Down Expand Up @@ -47,9 +47,9 @@ export function chartOnComponentClick(context) {

chart.on('component:click', () => console.log('click component'));

componentNames.forEach(name => {
componentNames.forEach((name) => {
chart.on(`${name}:click`, () => console.log(`click ${name}`));
})
});

const finished = chart.render();

Expand Down
6 changes: 3 additions & 3 deletions src/interaction/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ function maybeRoot(node, rootOf) {

// For extended component
function maybeComponentRoot(node) {
return maybeRoot(node, node => node.className === 'component');
return maybeRoot(node, (node) => node.className === 'component');
}

// For extended shape.
function maybeElementRoot(node) {
return maybeRoot(node, node => node.className === 'element');
return maybeRoot(node, (node) => node.className === 'element');
}

function bubblesEvent(eventType, view, emitter, predicate = (event) => true) {
Expand Down Expand Up @@ -64,7 +64,7 @@ function bubblesEvent(eventType, view, emitter, predicate = (event) => true) {
emitter.emit(`element:${eventType}`, e1);
emitter.emit(`${markType}:${eventType}`, e1);
} else {
const e1 = {...e, nativeEvent: true };
const e1 = { ...e, nativeEvent: true };
emitter.emit(`component:${eventType}`, e1);
emitter.emit(`${className}:${eventType}`, e1);
}
Expand Down

0 comments on commit c98e176

Please sign in to comment.