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

refactor: move version getter to ElementMixin #2369

Merged
merged 4 commits into from
Aug 23, 2021
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ Prepare a new version for the `updateVersion` script by running the following co
export npm_config_bump=23.0.0-alpha0
```

Run the script to bump static version getters in every component:
Run the script to bump static version getters in `ElementMixin`, `Lumo` and `Material`:

```sh
node scripts/updateVersion.js
Expand Down
4 changes: 0 additions & 4 deletions packages/button/src/vaadin-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ class Button extends ControlStateMixin(ActiveMixin(ElementMixin(ThemableMixin(Po
return 'vaadin-button';
}

static get version() {
return '22.0.0-alpha1';
}

static get template() {
return html`
<style>
Expand Down
4 changes: 0 additions & 4 deletions packages/button/test/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ describe('vaadin-button', () => {
it('should have a valid static "is" getter', () => {
expect(customElements.get(tagName).is).to.equal(tagName);
});

it('should have a valid version number', () => {
expect(customElements.get(tagName).version).to.match(/^(\d+\.)?(\d+\.)?(\d+)(-(alpha|beta|rc)\d+)?$/);
});
});

describe('default', () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/custom-field/src/vaadin-custom-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ class CustomField extends FieldAriaMixin(LabelMixin(FocusMixin(ThemableMixin(Ele
return 'vaadin-custom-field';
}

static get version() {
return '22.0.0-alpha1';
}

static get template() {
return html`
<style>
Expand Down
4 changes: 0 additions & 4 deletions packages/email-field/src/vaadin-email-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ export class EmailField extends TextField {
return 'vaadin-email-field';
}

static get version() {
return '22.0.0-alpha1';
}

constructor() {
super();
this._setType('email');
Expand Down
4 changes: 0 additions & 4 deletions packages/integer-field/src/vaadin-integer-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export class IntegerField extends NumberField {
return 'vaadin-integer-field';
}

static get version() {
return '22.0.0-alpha1';
}

static get properties() {
return {
/**
Expand Down
4 changes: 0 additions & 4 deletions packages/number-field/src/vaadin-number-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ export class NumberField extends InputFieldMixin(InputSlotMixin(ThemableMixin(El
return 'vaadin-number-field';
}

static get version() {
return '22.0.0-alpha1';
}

static get template() {
return html`
<style include="vaadin-input-field-shared-styles">
Expand Down
4 changes: 0 additions & 4 deletions packages/password-field/src/vaadin-password-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export class PasswordField extends TextField {
return 'vaadin-password-field';
}

static get version() {
return '22.0.0-alpha1';
}

static get template() {
if (!memoizedTemplate) {
// Clone the superclass template
Expand Down
4 changes: 0 additions & 4 deletions packages/text-area/src/vaadin-text-area.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ export class TextArea extends CharLengthMixin(
return 'vaadin-text-area';
}

static get version() {
return '22.0.0-alpha1';
}

static get template() {
return html`
<style include="vaadin-input-field-shared-styles">
Expand Down
4 changes: 0 additions & 4 deletions packages/text-field/src/vaadin-text-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export class TextField extends TextFieldMixin(InputSlotMixin(ThemableMixin(Eleme
return 'vaadin-text-field';
}

static get version() {
return '22.0.0-alpha1';
}

static get template() {
return html`
<style include="vaadin-input-field-shared-styles">
Expand Down
4 changes: 0 additions & 4 deletions packages/vaadin-accordion/src/vaadin-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ class AccordionElement extends ThemableMixin(ElementMixin(PolymerElement)) {
return 'vaadin-accordion';
}

static get version() {
return '22.0.0-alpha1';
}

static get properties() {
return {
/**
Expand Down
21 changes: 14 additions & 7 deletions packages/vaadin-accordion/test/accordion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
arrowUpKeyDown,
keyboardEventFor,
homeKeyDown,
endKeyDown
endKeyDown,
nextFrame
} from '@vaadin/testing-helpers';

import '../vaadin-accordion.js';
Expand All @@ -19,7 +20,7 @@ describe('vaadin-accordion', () => {
return accordion.items[idx].focusElement;
}

beforeEach(() => {
beforeEach(async () => {
accordion = fixtureSync(`
<vaadin-accordion>
<vaadin-accordion-panel>
Expand All @@ -36,16 +37,22 @@ describe('vaadin-accordion', () => {
</vaadin-accordion-panel>
</vaadin-accordion>
`);
accordion._observer.flush();
await nextFrame();
});

describe('custom element definition', () => {
it('should define a custom element with proper tag name', () => {
expect(customElements.get('vaadin-accordion')).to.be.ok;
let tagName;

beforeEach(() => {
tagName = accordion.tagName.toLowerCase();
});

it('should be defined in custom element registry', () => {
expect(customElements.get(tagName)).to.be.ok;
vursen marked this conversation as resolved.
Show resolved Hide resolved
});

it('should have a valid version number', () => {
expect(accordion.constructor.version).to.match(/^(\d+\.)?(\d+\.)?(\d+)(-(alpha|beta|rc)\d+)?$/);
it('should have a valid static "is" getter', () => {
expect(customElements.get(tagName).is).to.equal(tagName);
});
});

Expand Down
4 changes: 0 additions & 4 deletions packages/vaadin-app-layout/src/vaadin-app-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,6 @@ class AppLayoutElement extends ElementMixin(ThemableMixin(mixinBehaviors([IronRe
return 'vaadin-app-layout';
}

static get version() {
return '22.0.0-alpha1';
}

static get properties() {
return {
/**
Expand Down
4 changes: 0 additions & 4 deletions packages/vaadin-app-layout/test/app-layout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ describe('vaadin-app-layout', () => {
it('should have a valid static "is" getter', () => {
expect(customElements.get(tagName).is).to.equal(tagName);
});

it('should have a valid version number', () => {
expect(customElements.get(tagName).version).to.match(/^(\d+\.)?(\d+\.)?(\d+)(-(alpha|beta|rc)\d+)?$/);
});
});

describe('primarySection', () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/vaadin-avatar/src/vaadin-avatar-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ class AvatarGroupElement extends ElementMixin(ThemableMixin(mixinBehaviors([Iron
return 'vaadin-avatar-group';
}

static get version() {
return '22.0.0-alpha1';
}

static get properties() {
return {
/**
Expand Down
4 changes: 0 additions & 4 deletions packages/vaadin-avatar/src/vaadin-avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ class AvatarElement extends ElementMixin(ThemableMixin(PolymerElement)) {
return 'vaadin-avatar';
}

static get version() {
return '22.0.0-alpha1';
}

static get properties() {
return {
/**
Expand Down
14 changes: 8 additions & 6 deletions packages/vaadin-avatar/test/avatar-group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ describe('avatar-group', () => {
});

describe('custom element definition', () => {
it('should be defined with correct tag name', () => {
expect(customElements.get('vaadin-avatar-group')).to.be.ok;
let tagName;

beforeEach(() => {
tagName = group.tagName.toLowerCase();
});

it('should not expose class name globally', () => {
expect(window.AvatarGroupElement).not.to.be.ok;
it('should be defined in custom element registry', () => {
expect(customElements.get(tagName)).to.be.ok;
});

it('should have a valid version number', () => {
expect(group.constructor.version).to.match(/^(\d+\.)?(\d+\.)?(\d+)(-(alpha|beta|rc)\d+)?$/);
it('should have a valid static "is" getter', () => {
expect(customElements.get(tagName).is).to.equal(tagName);
});
});

Expand Down
27 changes: 18 additions & 9 deletions packages/vaadin-avatar/test/avatar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@ describe('vaadin-avatar', () => {

beforeEach(() => {
avatar = fixtureSync('<vaadin-avatar></vaadin-avatar>');
imgElement = avatar.shadowRoot.querySelector('img');
iconElement = avatar.shadowRoot.querySelector('#avatar-icon');
abbrElement = avatar.shadowRoot.querySelector('#avatar-abbr');
});

describe('custom element definition', () => {
it('should be defined with correct tag name', () => {
expect(customElements.get('vaadin-avatar')).to.be.ok;
let tagName;

beforeEach(() => {
tagName = avatar.tagName.toLowerCase();
});

it('should not expose class name globally', () => {
expect(window.AvatarElement).not.to.be.ok;
it('should be defined in custom element registry', () => {
expect(customElements.get(tagName)).to.be.ok;
vursen marked this conversation as resolved.
Show resolved Hide resolved
});

it('should have a valid version number', () => {
expect(avatar.constructor.version).to.match(/^(\d+\.)?(\d+\.)?(\d+)(-(alpha|beta|rc)\d+)?$/);
it('should have a valid static "is" getter', () => {
expect(customElements.get(tagName).is).to.equal(tagName);
});
});

describe('properties', () => {
beforeEach(() => {
imgElement = avatar.shadowRoot.querySelector('img');
iconElement = avatar.shadowRoot.querySelector('#avatar-icon');
abbrElement = avatar.shadowRoot.querySelector('#avatar-abbr');
});

const validImageSrc =
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiI+PHBhdGggZmlsbD0iIzAyMDIwMSIgZD0iTTQ1NC40MjYgMzkyLjU4MmMtNS40MzktMTYuMzItMTUuMjk4LTMyLjc4Mi0yOS44MzktNDIuMzYyLTI3Ljk3OS0xOC41NzItNjAuNTc4LTI4LjQ3OS05Mi4wOTktMzkuMDg1LTcuNjA0LTIuNjY0LTE1LjMzLTUuNTY4LTIyLjI3OS05LjctNi4yMDQtMy42ODYtOC41MzMtMTEuMjQ2LTkuOTc0LTE3Ljg4Ni0uNjM2LTMuNTEyLTEuMDI2LTcuMTE2LTEuMjI4LTEwLjY2MSAyMi44NTctMzEuMjY3IDM4LjAxOS04Mi4yOTUgMzguMDE5LTEyNC4xMzYgMC02NS4yOTgtMzYuODk2LTgzLjQ5NS04Mi40MDItODMuNDk1LTQ1LjUxNSAwLTgyLjQwMyAxOC4xNy04Mi40MDMgODMuNDY4IDAgNDMuMzM4IDE2LjI1NSA5Ni41IDQwLjQ4OSAxMjcuMzgzLS4yMjEgMi40MzgtLjUxMSA0Ljg3Ni0uOTUgNy4zMDMtMS40NDQgNi42MzktMy43NyAxNC4wNTgtOS45NyAxNy43NDMtNi45NTcgNC4xMzMtMTQuNjgyIDYuNzU2LTIyLjI4NyA5LjQyLTMxLjUyMSAxMC42MDUtNjQuMTE5IDE5Ljk1Ny05Mi4wOTEgMzguNTI5LTE0LjU0OSA5LjU4LTI0LjQwMyAyNy4xNTktMjkuODM4IDQzLjQ3OS01LjU5NyAxNi45MzgtNy44ODYgMzcuOTE3LTcuNTQxIDU0LjkxN2g0MTEuOTMyYy4zNDgtMTYuOTk5LTEuOTQ2LTM3Ljk3OC03LjUzOS01NC45MTd6Ii8+PC9zdmc+Cg==';
const invalidImageSrc = 'thisisnotavalidimagesource';
Expand Down Expand Up @@ -196,6 +201,7 @@ describe('vaadin-avatar', () => {
beforeEach(() => {
sinon.stub(console, 'warn');
});

afterEach(() => {
console.warn.restore();
});
Expand Down Expand Up @@ -330,14 +336,17 @@ describe('vaadin-avatar', () => {
});

it('should set aria-hidden="true" on the img element', () => {
const imgElement = avatar.shadowRoot.querySelector('img');
expect(imgElement.getAttribute('aria-hidden')).to.equal('true');
});

it('should set aria-hidden="true" on the icon element', () => {
const iconElement = avatar.shadowRoot.querySelector('#avatar-icon');
expect(iconElement.getAttribute('aria-hidden')).to.equal('true');
});

it('should set aria-hidden="true" on the abbr element', () => {
const abbrElement = avatar.shadowRoot.querySelector('#avatar-abbr');
expect(abbrElement.getAttribute('aria-hidden')).to.equal('true');
});
});
Expand Down
4 changes: 0 additions & 4 deletions packages/vaadin-board/src/vaadin-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ class BoardElement extends ElementMixin(mixinBehaviors([IronResizableBehavior],
return 'vaadin-board';
}

static get version() {
return '22.0.0-alpha1';
}

/**
* @protected
*/
Expand Down
15 changes: 8 additions & 7 deletions packages/vaadin-board/test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ import { expect } from '@esm-bundle/chai';
import { fixtureSync } from '@vaadin/testing-helpers';
import '../vaadin-board.js';

describe('vaadin-details', () => {
let board;
describe('vaadin-board', () => {
let board, tagName;

beforeEach(() => {
board = fixtureSync('<vaadin-board></vaadin-board>');
tagName = board.tagName.toLowerCase();
});

it('should define a vaadin-board custom element', () => {
expect(customElements.get('vaadin-board')).to.be.ok;
expect(customElements.get(tagName)).to.be.ok;
});

it('should define a vaadin-board-row custom element', () => {
expect(customElements.get('vaadin-board-row')).to.be.ok;
it('should have a valid static "is" getter', () => {
expect(customElements.get(tagName).is).to.equal(tagName);
});

it('should have a valid version number', () => {
expect(board.constructor.version).to.match(/^(\d+\.)?(\d+\.)?(\d+)(-(alpha|beta|rc)\d+)?$/);
it('should define a vaadin-board-row custom element', () => {
expect(customElements.get('vaadin-board-row')).to.be.ok;
});
});
4 changes: 0 additions & 4 deletions packages/vaadin-button/src/vaadin-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ class ButtonElement extends ElementMixin(ControlStateMixin(ThemableMixin(Gesture
return 'vaadin-button';
}

static get version() {
return '22.0.0-alpha1';
}

ready() {
super.ready();

Expand Down
4 changes: 0 additions & 4 deletions packages/vaadin-button/test/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ describe('vaadin-button', () => {
label = vaadinButton.shadowRoot.querySelector('[part=label]');
});

it('should have a valid version number', () => {
expect(vaadinButton.constructor.version).to.match(/^(\d+\.)?(\d+\.)?(\d+)(-(alpha|beta|rc)\d+)?$/);
});

it('should define button label using light DOM', () => {
const children = FlattenedNodesObserver.getFlattenedNodes(label);
expect(children[1].textContent).to.be.equal('Vaadin ');
Expand Down
4 changes: 0 additions & 4 deletions packages/vaadin-charts/src/vaadin-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@ class ChartElement extends ElementMixin(ThemableMixin(PolymerElement)) {
return 'vaadin-chart';
}

static get version() {
return '22.0.0-alpha1';
}

/** @private */
static __callHighchartsFunction(functionName, redrawCharts) {
const functionToCall = Highcharts[functionName];
Expand Down
6 changes: 1 addition & 5 deletions packages/vaadin-charts/test/chart-element.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ describe('vaadin-chart', () => {
});

it('should have a valid static "is" getter', () => {
expect(chart.constructor.is).to.equal(tagName);
});

it('should have a valid version number', () => {
expect(chart.constructor.version).to.match(/^(\d+\.)?(\d+\.)?(\d+)(-(alpha|beta|rc)\d+)?$/);
expect(customElements.get(tagName).is).to.equal(tagName);
});
});

Expand Down
Loading