diff --git a/js/ui/drawer/ui.drawer.js b/js/ui/drawer/ui.drawer.js index df60f099b367..182ab50fd4fd 100644 --- a/js/ui/drawer/ui.drawer.js +++ b/js/ui/drawer/ui.drawer.js @@ -275,7 +275,7 @@ const Drawer = Widget.inherit({ }, getOverlayTarget() { - return this.option('target') || this._$wrapper; + return this._options.silent('target') || this._$wrapper; }, getOverlay() { diff --git a/js/ui/toolbar.js b/js/ui/toolbar.js index fe83596d007c..78fcf8f76b86 100644 --- a/js/ui/toolbar.js +++ b/js/ui/toolbar.js @@ -325,13 +325,6 @@ const Toolbar = ToolbarBase.inherit({ this._menuStrategy.widgetOption(name, value); }, - _setDeprecatedOptions() { - this.callBase(); - extend(this._deprecatedOptions, { - 'height': { since: '20.1', message: 'Functionality associated with this option is not intended for the Toolbar widget.' } - }); - }, - /** * @name dxToolbarMethods.registerKeyHandler * @publicName registerKeyHandler(key, handler) diff --git a/js/ui/toolbar/ui.toolbar.base.js b/js/ui/toolbar/ui.toolbar.base.js index f1646573c703..40b7475fd992 100644 --- a/js/ui/toolbar/ui.toolbar.base.js +++ b/js/ui/toolbar/ui.toolbar.base.js @@ -9,6 +9,7 @@ import { each } from '../../core/utils/iterator'; import AsyncCollectionWidget from '../collection/ui.collection_widget.async'; import Promise from '../../core/polyfills/promise'; import { BindableTemplate } from '../../core/templates/bindable_template'; +import errors from '../../core/errors'; import fx from '../../animation/fx'; const TOOLBAR_CLASS = 'dx-toolbar'; @@ -44,6 +45,10 @@ const ToolbarBase = AsyncCollectionWidget.inherit({ this._userOptions = options || {}; this.callBase(element, options); + + if('height' in this._userOptions) { + errors.log('W0001', this.NAME, 'height', '20.1', 'Functionality associated with this option is not intended for the Toolbar widget.'); + } }, _getSynchronizableOptionsForCreateComponent: function() { diff --git a/testing/tests/DevExpress.ui.widgets/drawer.tests.js b/testing/tests/DevExpress.ui.widgets/drawer.tests.js index dc046ade6a33..3882bbd79260 100644 --- a/testing/tests/DevExpress.ui.widgets/drawer.tests.js +++ b/testing/tests/DevExpress.ui.widgets/drawer.tests.js @@ -376,25 +376,44 @@ QUnit.module('Drawer behavior', () => { assert.ok($(instance._overlay.option('position').of).hasClass('dx-drawer-content'), 'target is ok'); }); - QUnit.test('show warning if deprecated \'target\' option is used', function(assert) { - sinon.spy(errors, 'log'); + ['shrink', 'overlap', 'push'].forEach((openedStateMode) => { + QUnit.test(`warnings for deprecated 'target' option, ${openedStateMode}, target: notInitialized`, function(assert) { + sinon.spy(errors, 'log'); - try { - $('#drawer').dxDrawer({ - openedStateMode: 'overlap', - target: '#someID' - }); + try { + $('#drawer').dxDrawer({ + openedStateMode: openedStateMode + }); - assert.deepEqual(errors.log.lastCall.args, [ - 'W0001', - 'dxDrawer', - 'target', - '20.1', - 'Functionality associated with this option is not intended for the Drawer widget.' - ], 'args of the log method'); - } finally { - errors.log.restore(); - } + assert.strictEqual(errors.log.callCount, 0, 'log.callCount'); + } finally { + errors.log.restore(); + } + }); + + [null, undefined, '#someID'].forEach((target) => { + QUnit.test(`warnings for deprecated 'target' option, openedStateMode: ${openedStateMode}, target: ${target}`, function(assert) { + sinon.spy(errors, 'log'); + + try { + $('#drawer').dxDrawer({ + openedStateMode: openedStateMode, + target: target + }); + + assert.strictEqual(errors.log.callCount, 1, 'log.callCount'); + assert.deepEqual(errors.log.firstCall.args, [ + 'W0001', + 'dxDrawer', + 'target', + '20.1', + 'Functionality associated with this option is not intended for the Drawer widget.' + ], 'args of the log method'); + } finally { + errors.log.restore(); + } + }); + }); }); QUnit.test('content() function', function(assert) { diff --git a/testing/tests/DevExpress.ui.widgets/toolbar.tests.js b/testing/tests/DevExpress.ui.widgets/toolbar.tests.js index 6305673336fd..acfcfc92b088 100644 --- a/testing/tests/DevExpress.ui.widgets/toolbar.tests.js +++ b/testing/tests/DevExpress.ui.widgets/toolbar.tests.js @@ -275,6 +275,42 @@ QUnit.module('render', { assert.ok(templateUsed); assert.equal(this.element.find('.custom-template').length, 1); }); + + QUnit.test('show warning if deprecated "height" option is used', function(assert) { + sinon.spy(errors, 'log'); + + try { + $('#toolbar').dxToolbar({ + items: [ { location: 'before', text: 'text1' } ], + height: 50 + }); + + assert.strictEqual(errors.log.callCount, 1, 'log.callCount'); + assert.deepEqual(errors.log.firstCall.args, [ + 'W0001', + 'dxToolbar', + 'height', + '20.1', + 'Functionality associated with this option is not intended for the Toolbar widget.' + ], 'args of the log method'); + } finally { + errors.log.restore(); + } + }); + + QUnit.test('Warning messages not displaying if deprecated "height" option not used', function(assert) { + sinon.spy(errors, 'log'); + + try { + $('#toolbar').dxToolbar({ + items: [ { location: 'before', text: 'text1' } ] + }); + + assert.strictEqual(errors.log.callCount, 0, 'log.callCount'); + } finally { + errors.log.restore(); + } + }); }); QUnit.module('toolbar with menu', { @@ -1572,22 +1608,5 @@ QUnit.module('Waiting fonts for material theme', { themes.isMaterial = origIsMaterial; }); - - QUnit.test('show warning if deprecated "height" option is used', function(assert) { - sinon.spy(errors, 'log'); - - $('#toolbar').dxToolbar({ - items: [ { location: 'before', text: 'text1' } ], - height: 50 - }); - - assert.deepEqual(errors.log.lastCall.args, [ - 'W0001', - 'dxToolbar', - 'height', - '20.1', - 'Functionality associated with this option is not intended for the Toolbar widget.' - ], 'args of the log method'); - }); });