UI Tabs (and other UI components): Fail silently on error? Please discuss.
Hi all,
I was thinking about tweaking UI Tabs to be a little more robust. Have
a look for example on the API methods invocation code as it is now
(quite similiar to all the other UI modules):
return this.each(function() {
if (method) {
var tabs = $.data(this, 'ui-tabs');
tabs[method].apply(tabs, args);
} else
new $.ui.tabs(this, args[0] || {});
});
Now if the matched element has no tabs instance attached as data the
line
tabs[method].apply(tabs, args);
will throw a nice error. It's easy to (accidently) match an element
and try to apply a tabs method to it. I wonder if we should keep the
error to indicate that this error actually was a bug on the coder's
side (e.g. leave everything as it is now) or if we should provide a
more meaningful error message via try/catch or if we just eat the
error silently... the last option would at least allow some other
JavaScript on the page still being executed. That's why I tend towars
this solution.
Any advise appreciated.
--Klaus