Skip to content

Commit bd7f11d

Browse files
committed
add individual flag for each property
1 parent 4246f98 commit bd7f11d

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

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

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
77
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
88

9+
let spacingDeprecationNotified = false;
10+
let labelWidthDeprecationNotified = false;
11+
let labelSpacingDeprecationNotified = false;
12+
913
/**
1014
* @polymerMixin
1115
*/
@@ -46,32 +50,30 @@ export const FormItemMixin = (superClass) =>
4650
ready() {
4751
super.ready();
4852

49-
if (!this.constructor.__isDeprecationWarningShown) {
50-
const computedStyle = getComputedStyle(this);
53+
const computedStyle = getComputedStyle(this);
54+
const spacing = computedStyle.getPropertyValue('--vaadin-form-item-row-spacing');
55+
const labelWidth = computedStyle.getPropertyValue('--vaadin-form-item-label-width');
56+
const labelSpacing = computedStyle.getPropertyValue('--vaadin-form-item-label-spacing');
5157

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-
}
58+
if (!spacingDeprecationNotified && spacing !== '' && parseInt(spacing) !== 0) {
59+
console.warn(
60+
'`--vaadin-form-item-row-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-row-spacing` on <vaadin-form-layout> instead.',
61+
);
62+
spacingDeprecationNotified = true;
63+
}
5964

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-
}
65+
if (!labelWidthDeprecationNotified && labelWidth !== '' && parseInt(labelWidth) !== 0) {
66+
console.warn(
67+
'`--vaadin-form-item-label-width` is deprecated since 24.7. Use `--vaadin-form-layout-label-width` on <vaadin-form-layout> instead.',
68+
);
69+
labelWidthDeprecationNotified = true;
70+
}
6771

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-
}
72+
if (!labelSpacingDeprecationNotified && labelSpacing !== '' && parseInt(labelSpacing) !== 0) {
73+
console.warn(
74+
'`--vaadin-form-item-label-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-label-spacing` on <vaadin-form-layout> instead.',
75+
);
76+
labelSpacingDeprecationNotified = true;
7577
}
7678
}
7779

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ 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 { FormItem } from '../src/vaadin-form-item.js';
87

98
function estimateEffectiveColumnCount(layout) {
109
const offsets = [...layout.children]
@@ -139,7 +138,6 @@ describe('form layout', () => {
139138
});
140139

141140
afterEach(() => {
142-
FormItem.__isDeprecationWarningShown = false;
143141
console.warn.restore();
144142
});
145143

0 commit comments

Comments
 (0)