intercellular / cell

A self-driving web app framework
https://www.celljs.org
MIT License
1.5k stars 94 forks source link

Initialize parent before children #156

Closed gliechtenstein closed 7 years ago

gliechtenstein commented 7 years ago

Initialize parent node before children.

This should fix the problem mentioned here https://github.com/intercellular/cell/issues/155

Previously $init was being called from the bottom up. So if the tree structure looked like:

A
  - B
  - C
    - D

The $init() execution order was:

  1. B.$init()
  2. D.$init()
  3. C.$init()
  4. A.$init()

because it was depth first search based. (See demo: https://jsfiddle.net/bnLw8htg/1/)

With this update now the order will be

  1. A.$init()
  2. B.$init()
  3. C.$init()
  4. D.$init()

(See demo: https://jsfiddle.net/bnLw8htg/2/)

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 84.04% when pulling 8894074f70da7756c8fce59231403ed5d7dc5f91 on senior_before_junior into 9ce2d50e447c2a6a4ead7480b93007bf25ff79b2 on develop.