jquery/jquery-ui — pull request #586 by scottgonzalez (2012-01-30 00:13:48+00:00)
Title: Allow redefining a widget after other widgets have interited from it

This allows a widget to be redefined (`$.widget( "foo.bar", $.foo.bar, { ... } )`) after other widgets have inherited from it and still have the behavior be what you'd expect. In theory this should never occur, since you should load your plugins in the correct order. However, in practice this will become more and more likely to occur as our inheritance chains become deeper and users continue to load the official files together, either from a custom download or a CDN.

The use case that brought this to my attention was creating an extension for the new interaction plugin. If an extension were written for interaction, it'd be likely that users would load files in this order:

```html

```

The changes in jquery.ui.widget.js are pretty heavily commented, so if you're interested in the way that this is accomplished, just read the source. It's probably the closest thing to magic that we have in jQuery UI :-)

This required me to change `_super()` and `_superApply()` to accept the name of the method again. This change was needed in order to track what level of the prototype chain we're in at any given time. I actually prefer this implementation for `_super()` because it doen't require wrapping all of the methods on the prototype and it just seems a whole lot cleaner.