github github
  • Home
  • Pricing and Signup
  • Training
  • Gist
  • Blog
  • Login

jquery / jquery-ui

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Download Source
    • 1,082
    • 268
  • Source
  • Commits
  • Network (268)
  • Graphs
  • Tree: 1e28040

click here to add a description

click here to add a homepage

  • Switch Branches (8)
    • bind
    • devpreview
    • formcontrols
    • master
    • menu
    • panel
    • tooltip
    • widget-super
  • Switch Tags (22)
    • 1.9m2
    • 1.9m1
    • 1.8rc3
    • 1.8rc2
    • 1.8rc1
    • 1.8b1
    • 1.8a2
    • 1.8a1
    • 1.8.5
    • 1.8.4
    • 1.8.3
    • 1.8.2
    • 1.8.1
    • 1.8
    • 1.7
    • 1.6rc6
    • 1.6rc5
    • 1.6rc3
    • 1.6rc2
    • 1.6
    • 1.5.2
    • 1.5.1
  • Comments
  • Contributors
Sending Request…

The official jQuery user interface library. — Read more

  Cancel

http://jqueryui.com/

  Cancel
  • HTTP
  • Git Read-Only

This URL has Read+Write access

Widget: Throw errors when calling non-existent methods or methods on uninistantiated widgets. Fixes #5972 - Widget: Throw error for non-existent method calls.
scottgonzalez (author)
Fri Aug 27 11:48:17 -0700 2010
commit  1e28040cf358d0fe81ee
tree    721a02ecfcfb52284e0d
parent  52a052be79d21aa519cc
M tests/unit/accordion/accordion_methods.js 3 •••
M tests/unit/dialog/dialog_core.js 17 •••••
M tests/unit/dialog/dialog_methods.js 8 ••••
M tests/unit/slider/slider.html 1 •
M tests/unit/slider/slider_methods.js 8 ••••
M ui/jquery.ui.widget.js 13 ••••
Txt tests/unit/accordion/accordion_methods.js
  • View file @ 1e28040
... ...
@@ -18,9 +18,6 @@ test("init", function() {
18 18
   $('<div></div>').appendTo('body').remove().accordion().remove();
19 19
   ok(true, '.accordion() called on disconnected DOMElement - removed');
20 20
 
21  
-  $('<div></div>').accordion().accordion("foo").remove();
22  
-  ok(true, 'arbitrary method called after init');
23  
-
24 21
   var el = $('<div></div>').accordion();
25 22
   var foo = el.accordion("option", "foo");
26 23
   el.remove();
Txt tests/unit/dialog/dialog_core.js
  • View file @ 1e28040
... ...
@@ -88,23 +88,6 @@ function margin(el, side) {
88 88
 
89 89
 module("dialog: core");
90 90
 
91  
-test("element types", function() {
92  
-  var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
93  
-    + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
94  
-    + ',acronym,code,samp,kbd,var,img,object,hr'
95  
-    + ',input,button,label,select,iframe').split(',');
96  
-
97  
-  $.each(typeNames, function(i) {
98  
-    var typeName = typeNames[i];
99  
-    el = $(document.createElement(typeName)).appendTo('body');
100  
-    (typeName == 'table' && el.append("<tr><td>content</td></tr>"));
101  
-    el.dialog();
102  
-    ok(true, '$("&lt;' + typeName + '/&gt").dialog()');
103  
-    el.dialog("destroy");
104  
-    el.remove();
105  
-  });
106  
-});
107  
-
108 91
 test("title id", function() {
109 92
   expect(3);
110 93
 
Txt tests/unit/dialog/dialog_methods.js
  • View file @ 1e28040
... ...
@@ -10,7 +10,7 @@ module("dialog: methods", {
10 10
 });
11 11
 
12 12
 test("init", function() {
13  
-  expect(7);
  13
+  expect(6);
14 14
 
15 15
   $("<div></div>").appendTo('body').dialog().remove();
16 16
   ok(true, '.dialog() called on element');
... ...
@@ -24,9 +24,6 @@ test("init", function() {
24 24
   $('<div></div>').appendTo('body').remove().dialog().remove();
25 25
   ok(true, '.dialog() called on disconnected DOMElement - removed');
26 26
 
27  
-  $('<div></div>').dialog().dialog("foo").remove();
28  
-  ok(true, 'arbitrary method called after init');
29  
-
30 27
   el = $('<div></div>').dialog();
31 28
   var foo = el.dialog("option", "foo");
32 29
   el.remove();
... ...
@@ -46,9 +43,6 @@ test("destroy", function() {
46 43
   $('<div></div>').dialog().dialog("destroy").remove();
47 44
   ok(true, '.dialog("destroy") called on disconnected DOMElement');
48 45
 
49  
-  $('<div></div>').dialog().dialog("destroy").dialog("foo").remove();
50  
-  ok(true, 'arbitrary method called after destroy');
51  
-
52 46
   var expected = $('<div></div>').dialog(),
53 47
     actual = expected.dialog('destroy');
54 48
   equals(actual, expected, 'destroy is chainable');
Txt tests/unit/slider/slider.html
  • View file @ 1e28040
... ...
@@ -15,6 +15,7 @@
15 15
   <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
16 16
   <script type="text/javascript" src="../../../external/qunit.js"></script>
17 17
   <script type="text/javascript" src="../../jquery.simulate.js"></script>
  18
+  <script type="text/javascript" src="../testsuite.js"></script>
18 19
 
19 20
   <script type="text/javascript" src="slider_core.js"></script>
20 21
   <script type="text/javascript" src="slider_defaults.js"></script>
Txt tests/unit/slider/slider_methods.js
  • View file @ 1e28040
... ...
@@ -6,7 +6,7 @@
6 6
 module("slider: methods");
7 7
 
8 8
 test("init", function() {
9  
-  expect(6);
  9
+  expect(5);
10 10
 
11 11
   $("<div></div>").appendTo('body').slider().remove();
12 12
   ok(true, '.slider() called on element');
... ...
@@ -17,9 +17,6 @@ test("init", function() {
17 17
   $('<div></div>').slider().remove();
18 18
   ok(true, '.slider() called on disconnected DOMElement');
19 19
 
20  
-  $('<div></div>').slider().slider("foo").remove();
21  
-  ok(true, 'arbitrary method called after init');
22  
-
23 20
   var el = $('<div></div>').slider();
24 21
   var foo = el.slider("option", "foo");
25 22
   el.remove();
... ...
@@ -39,9 +36,6 @@ test("destroy", function() {
39 36
   $('<div></div>').appendTo('body').remove().slider().slider("destroy").remove();
40 37
   ok(true, '.slider("destroy") called on disconnected DOMElement');
41 38
 
42  
-  $('<div></div>').slider().slider("destroy").slider("foo").remove();
43  
-  ok(true, 'arbitrary method called after destroy');
44  
-
45 39
   var expected = $('<div></div>').slider(),
46 40
     actual = expected.slider('destroy');
47 41
   equals(actual, expected, 'destroy is chainable');
Txt ui/jquery.ui.widget.js
  • View file @ 1e28040
... ...
@@ -86,10 +86,15 @@ $.widget.bridge = function( name, object ) {
86 86
 
87 87
     if ( isMethodCall ) {
88 88
       this.each(function() {
89  
-        var instance = $.data( this, name ),
90  
-          methodValue = instance && $.isFunction( instance[options] ) ?
91  
-            instance[ options ].apply( instance, args ) :
92  
-            instance;
  89
+        var instance = $.data( this, name );
  90
+        if ( !instance ) {
  91
+          throw "cannot call methods on " + name + " prior to initialization; " +
  92
+            "attempted to call method '" + options + "'";
  93
+        }
  94
+        if ( !$.isFunction( instance[options] ) ) {
  95
+          throw "no such method '" + options + "' for " + name + " widget instance";
  96
+        }
  97
+        var methodValue = instance[ options ].apply( instance, args );
93 98
         if ( methodValue !== instance && methodValue !== undefined ) {
94 99
           returnValue = methodValue;
95 100
           return false;

2 notes on commit 1e28040

jzaefferer added a note to 1e28040 repo collab

Sun Aug 29 02:44:10 -0700 2010

I think it would be even more useful to do throw new Error("[message]") - that way the exception will contain fileName and lineNumber properties, making debugging even easier.

A quick Firebug test seems to confirm that, but I'm actually not sure about the exact semantics of throw and Error...

scottgonzalez added a note to 1e28040 repo collab

Mon Aug 30 05:40:20 -0700 2010

I did this for consistency with core. We could make this change and see about getting it into core as well.

Please log in to comment.
Dedicated Server Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
  • Blog
  • Support
  • Training
  • Job Board
  • Shop
  • Contact
  • API
  • Status
  • © 2010 GitHub Inc. All rights reserved.
  • Terms of Service
  • Privacy
  • Security
  • English
  • Deutsch
  • Français
  • 日本語
  • Português (BR)
  • Русский
  • 中文
  • See all available languages

Your current locale selection: English. Choose another?

  • English
  • Afrikaans
  • Català
  • Čeština
  • Deutsch
  • Español
  • Français
  • Hrvatski
  • Indonesia
  • Italiano
  • 日本語
  • Nederlands
  • Norsk
  • Polski
  • Português (BR)
  • Русский
  • Српски
  • Svenska
  • 中文

Keyboard Shortcuts

Site wide shortcuts

s
Focus site search
?
Bring up this help dialog

Commit list

j
Move selected down
k
Move selected up
t
Open tree
p
Open parent
c or o or enter
Open commit

Pull request list

j
Move selected down
k
Move selected up
o or enter
Open issue

Issues

j
Move selected down
k
Move selected up
x
Toggle select target
o or enter
Open issue
I
Mark selected as read
U
Mark selected as unread
e
Close selected
y
Remove selected from view
c
Create issue
l
Create label
i
Back to inbox
u
Back to issues
/
Focus issues search

Network Graph

← or h
Scroll left
→ or l
Scroll right
↑ or k
Scroll up
↓ or j
Scroll down
t
Toggle visibility of head labels
shift ← or shift h
Scroll all the way left
shift → or shift l
Scroll all the way right
shift ↑ or shift k
Scroll all the way up
shift ↓ or shift j
Scroll all the way down