Skip to content

Commit 4246f98

Browse files
committed
revert flag
1 parent 0d89e51 commit 4246f98

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

packages/form-layout/src/vaadin-form-item-mixin.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,32 @@ export const FormItemMixin = (superClass) =>
4646
ready() {
4747
super.ready();
4848

49-
const computedStyle = getComputedStyle(this);
50-
51-
const spacing = computedStyle.getPropertyValue('--vaadin-form-item-row-spacing');
52-
if (spacing !== '' && parseInt(spacing) !== 0) {
53-
console.warn(
54-
'`--vaadin-form-item-row-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-row-spacing` on <vaadin-form-layout> instead.',
55-
);
56-
}
49+
if (!this.constructor.__isDeprecationWarningShown) {
50+
const computedStyle = getComputedStyle(this);
51+
52+
const spacing = computedStyle.getPropertyValue('--vaadin-form-item-row-spacing');
53+
if (spacing !== '' && parseInt(spacing) !== 0) {
54+
console.warn(
55+
'`--vaadin-form-item-row-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-row-spacing` on <vaadin-form-layout> instead.',
56+
);
57+
this.constructor.__isDeprecationWarningShown = true;
58+
}
5759

58-
const labelWidth = computedStyle.getPropertyValue('--vaadin-form-item-label-width');
59-
if (labelWidth !== '' && parseInt(labelWidth) !== 0) {
60-
console.warn(
61-
'`--vaadin-form-item-label-width` is deprecated since 24.7. Use `--vaadin-form-layout-label-width` on <vaadin-form-layout> instead.',
62-
);
63-
}
60+
const labelWidth = computedStyle.getPropertyValue('--vaadin-form-item-label-width');
61+
if (labelWidth !== '' && parseInt(labelWidth) !== 0) {
62+
console.warn(
63+
'`--vaadin-form-item-label-width` is deprecated since 24.7. Use `--vaadin-form-layout-label-width` on <vaadin-form-layout> instead.',
64+
);
65+
this.constructor.__isDeprecationWarningShown = true;
66+
}
6467

65-
const labelSpacing = computedStyle.getPropertyValue('--vaadin-form-item-label-spacing');
66-
if (labelSpacing !== '' && parseInt(labelSpacing) !== 0) {
67-
console.warn(
68-
'`--vaadin-form-item-label-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-label-spacing` on <vaadin-form-layout> instead.',
69-
);
68+
const labelSpacing = computedStyle.getPropertyValue('--vaadin-form-item-label-spacing');
69+
if (labelSpacing !== '' && parseInt(labelSpacing) !== 0) {
70+
console.warn(
71+
'`--vaadin-form-item-label-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-label-spacing` on <vaadin-form-layout> instead.',
72+
);
73+
this.constructor.__isDeprecationWarningShown = true;
74+
}
7075
}
7176
}
7277

packages/form-layout/test/form-layout.test.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import sinon from 'sinon';
44
import '@vaadin/text-field/vaadin-text-field.js';
55
import '../src/vaadin-form-layout.js';
66
import '../src/vaadin-form-item.js';
7-
import '@polymer/polymer/lib/elements/dom-repeat.js';
7+
import { FormItem } from '../src/vaadin-form-item.js';
88

99
function estimateEffectiveColumnCount(layout) {
1010
const offsets = [...layout.children]
@@ -139,6 +139,7 @@ describe('form layout', () => {
139139
});
140140

141141
afterEach(() => {
142+
FormItem.__isDeprecationWarningShown = false;
142143
console.warn.restore();
143144
});
144145

@@ -154,27 +155,36 @@ describe('form layout', () => {
154155
expect(getComputedStyle(item).getPropertyValue('--vaadin-form-item-row-spacing')).to.be.empty;
155156
});
156157

157-
it('should warn when adding form-item with deprecated --vaadin-form-item-label-width', () => {
158-
const item = document.createElement('vaadin-form-item');
159-
item.style.setProperty('--vaadin-form-item-label-width', '100px');
160-
layout.appendChild(item);
161-
expect(console.warn.calledOnce).to.be.true;
158+
it('should warn once when adding form items with deprecated --vaadin-form-item-label-width', () => {
159+
for (let i = 0; i < 2; i++) {
160+
const item = document.createElement('vaadin-form-item');
161+
item.style.setProperty('--vaadin-form-item-label-width', '100px');
162+
layout.appendChild(item);
163+
}
164+
165+
expect(console.warn).to.be.calledOnce;
162166
expect(console.warn.args[0][0]).to.contain('`--vaadin-form-item-label-width` is deprecated');
163167
});
164168

165-
it('should warn when adding form-item with deprecated --vaadin-form-item-label-spacing', () => {
166-
const item = document.createElement('vaadin-form-item');
167-
item.style.setProperty('--vaadin-form-item-label-spacing', '8px');
168-
layout.appendChild(item);
169-
expect(console.warn.calledOnce).to.be.true;
169+
it('should warn once when adding form items with deprecated --vaadin-form-item-label-spacing', () => {
170+
for (let i = 0; i < 2; i++) {
171+
const item = document.createElement('vaadin-form-item');
172+
item.style.setProperty('--vaadin-form-item-label-spacing', '8px');
173+
layout.appendChild(item);
174+
}
175+
176+
expect(console.warn).to.be.calledOnce;
170177
expect(console.warn.args[0][0]).to.contain('`--vaadin-form-item-label-spacing` is deprecated');
171178
});
172179

173-
it('should warn when adding form-item with deprecated --vaadin-form-item-row-spacing', () => {
174-
const item = document.createElement('vaadin-form-item');
175-
item.style.setProperty('--vaadin-form-item-row-spacing', '8px');
176-
layout.appendChild(item);
177-
expect(console.warn.calledOnce).to.be.true;
180+
it('should warn when adding form items with deprecated --vaadin-form-item-row-spacing', () => {
181+
for (let i = 0; i < 2; i++) {
182+
const item = document.createElement('vaadin-form-item');
183+
item.style.setProperty('--vaadin-form-item-row-spacing', '8px');
184+
layout.appendChild(item);
185+
}
186+
187+
expect(console.warn).to.be.calledOnce;
178188
expect(console.warn.args[0][0]).to.contain('`--vaadin-form-item-row-spacing` is deprecated');
179189
});
180190

0 commit comments

Comments
 (0)