mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Core: Modified widget factory to prevent access to internal methods through the API (internal methods are any methods preceded by an underscore). Provides framework for #3188.
This commit is contained in:
parent
4705f5cc2e
commit
44140343f4
@ -38,12 +38,19 @@ $.widget = function(name, prototype) {
|
||||
var isMethodCall = (typeof options == 'string'),
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
// prevent calls to internal methods
|
||||
if (isMethodCall && options.substring(0, 1) == '_') {
|
||||
return this;
|
||||
}
|
||||
|
||||
// handle getter methods
|
||||
if (isMethodCall && getter(namespace, name, options)) {
|
||||
var instance = $.data(this[0], name);
|
||||
return (instance ? instance[options].apply(instance, args)
|
||||
: undefined);
|
||||
}
|
||||
|
||||
// handle initialization and non-getter methods
|
||||
return this.each(function() {
|
||||
var instance = $.data(this, name);
|
||||
if (isMethodCall && instance && $.isFunction(instance[options])) {
|
||||
|
Loading…
Reference in New Issue
Block a user