Sir Robert
Sir Robert

Reputation: 4946

ClojureScript/Om: Rendered HTML is missing attributes

I have a dead simple ClojureScript/Om application. It seems a little broken.

This is the core file:

(ns demo.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [goog.events :as events]
            [cljs.core.async :as async :refer [>! <! put! chan]]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [goog.events.EventType :as EventType]
            [clojure.string :as string]))

(defn layout
  [app owner]
  (reify
    om/IRender
    (render [_]
      (dom/div {:id "some-id"} "Pumpkin"))))

(defn main []
  (om/root
    layout
    {}
    {:target (. js/document (getElementById "app"))}))

It renders this HTML:

<div id="app">
    <div data-reactid=".0">Pumpkin</div>
</div>

Why doesn't the div have the id #some-id?

Upvotes: 1

Views: 349

Answers (1)

Andrew Marshall
Andrew Marshall

Reputation: 96934

You need to use the #js {} reader literal to specify a JS object rather than a plain-old map:

(dom/div #js {:id "some-id"} "Pumpkin")

This is elaborated a bit in the Om Tutorial.

Upvotes: 4

Related Questions