Skip to content

Commit

Permalink
$.isFunction -> core/utils/type/isFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
mpreyskurantov committed Oct 29, 2024
1 parent 336b113 commit 0004a78
Show file tree
Hide file tree
Showing 30 changed files with 109 additions and 86 deletions.
4 changes: 3 additions & 1 deletion apps/demos/Demos/Charts/SignalRService/signalr-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
/// <param name="$" type="jQuery" />
"use strict";

var isFunction = function(val) { return typeof val === 'function'; };

if (typeof ($.signalR) !== "function") {
throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
}
Expand Down Expand Up @@ -52,7 +54,7 @@
if (hub.client.hasOwnProperty(memberKey)) {
memberValue = hub.client[memberKey];

if (!$.isFunction(memberValue)) {
if (!isFunction(memberValue)) {
// Not a client hub function
continue;
}
Expand Down
4 changes: 3 additions & 1 deletion apps/demos/Demos/DataGrid/SignalRService/signalr-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
/// <param name="$" type="jQuery" />
"use strict";

var isFunction = function(val) { return typeof val === 'function'; };

if (typeof ($.signalR) !== "function") {
throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
}
Expand Down Expand Up @@ -53,7 +55,7 @@
if (hub.client.hasOwnProperty(memberKey)) {
memberValue = hub.client[memberKey];

if (!$.isFunction(memberValue)) {
if (!isFunction(memberValue)) {
// Not a client hub function
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/testing/helpers/gridBaseMocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ module.exports = function($, gridCore, columnResizingReordering, domUtils, commo
if(options) {
if(options.initDefaultOptions) {
$.each(modules, function() {
if($.isFunction(this.defaultOptions)) {
if(typeUtils.isFunction(this.defaultOptions)) {
that.option(this.defaultOptions());
}
});
Expand Down
3 changes: 2 additions & 1 deletion packages/devextreme/testing/helpers/nativePointerMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
const isBoolean = function(val) { return typeof val === 'boolean'; };
const isObject = function(val) { return typeof val === 'object'; };
const isNumeric = function(val) { return typeof val === 'number'; };
const isFunction = function(val) { return typeof val === 'function'; };

const MOUSE_EVENTS = {
'click': 1,
Expand Down Expand Up @@ -329,7 +330,7 @@
if(!isNumeric(detail)) {
detail = 1;

if($.isFunction(document.createEvent)) {
if(isFunction(document.createEvent)) {

customEvent = document.createEvent('UIEvents');
customEvent.initUIEvent(type, bubbles, cancelable, view, detail);
Expand Down
14 changes: 8 additions & 6 deletions packages/devextreme/testing/helpers/vizMocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
require('viz/core/renderers/renderer'),
require('viz/core/errors_warnings'),
require('__internal/viz/core/m_base_widget'),
require('viz/core/base_widget.utils')
require('viz/core/base_widget.utils'),
require('core/utils/type')
);
});
} else {
Expand All @@ -32,10 +33,11 @@
DevExpress.require('viz/core/renderers/renderer'),
DevExpress.require('viz/core/errors_warnings'),
DevExpress.require('__internal/viz/core/m_base_widget'),
DevExpress.require('viz/core/base_widget.utils')
DevExpress.require('viz/core/base_widget.utils'),
DevExpress.require('core/utils/type')
);
}
}(window, function($, tooltipModule, titleModule, legendModule, axisModule, pointModule, Series, loadingIndicatorModule, exportMenuModule, rendererModule, errors, baseWidgetModule, baseWidgetUtils) {
}(window, function($, tooltipModule, titleModule, legendModule, axisModule, pointModule, Series, loadingIndicatorModule, exportMenuModule, rendererModule, errors, baseWidgetModule, baseWidgetUtils, typeUtils) {
/* global currentAssert, currentTest */

const Element = stubClass(rendererModule.SvgElement, {
Expand Down Expand Up @@ -94,7 +96,7 @@
return this;
},
getBBox: function() {
const template = $.isFunction(this.renderer.bBoxTemplate) ? this.renderer.bBoxTemplate.call(this) : this.renderer.bBoxTemplate;
const template = typeUtils.isFunction(this.renderer.bBoxTemplate) ? this.renderer.bBoxTemplate.call(this) : this.renderer.bBoxTemplate;
return $.extend({}, template);
},
dispose: function() {
Expand Down Expand Up @@ -219,9 +221,9 @@

this._resetStub = function(stub) {
$.each(stub, function(key, value) {
if($.isFunction(value && value.reset)) {
if(typeUtils.isFunction(value && value.reset)) {
value.reset();
$.isFunction(value.resetBehavior) && value.resetBehavior();
typeUtils.isFunction(value.resetBehavior) && value.resetBehavior();
} else {
stub[key] = undefined;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/devextreme/testing/helpers/widgetsIterator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(function(require) {
const $ = require('jquery');
const typeUtils = require('core/utils/type');

return function(namespace, parent, excluded) {
excluded = excluded || [];
Expand All @@ -12,7 +13,7 @@ define(function(require) {
return;
}

if($.isFunction(excluded) ? !excluded(componentName) : $.inArray(componentName, excluded) > -1) {
if(typeUtils.isFunction(excluded) ? !excluded(componentName) : $.inArray(componentName, excluded) > -1) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ define(function(require) {
assert.strictEqual(LOG.arguments[0], this.element[0], 'element');
assert.strictEqual(LOG.arguments[1], data, 'data');
assert.deepEqual(LOG.arguments[2], ['test1', 'test2'], 'namespaces');
assert.ok($.isFunction(LOG.arguments[3]), 'eventHandle');
assert.ok(isFunction(LOG.arguments[3]), 'eventHandle');
});

QUnit.test('\'teardown\' method', function(assert) {
Expand All @@ -105,7 +105,7 @@ define(function(require) {
assert.equal(LOG.arguments.length, 3, 'arguments count');
assert.strictEqual(LOG.arguments[0], this.element[0], 'element');
assert.deepEqual(LOG.arguments[1], ['test1', 'test2'], 'namespaces');
assert.ok($.isFunction(LOG.arguments[2]), 'eventHandle');
assert.ok(isFunction(LOG.arguments[2]), 'eventHandle');
});

QUnit.test('\'add\' method', function(assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import $ from 'jquery';
import ko from 'knockout';
import { DataSource } from 'data/data_source/data_source';
import { logger } from 'core/utils/console';
import { isFunction } from 'core/utils/type';
import fx from 'animation/fx';
import dataSourceAdapter from '__internal/grids/data_grid/m_data_source_adapter';
import dataGridMocks from '../../helpers/dataGridMocks.js';
Expand Down Expand Up @@ -51,7 +52,7 @@ const processColumnsForCompare = function(columns, parameterNames) {
delete this[propertyName];
}
} else {
if($.isFunction(this[propertyName])) {
if(isFunction(this[propertyName])) {
delete this[propertyName];
}
if(propertyName === 'filterOperations' ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import messageLocalization from 'localization/message';
import errors from 'core/errors';
import localization from 'localization';
import config from 'core/config';
import { isFunction } from 'core/utils/type';
import { logger } from 'core/utils/console';

import { generateDate } from '../../../helpers/dateHelper.js';
Expand All @@ -14,7 +15,7 @@ export default function() {
const checkModules = function(testName, namespace, methods) {
QUnit.test(testName, function(assert) {
$.each(methods, function(index, method) {
assert.ok($.isFunction(namespace[method]), method + ' method exists');
assert.ok(isFunction(namespace[method]), method + ' method exists');
});
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import registerEvent from 'events/core/event_registrator';
import eventsEngine from 'events/core/events_engine';
import registerEventCallbacks from 'events/core/event_registrator_callbacks';
import Class from 'core/class';
import { isFunction } from 'core/utils/type';

import eventHelper from '../../helpers/eventHelper.js';

Expand Down Expand Up @@ -87,7 +88,7 @@ QUnit.test('\'setup\' method', function(assert) {
assert.strictEqual(LOG.arguments[0], this.element[0], 'element');
assert.strictEqual(LOG.arguments[1], data, 'data');
assert.deepEqual(LOG.arguments[2], ['test1', 'test2'], 'namespaces');
assert.ok($.isFunction(LOG.arguments[3]), 'eventHandle');
assert.ok(isFunction(LOG.arguments[3]), 'eventHandle');
});

QUnit.test('\'teardown\' method', function(assert) {
Expand All @@ -103,7 +104,7 @@ QUnit.test('\'teardown\' method', function(assert) {
assert.equal(LOG.arguments.length, 3, 'arguments count');
assert.strictEqual(LOG.arguments[0], this.element[0], 'element');
assert.deepEqual(LOG.arguments[1], ['test1', 'test2'], 'namespaces');
assert.ok($.isFunction(LOG.arguments[2]), 'eventHandle');
assert.ok(isFunction(LOG.arguments[2]), 'eventHandle');
});

QUnit.test('\'add\' method', function(assert) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const $ = require('jquery');
const noop = require('core/utils/common').noop;
const typeUtils = require('core/utils/type');
const BaseStrategy = require('events/pointer/base');
const registerEvent = require('events/core/event_registrator');
const special = require('../../../helpers/eventHelper.js').special;
Expand Down Expand Up @@ -231,7 +232,7 @@ QUnit.test('event is triggered one time after refresh', function(assert) {
});

QUnit.test('pointer event base strategy should have \'setup\' implementation, because jQuery adds a browser event via addEventListener/attachEvent otherwise (T208653)', function(assert) {
assert.ok($.isFunction((new BaseStrategy('', '')).setup));
assert.ok(typeUtils.isFunction((new BaseStrategy('', '')).setup));
});

QUnit.test('pointer events should correctly unsubscribe events with target', function(assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const processColumnsForCompare = function(columns, parameterNames, ignoreParamet
delete this[propertyName];
}
} else {
if($.isFunction(this[propertyName])) {
if(isFunction(this[propertyName])) {
delete this[propertyName];
}
if([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6880,14 +6880,14 @@ QUnit.module('Filtering', {
assert.ok(Array.isArray(filter[0]), 'first argument is filter expression');
assert.strictEqual(filter[1], 'and', 'second argument is operation \'and\'');
assert.ok(Array.isArray(filter[2]), 'third argument is filter expression');
assert.ok($.isFunction(filter[0][0]), 'filter expression selector is function');
assert.ok(typeUtils.isFunction(filter[0][0]), 'filter expression selector is function');

filter = this.getCombinedFilter(true);
assert.ok(Array.isArray(filter[0]), 'first argument is filter expression');
assert.strictEqual(filter[1], 'and', 'second argument is operation \'and\'');
assert.ok(Array.isArray(filter[2]), 'third argument is filter expression');
assert.equal(filter.length, 3, 'filter expression + \'and\' + \'filter expression\'');
assert.ok(!$.isFunction(filter[2][0]), 'filter expression selector isn\'t function');
assert.ok(!typeUtils.isFunction(filter[2][0]), 'filter expression selector isn\'t function');
assert.strictEqual(filter[0][0], 'name', 'value of the selector');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,7 @@ QUnit.module('API methods', baseModuleConfig, () => {
let reloadResolved = false;
const d = dataGrid.refresh();

assert.ok($.isFunction(d.promise), 'type object is the Deferred');
assert.ok(typeUtils.isFunction(d.promise), 'type object is the Deferred');
d.done(function() {
reloadResolved = true;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import gridCoreUtils from '__internal/grids/grid_core/m_utils';
import $ from 'jquery';
import ArrayStore from 'data/array_store';
import { noop } from 'core/utils/common';
import { isFunction } from 'core/utils/type';
import ODataStore from 'data/odata/store';
import devices from 'core/devices';
import { DataSource } from 'data/data_source/data_source';
Expand Down Expand Up @@ -1764,7 +1765,7 @@ QUnit.module('Header Filter', {

// assert
assert.ok(list.option('searchEnabled'), 'list with search bar');
assert.ok($.isFunction(list.option('searchExpr')), 'expr is correct');
assert.ok(isFunction(list.option('searchExpr')), 'expr is correct');
assert.equal(list.option('searchTimeout'), 300, 'search timeout is assigned');
assert.equal(list.option('searchMode'), 'contains', 'search mode is default');
});
Expand Down Expand Up @@ -1803,7 +1804,7 @@ QUnit.module('Header Filter', {

// assert
assert.ok(list.option('searchEnabled'), 'list with search bar');
assert.ok($.isFunction(list.option('searchExpr')), 'expr is correct');
assert.ok(isFunction(list.option('searchExpr')), 'expr is correct');
assert.equal(list.option('searchTimeout'), 300, 'search timeout is assigned');
assert.equal(list.option('searchMode'), 'equals', 'search mode is assigned');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dataUtils from 'core/element_data';
import config from 'core/config';
import browser from 'core/utils/browser';
import errors from 'core/errors';
import { isRenderer } from 'core/utils/type';
import { isFunction, isRenderer } from 'core/utils/type';
import { normalizeKeyName } from 'events/utils/index';

import ArrayStore from 'data/array_store';
Expand Down Expand Up @@ -1566,15 +1566,15 @@ QUnit.module('options', {
const popup = $lookup.find('.' + POPUP_CLASS).dxPopup('instance');

let initialValue = popup.option('width');
if($.isFunction(initialValue)) {
if(isFunction(initialValue)) {
initialValue = initialValue();
}

instance.option('dropDownOptions.width', initialValue + 1);

instance.option('dropDownOptions.width', 'auto');
let autoValue = popup.option('width');
if($.isFunction(autoValue)) {
if(isFunction(autoValue)) {
autoValue = autoValue();
}

Expand All @@ -1600,15 +1600,15 @@ QUnit.module('options', {
const popup = $lookup.find('.' + POPUP_CLASS).dxPopup('instance');

let initialValue = popup.option('height');
if($.isFunction(initialValue)) {
if(isFunction(initialValue)) {
initialValue = initialValue();
}

instance.option('dropDownOptions.height', initialValue + 1);

instance.option('dropDownOptions.height', 'auto');
let autoValue = popup.option('height');
if($.isFunction(autoValue)) {
if(isFunction(autoValue)) {
autoValue = autoValue();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from 'jquery';
import { DataSource } from 'data/data_source/data_source';
import { isRenderer } from 'core/utils/type';
import { isFunction, isRenderer } from 'core/utils/type';
import { createTextElementHiddenCopy } from 'core/utils/dom';
import ajaxMock from '../../helpers/ajaxMock.js';
import config from 'core/config';
Expand Down Expand Up @@ -6819,7 +6819,7 @@ QUnit.module('performance', () => {
$item.trigger('dxclick');

const filter = load.lastCall.args[0].filter;
assert.ok($.isFunction(filter), 'filter is function');
assert.ok(isFunction(filter), 'filter is function');
});

QUnit.test('loadOptions.filter should be correct when user filter is also used', function(assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import '../../helpers/noIntl.js';

import $ from 'jquery';
import { isFunction } from 'core/utils/type';
import { PivotGridDataSource } from '__internal/grids/pivot_grid/data_source/m_data_source';

import executeAsyncMock from '../../helpers/executeAsyncMock.js';
Expand Down Expand Up @@ -79,7 +80,7 @@ QUnit.module('Chart Binding', {
const pivotGrid = createPivotGrid();

assert.ok(pivotGrid);
assert.ok($.isFunction(pivotGrid.bindChart));
assert.ok(isFunction(pivotGrid.bindChart));
});

QUnit.test('Call bind chart without arguments', function(assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fx from 'animation/fx';
import { DataSource } from 'data/data_source/data_source';

import { triggerHidingEvent, triggerShownEvent } from 'events/visibility_change';
import { isFunction } from 'core/utils/type';
import $ from 'jquery';
import { AppointmentDataProvider } from '__internal/scheduler/appointments/data_provider/m_appointment_data_provider';
import errors from 'ui/widget/ui.errors';
Expand Down Expand Up @@ -92,8 +93,8 @@ QUnit.module('Initialization', {
'allDay',
'recurrenceRule',
'recurrenceException'], function(_, field) {
assert.ok($.isFunction(dataAccessors.getter[field]), '\'' + field + '\' getter is OK');
assert.ok($.isFunction(dataAccessors.setter[field]), '\'' + field + '\' setter is OK');
assert.ok(isFunction(dataAccessors.getter[field]), '\'' + field + '\' getter is OK');
assert.ok(isFunction(dataAccessors.setter[field]), '\'' + field + '\' setter is OK');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ContextMenu from 'ui/context_menu';
import { addNamespace } from 'events/utils/index';
import contextMenuEvent from 'events/contextmenu';
import holdEvent from 'events/hold';
import { isRenderer } from 'core/utils/type';
import { isFunction, isRenderer } from 'core/utils/type';
import config from 'core/config';
import keyboardMock from '../../helpers/keyboardMock.js';
import ariaAccessibilityTestHelper from '../../helpers/ariaAccessibilityTestHelper.js';
Expand Down Expand Up @@ -1013,11 +1013,11 @@ QUnit.module('Showing and hiding context menu', moduleConfig, () => {

let d = instance.show();

assert.ok($.isFunction(d.promise), 'type object is the Deferred');
assert.ok(isFunction(d.promise), 'type object is the Deferred');

d = instance.hide();

assert.ok($.isFunction(d.promise), 'type object is the Deferred');
assert.ok(isFunction(d.promise), 'type object is the Deferred');
});

QUnit.test('overlay wrapper should have the same size as window (T1102095)', function(assert) {
Expand Down
Loading

0 comments on commit 0004a78

Please sign in to comment.