User Story
As an app developer, I often need to modify widget behavior in order to resolve a bug, create a workaround, or perform customization.
Some widget functions and private variables are not accessible due to being defined in an anonymous closure. Some of these functions can be replaced by also replacing every single occurrence of the functions in accessible functions using zk.override
However, some anonymous closures also contain anonymous fields.
For example:
https://github.com/zkoss/zk/blob/v9.1.0/zk/src/archive/web/js/zk/drag.js#L20-L24
These attributes are used by multiple functions in the anonymous closure:
https://github.com/zkoss/zk/blob/v9.1.0/zk/src/archive/web/js/zk/drag.js#L89
Window.js contains many private functions, usually when we customize a window widget, we need to copy lots of private functions
This then means that in order to make any change to these functions, the only viable way is to replace the entire javascript file, which is more complex, and is a potential issue source during an upgrade.
Using overrides with a super call is more robust, and doesn't need to be manually merged later.
In addition, since the client-side code is moving to typescript in more recent ZK versions, the complexity and user-maintainability of replacing the full JS files increase, as the client code needs to be compiled before deployment. This also adds complexity to the upgrade process.
Acceptance Criteria
Every widget class using the anonymous closure to declare functions should move these functions to the already existing static holder located at widget.$class._staticFn()
https://github.com/zkoss/zk/blob/v9.1.0/zk/src/archive/web/js/zk/drag.js#L800
This should have the same resource cost (as the functions will exist per class, rather than per instance in both cases) and makes these functions accessible for override at runtime, allowing zk.override to be used on them.
Details
- relates to
-
ZK-5802 _listenFlex, _unlistenFlex declared on static member _ are used directly, cannot be overriden
-
- Closed
-