Toomany DOM updates

北城余情 提交于 2019-12-12 19:20:30

问题


The link [https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/home] has few demos of binding.scala I have used DomListner extension in chrome to understand the dom events. I found for each interaction there are hundreds of DOM events fired. For example one click on calculator button results in 114 events.

  1. It this a performance issue ?
  2. Does binding.scala library need performance improvements ?
  3. Does the code written using binding.scala need optimization ?


回答1:


It's the expected behavior, because the DEMO that you mentioned recreated anchor elements, explicitly.

According to the Scaladoc for bind method:

Each time the value changes, in the current @dom method, all code after the current bind expression will be re-evaluated

As a result, the calc.bind call at here forces recreating the anchor element.


I created a pull request to change the class attribute instead, by avoiding the calc.bind call before XHTML literals.



来源:https://stackoverflow.com/questions/48024292/toomany-dom-updates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!