Steps to Reproduce
Try to override _listenFlex, _unlistenFlex:
<script><![CDATA[ zk.afterLoad("zk", function () { var _x_ = {}; zk.override(zk.widget._, _x_, { _listenFlex(wgt) {
Current Result
Replaces the publicly visible reference to zk.widget._,listenFlex, but is not invoked by zk.Widget.prototype.bind or setHflex_, or other consumers, because they are using a direct reference to the original function, not a reference to the function located in the public member:
https://github.com/zkoss/zk/blob/7185169f3cb3814a8f9b7c7d3d9bde265c19a22f/zk/src/main/resources/web/js/zk/widget.ts#L1581-L1583
https://github.com/zkoss/zk/blob/7185169f3cb3814a8f9b7c7d3d9bde265c19a22f/zk/src/main/resources/web/js/zk/widget.ts#L1604-L1607
https://github.com/zkoss/zk/blob/7185169f3cb3814a8f9b7c7d3d9bde265c19a22f/zk/src/main/resources/web/js/zk/widget.ts#L3902-L3904
As a result, the only way to override listenFlex and _unlistenFlex is to override all consumers to replace the direct reference to _listenFlex by a reference to the publicly available zk.widget.._listenFlex
Expected Result
Overriding public members should cause the override to be used by consumers, not the unmodified original function
Debug Information
- Several class-level members are referred to directly by functions. This makes overrides difficult, as all consumers have to be replaced.
- Another example found during the same patch:
zk.Widget.prototype.setHflex makes a reference to zk.widget._.binds directly as _binds, which makes overriding the function more difficult, same issue. - please solve similar bugs in other widgets
Workaround
replace the entire set of functions using the class-level values
- relates to
-
ZK-4928 expose widget private functions and variables as public ones
-
- Closed
-