Skip to content

Commit

Permalink
add individual flag for each property
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Feb 18, 2025
1 parent 4246f98 commit bd7f11d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
48 changes: 25 additions & 23 deletions packages/form-layout/src/vaadin-form-item-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';

let spacingDeprecationNotified = false;
let labelWidthDeprecationNotified = false;
let labelSpacingDeprecationNotified = false;

/**
* @polymerMixin
*/
Expand Down Expand Up @@ -46,32 +50,30 @@ export const FormItemMixin = (superClass) =>
ready() {
super.ready();

if (!this.constructor.__isDeprecationWarningShown) {
const computedStyle = getComputedStyle(this);
const computedStyle = getComputedStyle(this);
const spacing = computedStyle.getPropertyValue('--vaadin-form-item-row-spacing');
const labelWidth = computedStyle.getPropertyValue('--vaadin-form-item-label-width');
const labelSpacing = computedStyle.getPropertyValue('--vaadin-form-item-label-spacing');

const spacing = computedStyle.getPropertyValue('--vaadin-form-item-row-spacing');
if (spacing !== '' && parseInt(spacing) !== 0) {
console.warn(
'`--vaadin-form-item-row-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-row-spacing` on <vaadin-form-layout> instead.',
);
this.constructor.__isDeprecationWarningShown = true;
}
if (!spacingDeprecationNotified && spacing !== '' && parseInt(spacing) !== 0) {
console.warn(
'`--vaadin-form-item-row-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-row-spacing` on <vaadin-form-layout> instead.',
);
spacingDeprecationNotified = true;
}

const labelWidth = computedStyle.getPropertyValue('--vaadin-form-item-label-width');
if (labelWidth !== '' && parseInt(labelWidth) !== 0) {
console.warn(
'`--vaadin-form-item-label-width` is deprecated since 24.7. Use `--vaadin-form-layout-label-width` on <vaadin-form-layout> instead.',
);
this.constructor.__isDeprecationWarningShown = true;
}
if (!labelWidthDeprecationNotified && labelWidth !== '' && parseInt(labelWidth) !== 0) {
console.warn(
'`--vaadin-form-item-label-width` is deprecated since 24.7. Use `--vaadin-form-layout-label-width` on <vaadin-form-layout> instead.',
);
labelWidthDeprecationNotified = true;
}

const labelSpacing = computedStyle.getPropertyValue('--vaadin-form-item-label-spacing');
if (labelSpacing !== '' && parseInt(labelSpacing) !== 0) {
console.warn(
'`--vaadin-form-item-label-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-label-spacing` on <vaadin-form-layout> instead.',
);
this.constructor.__isDeprecationWarningShown = true;
}
if (!labelSpacingDeprecationNotified && labelSpacing !== '' && parseInt(labelSpacing) !== 0) {
console.warn(
'`--vaadin-form-item-label-spacing` is deprecated since 24.7. Use `--vaadin-form-layout-label-spacing` on <vaadin-form-layout> instead.',
);
labelSpacingDeprecationNotified = true;
}
}

Expand Down
2 changes: 0 additions & 2 deletions packages/form-layout/test/form-layout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import sinon from 'sinon';
import '@vaadin/text-field/vaadin-text-field.js';
import '../src/vaadin-form-layout.js';
import '../src/vaadin-form-item.js';
import { FormItem } from '../src/vaadin-form-item.js';

function estimateEffectiveColumnCount(layout) {
const offsets = [...layout.children]
Expand Down Expand Up @@ -139,7 +138,6 @@ describe('form layout', () => {
});

afterEach(() => {
FormItem.__isDeprecationWarningShown = false;
console.warn.restore();
});

Expand Down

0 comments on commit bd7f11d

Please sign in to comment.