aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-06-09 09:47:18 -0400
committerScott González <scott.gonzalez@gmail.com>2011-06-09 09:47:18 -0400
commit3dea8f1786e07b17458f4fecff1dbb8b04f79a2d (patch)
treeec00489ecbd19376c729e46e0817b53420cca57b /ui
parent7cd3d0a99ec4c92671aa637d322a41300786d879 (diff)
downloadjquery-ui-3dea8f1786e07b17458f4fecff1dbb8b04f79a2d.tar.gz
jquery-ui-3dea8f1786e07b17458f4fecff1dbb8b04f79a2d.zip
Widget: Added ability to get deep options. Fixes #7459 - Widget: Extend .option() to get partial nested options.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.widget.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 00bc07c4f..59d110b6a 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -133,7 +133,7 @@ $.widget.bridge = function( name, object ) {
}
var methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
- returnValue = methodValue.jquery ?
+ returnValue = methodValue && methodValue.jquery ?
returnValue.pushStack( methodValue.get() ) :
methodValue;
return false;
@@ -239,9 +239,6 @@ $.Widget.prototype = {
}
if ( typeof key === "string" ) {
- if ( value === undefined ) {
- return this.options[ key ];
- }
// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
options = {};
parts = key.split( "." );
@@ -252,8 +249,15 @@ $.Widget.prototype = {
curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
curOption = curOption[ parts[ i ] ];
}
- curOption[ parts.pop() ] = value;
+ key = parts.pop();
+ if ( value === undefined ) {
+ return curOption[ key ] === undefined ? null : curOption[ key ];
+ }
+ curOption[ key ] = value;
} else {
+ if ( value === undefined ) {
+ return this.options[ key ] === undefined ? null : this.options[ key ];
+ }
options[ key ] = value;
}
}