Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested non-cursor components fail because graft' relies on *cursor*' which is nil #167

Closed
the-kenny opened this issue Apr 21, 2014 · 3 comments

Comments

@the-kenny
Copy link

Since 0.6.0 nested non-cursor components fail because *cursor* is nil.

Using non-cursors like this might not be very intuitive, nevertheless I have a situation comparable to the following in my application:

(ns om-error.core
  (:require [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]))

(enable-console-print!)

(defn inner [[a b] owner]
  (reify
    om/IRender
    (render [this]
      (println "inner" om.core/*cursor*)
      (dom/div nil
               (dom/h1 nil a)
               (dom/h1 nil b)))))

(defn widget [data foo owner]
  (reify
    om/IRender
    (render [this]
      ;; *cursor* is nil because `data' isn't a cursor(?)
      (println "widget" om.core/*cursor*)
      ;; fails because the [data ...] part is wrapped by graft which
      ;; relies on *cursor*, which is nil here
      (om/build inner [data "non-cursor"]))))

(defn main [state owner]
  (reify
    om/IRender
    (render [this]
      (println "main" om.core/*cursor*)
      ;; :text is a string
      (om/build widget (:text state)))))

(om/root main {:text "Hello world!"}
         {:target (. js/document (getElementById "widget"))})

*cursor* is a valid cursor in main, nil in widget. This leads to an error when calling build for inner as om.core/graft relies on *cursor*.

@swannodette
Copy link
Member

Thanks for the report will look into it.

@swannodette
Copy link
Member

This ticket will be resolved by #135.

@swannodette
Copy link
Member

fixed in master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants