#8997 closed feature (wontfix)
Implementation of private methods
Reported by: | sievlev | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | none |
Component: | ui.widget | Version: | 1.10.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In current implementation of widgets it's easy to accidentally overload an internal methods.
For example, I can create an own _createButtons() method in my widget inherited from $.ui.dialog. As a result I will corrupt internal routines in $.ui.dialog widget.
I suggest to implement a real private methods to avoid possible conflicts. For simplicity reasons I suggest to expand naming conventions. Like in python or glibc all methods started with two underscore symbols will be treated as a private methods. To call a private method you will have to use a special call similar to _super.
See https://github.com/jquery/jquery-ui/pull/889 for details.
Change History (3)
comment:1 Changed 11 years ago by
Component: | ui.core → ui.widget |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
comment:2 Changed 11 years ago by
So I can safely override the undocumented methods and use them in any way, isn't it?
As I understand you I can have an own version of _createButtons in my dialog?
comment:3 Changed 11 years ago by
No you can't. Our widgets are generally not designed for inheritance, so if you extend something, you have to know what you're doing. There are a few exceptions like the _renderItem method in autocomplete, which is specifically intended for overriding. There is definitely more work to be done on documentation: https://github.com/jquery/api.jqueryui.com/issues/20
This isn't going to happen. Everything is exposed and we like it that way.