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

Treeitems removed by ROD after receiving onOpen still try to render, cause issues if accessing DOM

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 9.6.0
    • 8.5.1, 9.5.1.2
    • Components
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      Run fiddle

      https://zkfiddle.org/sample/1u2u7ai/5-Another-new-ZK-fiddle

      Click button to open both nodes at the same time

      Current Result

      JS error:
      1 Errors
       
      Failed to process
      setAttr
      Cannot read property 'checked' of null (TypeError)
       

      zk.wpd:44276 Uncaught (in promise) TypeError: Cannot read property 'checked' of null
          at init.bind_ (zk.wpd:44276)
          at init.bind_ (za11y.wpd:10)
          at init.bindChildren_ (zk.wpd:23546)
          at init.bind_ (zk.wpd:23509)
          at init.bind_ (za11y.wpd:5)
          at init.$supers (zk.wpd:12886)
          at init.bind_ (zul.sel.wpd:5715)
          at init.bind_ (za11y.wpd:104)
          at init.bindChildren_ (zk.wpd:23546)
          at init.bind_ (zk.wpd:23509)
      bind_	@	zk.wpd:44276
      bind_	@	za11y.wpd:10
      bindChildren_	@	zk.wpd:23546
      bind_	@	zk.wpd:23509
      bind_	@	za11y.wpd:5
      $supers	@	zk.wpd:12886
      bind_	@	zul.sel.wpd:5715
      bind_	@	za11y.wpd:104
      bindChildren_	@	zk.wpd:23546
      bind_	@	zk.wpd:23509
      bind_	@	za11y.wpd:5
      bind_	@	za11y.wpd:103
      bindChildren_	@	zk.wpd:23546
      bind_	@	zk.wpd:23509
      bind_	@	za11y.wpd:5
      bind_	@	za11y.wpd:94
      bind	@	zk.wpd:23427
      insertChildHTML_	@	zul.sel.wpd:4777
      insertChildHTML_	@	zk.wpd:54236
      _rodRender	@	zk.wpd:54085
      _renderItem	@	zk.wpd:54110
      setOpen	@	zk.wpd:54130
      _set2	@	zk.wpd:12126
      setter.func	@	zk.wpd:21706
      zk.Widget.zk.$extends.set	@	zk.wpd:21734
      setAttr	@	zk.wpd:30272
      doProcess	@	zk.wpd:28692
      doCmdsNow	@	zk.wpd:28791
      _doCmds	@	zk.wpd:29155
      afterResponse	@	zk.wpd:29662
      _onResponseReady	@	zk.wpd:29517
      (anonymous)	@	zk.wpd:28767
      Promise.then (async)		
      (anonymous)	@	zk.wpd:28765
      Promise.then (async)		
      ajaxSendNow	@	zk.wpd:28764
      sendNow	@	zk.wpd:29383
      (anonymous)	@	zk.wpd:28734
      setTimeout (async)		
      ajaxSend2	@	zk.wpd:28734
      ajaxSend	@	zk.wpd:28728
      send	@	zk.wpd:29031
      sendAU_	@	zk.wpd:24243
      fireX	@	zk.wpd:24181
      doClick_	@	zk.wpd:43525
      _doEvt	@	zk.wpd:27369
      (anonymous)	@	zk.wpd:27565
      dispatch	@	zk.wpd:5614
      elemData.handle	@	zk.wpd:5418
      

       

      Expected Result

       No error

       

      Debug Information

      Caused by the checkbox located inside the target treeitem's child accessing the DOM (.$n()) while the widget is no longer in the DOM 

       

      Order of events causing this situation:

      • Both 1st level nodes (first block and target) are rendered closed.
      • First block contains enough children to push the target node over the ROD limit
      • Since both nodes are created closed, they are both initially rendered. (both in the ROD viewport)
      • When both nodes are opened, they both receive setOpen before their children are rendered, so the target node is "on screen" while initially receiving the command.
      • When the first block renders its children, it pushed target out of the rendered node limit, but target has already done setOpen and has started rendering its own content.
      • Since the node is no longer in the DOM, if a descendant of the target Treeitem tries to access DOM, it will fail. Other methods may also be unstable due to ROD / rendering uncertainty.

      Workaround

       Disable Tree ROD with 

          <custom-attributes org.zkoss.zul.tree.initRodSize="-1"/>

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

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day
                1d