devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
49 lines (48 loc) • 1.86 kB
JavaScript
/**
* DevExtreme (esm/__internal/integration/jquery/component_registrator.js)
* Version: 25.2.7
* Build date: Tue May 05 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import {
componentRegistratorCallbacks
} from "../../core/m_component_registrator_callbacks";
import errors from "../../core/m_errors";
import jQuery from "jquery";
if (jQuery) {
const registerJQueryComponent = function(name, componentClass) {
jQuery.fn[name] = function(options) {
const isMemberInvoke = "string" === typeof options;
let result;
if (isMemberInvoke) {
const memberName = options;
const memberArgs = [].slice.call(arguments).slice(1);
this.each(function() {
const instance = componentClass.getInstance(this);
if (!instance) {
throw errors.Error("E0009", name)
}
const member = instance[memberName];
const memberValue = member.apply(instance, memberArgs);
if (void 0 === result) {
result = memberValue
}
})
} else {
this.each(function() {
const instance = componentClass.getInstance(this);
if (instance) {
instance.option(options)
} else {
new componentClass(this, options)
}
});
result = this
}
return result
}
};
componentRegistratorCallbacks.add(registerJQueryComponent)
}