Skip to content

Commit a8c41f0

Browse files
chore: postpone theme class attachments until first widget creation (DevExpress#29679)
1 parent f55b813 commit a8c41f0

10 files changed

+20
-4
lines changed
51 Bytes
Loading
64 Bytes
Loading
-1.04 KB
Loading
-1 KB
Loading
-1.13 KB
Loading
-1.01 KB
Loading
-108 Bytes
Loading
91 Bytes
Loading

packages/devextreme/js/ui/themes.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { getOuterHeight } from '../core/utils/size';
22
import devices from '../core/devices';
33
import domAdapter from '../core/dom_adapter';
44
import $ from '../core/renderer';
5-
import { Deferred } from '../core/utils/deferred';
5+
import { Deferred, when } from '../core/utils/deferred';
66
import { parseHTML } from '../core/utils/html_parser';
77
import { each } from '../core/utils/iterator';
88
import readyCallbacks from '../core/utils/ready_callbacks';
99
import { value as viewPortValue, changeCallback, originalViewPort } from '../core/utils/view_port';
1010
import { getWindow, hasWindow } from '../core/utils/window';
1111
import { themeReadyCallback } from './themes_callback';
12+
import { uiLayerInitialized } from '../__internal/core/utils/m_common';
1213
import errors from './widget/ui.errors';
1314
const window = getWindow();
1415
const ready = readyCallbacks.add;
@@ -278,7 +279,8 @@ function getCssClasses(themeName) {
278279
}
279280

280281
let themeClasses;
281-
export function attachCssClasses(element, themeName) {
282+
283+
function _attachCssClasses(element, themeName) {
282284
themeClasses = getCssClasses(themeName).join(' ');
283285
$(element).addClass(themeClasses);
284286

@@ -302,8 +304,16 @@ export function attachCssClasses(element, themeName) {
302304
activateHairlines();
303305
}
304306

307+
export function attachCssClasses(element, themeName) {
308+
when(uiLayerInitialized).done(() => {
309+
_attachCssClasses(element, themeName);
310+
});
311+
}
312+
305313
export function detachCssClasses(element) {
306-
$(element).removeClass(themeClasses);
314+
when(uiLayerInitialized).done(() => {
315+
$(element).removeClass(themeClasses);
316+
});
307317
}
308318

309319
function themeReady(callback) {

packages/devextreme/testing/tests/DevExpress.ui/themes.tests.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import $ from 'jquery';
44
import themes from 'ui/themes';
55
import viewPortUtils from 'core/utils/view_port';
6+
import { uiLayerInitialized } from '__internal/core/utils/m_common';
67

78
const viewPortChanged = viewPortUtils.changeCallback;
89

@@ -250,6 +251,7 @@ QUnit.module('dx-theme links', (hooks) => {
250251
let $frame;
251252
const frames = [];
252253
hooks.beforeEach(() => {
254+
uiLayerInitialized.resolve();
253255
themes.setDefaultTimeout(100);
254256
$frame = $('<iframe></iframe>').appendTo('body');
255257
frames.push($frame);
@@ -605,7 +607,11 @@ QUnit.module('dx-theme links', (hooks) => {
605607
});
606608
});
607609

608-
QUnit.module('misc', () => {
610+
QUnit.module('misc', (hooks) => {
611+
hooks.beforeEach(() => {
612+
uiLayerInitialized.resolve();
613+
});
614+
609615
const DX_HAIRLINES_CLASS = 'dx-hairlines';
610616

611617
test('attachCssClasses', function(assert) {

0 commit comments

Comments
 (0)