Skip to content

Commit 404a476

Browse files
committed
Revert "jQuery.widget: Document that instance can be called on any element to determine whether it is a widget. Fixes #77."
This reverts commit cde5d57.
1 parent 0726190 commit 404a476

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

entries/jQuery.widget.xml

+3-16
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,17 @@
8787

8888
<h3>Instance</h3>
8989

90-
<p>The widget's instance can be retrieved from a given element using the <a href="#method-instance"><code>instance()</code></a> method.</p>
90+
<p>The widget's instance can be retrieved from a given element using the <a href="#method-instance">instance method</a>.</p>
9191

9292
<pre><code>
9393
$( "#elem" ).progressbar( "instance" );
9494
</code></pre>
9595

96-
<p>If the <code>instance()</code> method is called on an element that is not associated with the widget, <code>undefined</code> is returned.</p>
97-
98-
<pre><code>
99-
$( "#not-a-progressbar" ).progressbar( "instance" ); // undefined
100-
</code></pre>
101-
102-
<p>The instance is stored using <a href="http://api.jquery.com/jQuery.data/"><code>jQuery.data()</code></a> with the widget's full name as the key. Therefore, the <a href="/data-selector/"><code>:data</code></a> selector can also determine whether an element has a given widget bound to it.</p>
96+
<p>The instance is stored using <a href="http://api.jquery.com/jQuery.data/"><code>jQuery.data()</code></a> with the widget's full name as the key. Therefore, you can use the <a href="/data-selector"><code>:data</code></a> selector to determine whether an element has a given widget bound to it.</p>
10397

10498
<pre><code>
10599
$( "#elem" ).is( ":data( 'ui-progressbar' )" ); // true
106-
$( "#elem" ).is( ":data( 'ui-draggable' )" ); // false
107-
</code></pre>
108-
109-
<p>Unlike <code>instance()</code>, <code>:data</code> can be used even if the widget being tested for has not loaded.</p>
110-
111-
<pre><code>
112-
$( "#elem" ).nonExistentWidget( "instance" ); // TypeError
113-
$( "#elem" ).is( ":data( 'ui-nonExistentWidget' )" ); // false
100+
$( "#elem" ).is( ":data( 'ui-draggable' )" ); //false
114101
</code></pre>
115102

116103
<p>You can also use <code>:data</code> to get a list of all elements that are instances of a given widget.</p>

includes/widget-method-instance.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?xml version="1.0"?>
2-
<method name="instance" return="Object">
2+
<method name="instance">
33
<desc>
4-
<p>Retrieves the <placeholder name="name"/>'s instance object. If the element does not have an associated instance, <code>undefined</code> is returned.</p>
5-
6-
<p>Unlike other widget methods, <code>instance()</code> is safe to call on any element after the <placeholder name="name"/> plugin has loaded.</p>
4+
Retrieves the <placeholder name="name"/>'s instance object.
75
</desc>
86
</method>

0 commit comments

Comments
 (0)