Skip to content

Commit fa590c3

Browse files
marker-daomarker dao ®
andauthored
SwatchContainer: Improve typing (#30781)
Co-authored-by: marker dao ® <[email protected]>
1 parent efd863e commit fa590c3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

packages/devextreme/js/__internal/core/utils/m_swatch_container.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
import type { dxElementWrapper } from '@js/core/renderer';
12
import $ from '@js/core/renderer';
23
import { value } from '@js/core/utils/view_port';
34

45
const SWATCH_CONTAINER_CLASS_PREFIX = 'dx-swatch-';
56

6-
const getSwatchContainer = (element) => {
7+
const getSwatchContainer = (
8+
element: Element | dxElementWrapper,
9+
): dxElementWrapper => {
710
const $element = $(element);
811
const swatchContainer = $element.closest(`[class^="${SWATCH_CONTAINER_CLASS_PREFIX}"], [class*=" ${SWATCH_CONTAINER_CLASS_PREFIX}"]`);
9-
const viewport = value();
10-
if (!swatchContainer.length) return viewport;
12+
const viewport: dxElementWrapper = value();
13+
14+
if (!swatchContainer.length) {
15+
return viewport;
16+
}
1117

1218
const swatchClassRegex = new RegExp(`(\\s|^)(${SWATCH_CONTAINER_CLASS_PREFIX}.*?)(\\s|$)`);
1319
const swatchClass = swatchContainer[0].className.match(swatchClassRegex)[2];

packages/devextreme/js/__internal/ui/overlay/m_overlay_position_controller.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ export class OverlayPositionController<
210210
this._properties.container = element;
211211
}
212212

213-
this._$markupContainer = element
214-
? $(element)
215-
: swatch.getSwatchContainer(this._$root);
213+
if (element) {
214+
this._$markupContainer = $(element);
215+
} else if (this._$root) {
216+
this._$markupContainer = swatch.getSwatchContainer(this._$root);
217+
}
216218

217219
this.updateVisualContainer(this._properties.visualContainer);
218220
}

0 commit comments

Comments
 (0)