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

zjq undoVparent may cause error if detached / missing element

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 9.6.0
    • 9.6.0
    • None
    • Security Level: Jimmy

      Steps to Reproduce

      no reproducing scenario at the moment (original code unavailable), but happens during unbind workflow.

      Original scenario involve tree, possibly unloaded treeItems with popup / tooltips

      Current Result

      If undoVParent is called on a widget that doesn't currently have an associated dom element (ROD, etc), the el variable will be undefined:

      https://github.com/zkoss/zk/blob/v9.5.1.3/zk/src/archive/web/js/zk/dom.js#L1768

      This will cause the typeError:

      cannot read property z_vp of undefined.

      Expected Result

      check if el exists / vparent exists before executing

      Debug Information

      error happens at:

      https://github.com/zkoss/zk/blob/v9.5.1.3/zk/src/archive/web/js/zk/dom.js#L1769

       

      Workaround

       

      	<script><![CDATA[
      		zk.afterLoad("zk", function () {
      		    var _xzjq = {};
      		    zk.override(zjq.prototype, _xzjq, {
      		        undoVParent: function() {
      		        	var el = this.jq[0];
      	        		if(!this.hasVParent() || !el){
      	        			console.log("skip undoVparent")
      	        			return;
      	        		}
      					var result = _xzjq.undoVParent.apply(this, arguments);
      					return result;
      		        }
      		     });
      		});
      	]]></script>
      

            Leon03 Leon03
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: