_listenFlex, _unlistenFlex declared on static member _ are used directly, cannot be overriden

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major
    • 10.1.0
    • Affects Version/s: 10.0.0, 10.0.1.1, 10.0.2
    • Component/s: None
    • Security Level: Jimmy
    • None

      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

            Assignee:
            jamson
            Reporter:
            MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: