Skip to content

Commit

Permalink
fix: dynamic classes only now functional (#4780)
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-chase authored and emyarod committed Nov 28, 2019
1 parent 9d51071 commit c170f74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/icons-vue/tasks/__tests__/createIconComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,23 @@ describe('createIconComponent', () => {
expect(node.classList.contains(dynamicClass)).toBe(true);
});

it('should support dynamic classes only', async () => {
const dynamicClass = 'bar';
const node = render({
components: {
[MockIconComponent.name]: MockIconComponent,
},
data() {
return {
myDynamicClass: dynamicClass,
};
},
template: `<MockIcon v-bind:class="myDynamicClass" />`,
});

expect(node.classList.contains(dynamicClass)).toBe(true);
});

it('should be focusable if aria-label and tabindex is used', async () => {
const label = 'custom-label';
const node = render({
Expand Down
1 change: 1 addition & 0 deletions packages/icons-vue/tasks/createIconComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default {
};
}
if (data.class) {
svgData.class = svgData.class || {}; // may be no static class
svgData.class[data.class] = true;
}
return createElement('svg', svgData, [
Expand Down

0 comments on commit c170f74

Please sign in to comment.