Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-2563

Menupopup widget parent sometimes becomes null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Normal Normal
    • None
    • 7.0.1
    • Components
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      1. visit the page with IE 10
      2. quickly right clicking to open context menu

      currently, we cannot reproduce it with local sample.

      Actual Result

      IE 10 throws a JS exception.

      SCRIPT5007: Unable to get property '$instanceof' of undefined or null reference
      zk.wpd, line 19703 character 11

      Debug Information

      Call stack

      > _getMenu, zul.menu.wpd, line 1187
      open, zul.menu.wpd, line 1323
      open, zk.wpd, line 27643
      invoke, zk.wpd, line 20207
      doProcess, zk.wpd, line 19187
      doCmdsNow, zk.wpd, line 19428
      _doCmds, zk.wpd, line 19668
      afterResponse, zk.wpd, line 19319
      onResponseReady, zk.wpd, line 19316

      Error Code

      p is null.

      zul.menu.Menupopup = zk.$extends(zul.wgt.Popup, {
      ...
      ( function () {
              function _getMenu(wgt) {
                     var p = wgt.parent;
                     return p.$instance of(zul.menu.Menu) ? p: null ;
             }
      ...
      }
      

      even we check null in _getMenu(), zk throws another exception in _rmActive() of zul.menu.Menupopup for wgt.parent is null.

      ...
      	_rmActive: function (wgt) {
      		if (wgt.parent.$instanceof(zul.menu.Menu)) {
      			wgt.parent.$class._rmActive(wgt.parent);
      		}
      	}
      

      As far, I only know. No matter where the exception happens, Menupopup's parent is always null.

      Workaround

      I apply the workaround below and the exception never happens.

      zul.wgt.Popup.prototype.afterCloseAnima_ = function (opts) {
          this.setVisible(false);
          
          var node = this.$n();
          zk(node).undoVParent();
          zWatch.fireDown('onVParent', this);
      
          this.setFloating_(false);
          if (opts && opts.sendOnOpen)
              this.fire('onOpen', {open:false});
          if (zk.ie < 11) { 
              this.replaceHTML(node); // remove setTimeout()
          }
          
          //remove extra CSS class
          jq(node).removeClass(this.$s('open'));
      };
      

            Jenkins Jenkins
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: