Uploaded image for project: 'ZK CKeditor'
  1. ZK CKeditor
  2. ZKCK-32

CKeditor onVParent, _isChildOf(wgt) doesn't have an escape condition

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 4.7.0.0
    • 4.4.6.3
    • Security Level: Jimmy
    • None

      steps to reproduce

      http://zkfiddle.org/sample/32ovgu2/1-ckeditor-memory-leak
      Click the add editor button
      After the editor flicker in and out: press the popup button

      actual result

      NPE thrown in JS, current operation stopped, popup don't open

      expected result

      unbound editor is ignored, current operation continues, popup opens

      debug info

      CKeditor listener zWatch onVParent checks for ancestor from the target of VParent.
      In a complex case with tabbox / load on demand a CKeditor may be instanciated, but not bound to DOM when triggering VParent.
      This cause _isChildOf to find a null parent at the top of the unbound widget branch, and throw an exception.

      root cause

      while() loop in _isChildOf doesn't have an escape condition if the ckeditor is not currently part of a page.

      Workaround

      zk.afterLoad('ckez', function() {
      	var xCKeditor = {};
      	zk.override(ckez.CKeditor.prototype, xCKeditor ,{
      		_isChildOf: function(wgt) {
      			var p = this.parent;
      			if (p) {
      				do {
      					if (p == wgt)
      						return true;
      					p = p.parent;
      				} while (p != wgt.desktop && p != null);
      			}
      			return false;
      		}
      	});//zk.override
      });//zk/afterLoad
      

            Unassigned Unassigned
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: