stathissideris / dali

dali is a Clojure library for representing, exporting and manipulating the SVG graphics format.
291 stars 16 forks source link

Referring to layout tags with one child from other layouts fails #6

Open stathissideris opened 8 years ago

stathissideris commented 8 years ago

Example:

(-> [:dali/page

     [:dali/stack
      {:id :a}
      [:text {} "A"]]

     [:dali/stack
      {:id :b}
      [:text {} "B"]]

     [:dali/connect
      {:from :a
       :to   :b}]]
    dali.syntax/dali->ixml
    dali.layout/resolve-layout)
stathissideris commented 8 years ago

When there is a layout tag with more than one child, the layout tag is converted to a tag and it works as expected. When you have a layout tag with a single child, dali promotes the child one level up and the layout tag is removed completely. Layout happens in "eval order" so in this case, the two stack tags are laid out first, the IDs get lost because of the promotion, and then connect is unable to find them and throws an exception.