Skip to content
Permalink
Browse files

Core: Modified widget factory to prevent access to internal methods t…

…hrough the API (internal methods are any methods preceded by an underscore). Provides framework for #3188.
  • Loading branch information
scottgonzalez committed Aug 16, 2008
1 parent 4705f5c commit 44140343f489842ec9ca92b072601bf7de7b4abe
Showing with 7 additions and 0 deletions.
  1. +7 −0 ui/ui.core.js
@@ -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])) {

0 comments on commit 4414034

Please sign in to comment.
You can’t perform that action at this time.