太多 DOM 更新

Toomany DOM updates

link [https://ccamel.github.io/playground-binding.scala/index.html#playground-binding.scala/home] binding.scala 的演示很少 我在 chrome 中使用 DomListner 扩展来理解 dom 事件。 我发现每次互动都会触发数百个 DOM 事件。 例如,单击计算器按钮会导致 114 个事件。

  1. 这是性能问题吗?
  2. binding.scala 库是否需要性能改进?
  3. 使用binding.scala编写的代码是否需要优化?

这是预期的行为,因为您提到的 DEMO 明确地重新创建了锚元素。

根据 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

因此,在 here 处的 calc.bind 调用强制重新创建锚元素。


我创建 a pull request 来更改 class 属性,避免在 XHTML 文字之前调用 calc.bind