aaronc / freactive

High-performance, pure Clojurescript, declarative DOM library
http://documentup.com/aaronc/freactive
Eclipse Public License 1.0
387 stars 27 forks source link

freactive does not support :style in hiccup like notation #18

Closed sveri closed 9 years ago

sveri commented 9 years ago

I tried this: [:div#success {:class "alert alert-success" :style "display:none"}] and it compiles without warnings but when I open the page I get this error:

Uncaught Error: Assert failed: (map? attr-value) dom.cljs:226bind_attrBANG dom.cljs:226(anonymous function) dom.cljs:456build_element dom.cljs:459append_child dom.cljs:278replace_or_append_child dom.cljs:289do_show_element dom.cljs:300transition_element dom.cljs:314append_childBANG dom.cljs:433append_childrenBANG dom.cljs:439(anonymous function) dom.cljs:458build_element dom.cljs:459append_child dom.cljs:278replace_or_append_child dom.cljs:289(anonymous function) dom.cljs:357append_deref_child dom.cljs:417append_childBANG dom.cljs:430append_childrenBANG dom.cljs:441append_childrenBANG dom.cljs:440(anonymous function) dom.cljs:458build_element dom.cljs:459append_child dom.cljs:278replace_or_append_child dom.cljs:289do_show_element dom.cljs:300transition_element dom.cljs:314append_childBANG dom.cljs:433append_childrenBANG dom.cljs:439(anonymous function) dom.cljs:458build_element dom.cljs:459append_child dom.cljs:278replace_or_append_child dom.cljs:289do_show_element dom.cljs:300transition_element dom.cljs:314append_childBANG dom.cljs:433mountBANG dom.cljs:466main core.cljs:22(anonymous function)

And: Uncaught TypeError: Cannot read property 'nodeType' of null dom.cljs:18dom_nodeQMARK dom.cljs:18get_element_spec dom.cljs:54get_transition dom.cljs:107animate dom.cljs:373render

aaronc commented 9 years ago

Hi sveri, so the way freactive supports :style is by supporting a map of properties. This allows one to do binding direct to style properties - which could be pretty useful for animation. The stack trace (which I agree is unreadable) is trying to tell you that the attribute value (attr-value) should be a map (therefore Assert failed: (map? attr-value)

Try this:

[:div#success {:class "alert alert-success" :style {:display "none"}}]
sveri commented 9 years ago

Thank you, that does the trick. I wonder if this is documented somewhere in the hiccup docu? I did not find anthing.

aaronc commented 9 years ago

Well this is documented for freactive. Hiccup probably does it the way you expected.

On Sunday, November 23, 2014, sveri notifications@github.com wrote:

Closed #18 https://github.com/aaronc/freactive/issues/18.

— Reply to this email directly or view it on GitHub https://github.com/aaronc/freactive/issues/18#event-197312453.

sveri commented 9 years ago

Sorry, I have been reading the docs like three times, but missed that obvious example.