Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only add vaadin-tab elements to items #151

Merged
merged 2 commits into from
Jan 23, 2020
Merged
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
6 changes: 5 additions & 1 deletion src/vaadin-tabs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { customElement } from 'lit-element';
import { TabsBase } from './vaadin-tabs-base';
import { TabsMixin } from './vaadin-tabs-mixin';
import './vaadin-tab';
import { VaadinTab } from './vaadin-tab';

/**
* `<vaadin-tabs>` is a Web Component for easy switching between different views.
Expand All @@ -22,6 +22,10 @@ export class VaadinTabs extends TabsMixin(TabsBase) {
static get version() {
return '4.0.0-alpha1';
}

protected _filterItems() {
return Array.from(this.querySelectorAll(VaadinTab.is));
}
}

declare global {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/tabs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('tabs', () => {
<vaadin-tab>Tab two</vaadin-tab>
<vaadin-tab>Tab three</vaadin-tab>
<vaadin-tab>Tab four</vaadin-tab>
<span>&nbsp;</span>
<vaadin-tab>
<a>Tab five</a>
</vaadin-tab>
Expand Down Expand Up @@ -59,6 +60,15 @@ describe('tabs', () => {
});
});

describe('items', () => {
it('should only add vaadin-tab components to items', () => {
expect(tabs.items.length).to.equal(5);
tabs.items.forEach(item => {
expect(item.tagName.toLowerCase()).to.equal('vaadin-tab');
});
});
});

['horizontal', 'vertical'].forEach(orientation => {
describe(`${orientation} orientation`, () => {
beforeEach(async () => {
Expand Down