$('<div></div>').appendTo('body').remove().accordion().remove();
ok(true, '.accordion() called on disconnected DOMElement - removed');
- $('<div></div>').accordion().accordion("foo").remove();
- ok(true, 'arbitrary method called after init');
-
var el = $('<div></div>').accordion();
var foo = el.accordion("option", "foo");
el.remove();
module("dialog: core");
-test("element types", function() {
- var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
- + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
- + ',acronym,code,samp,kbd,var,img,object,hr'
- + ',input,button,label,select,iframe').split(',');
-
- $.each(typeNames, function(i) {
- var typeName = typeNames[i];
- el = $(document.createElement(typeName)).appendTo('body');
- (typeName == 'table' && el.append("<tr><td>content</td></tr>"));
- el.dialog();
- ok(true, '$("<' + typeName + '/>").dialog()');
- el.dialog("destroy");
- el.remove();
- });
-});
-
test("title id", function() {
expect(3);
});
test("init", function() {
- expect(7);
+ expect(6);
$("<div></div>").appendTo('body').dialog().remove();
ok(true, '.dialog() called on element');
$('<div></div>').appendTo('body').remove().dialog().remove();
ok(true, '.dialog() called on disconnected DOMElement - removed');
- $('<div></div>').dialog().dialog("foo").remove();
- ok(true, 'arbitrary method called after init');
-
el = $('<div></div>').dialog();
var foo = el.dialog("option", "foo");
el.remove();
$('<div></div>').dialog().dialog("destroy").remove();
ok(true, '.dialog("destroy") called on disconnected DOMElement');
- $('<div></div>').dialog().dialog("destroy").dialog("foo").remove();
- ok(true, 'arbitrary method called after destroy');
-
var expected = $('<div></div>').dialog(),
actual = expected.dialog('destroy');
equals(actual, expected, 'destroy is chainable');
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
<script type="text/javascript" src="../../../external/qunit.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
+ <script type="text/javascript" src="../testsuite.js"></script>
<script type="text/javascript" src="slider_core.js"></script>
<script type="text/javascript" src="slider_defaults.js"></script>
module("slider: methods");
test("init", function() {
- expect(6);
+ expect(5);
$("<div></div>").appendTo('body').slider().remove();
ok(true, '.slider() called on element');
$('<div></div>').slider().remove();
ok(true, '.slider() called on disconnected DOMElement');
- $('<div></div>').slider().slider("foo").remove();
- ok(true, 'arbitrary method called after init');
-
var el = $('<div></div>').slider();
var foo = el.slider("option", "foo");
el.remove();
$('<div></div>').appendTo('body').remove().slider().slider("destroy").remove();
ok(true, '.slider("destroy") called on disconnected DOMElement');
- $('<div></div>').slider().slider("destroy").slider("foo").remove();
- ok(true, 'arbitrary method called after destroy');
-
var expected = $('<div></div>').slider(),
actual = expected.slider('destroy');
equals(actual, expected, 'destroy is chainable');
if ( isMethodCall ) {
this.each(function() {
- var instance = $.data( this, name ),
- methodValue = instance && $.isFunction( instance[options] ) ?
- instance[ options ].apply( instance, args ) :
- instance;
+ var instance = $.data( this, name );
+ if ( !instance ) {
+ throw "cannot call methods on " + name + " prior to initialization; " +
+ "attempted to call method '" + options + "'";
+ }
+ if ( !$.isFunction( instance[options] ) ) {
+ throw "no such method '" + options + "' for " + name + " widget instance";
+ }
+ var methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue;
return false;