I guess the first step is to see if its possible to get the React backing
object (owner) from a given DOM node. Since they all have a reactid
attribute, I imagine its possible to query React to get the React object.
You'll have to check out the React documentation.
You _could_ also hack your own lookup mechanism, by either walking the
component tree, or by maintaining a reactid to owner map. Its probably not
the best idea though :)

Once you have the React object, it really depends on what you mean by
"component":

If you mean the (fn [props owner opts] ...) function, or the object
returned by reify, then I don't know of any way to get these.
On the other hand, when you have the owner, you can get access to quite a
few things:

   - (aget owner "state" "__om_id") ; internal id, it looks like
   - (aget owner "state" "__om_state") ; component local state
   - (aget owner "props" "__om_cursor") ; cursor passed to the component
   - (aget owner "props" "__om_app_state") ; cursor-less app state
   - (aget owner "props" "__om_shared") ; shared state
   - ...and more. Take a look in the Chrome React Dev Tools plugin.



On 1 June 2014 18:00, Paul Butcher <[email protected]> wrote:

> Given an Om component, I can find the associated DOM node with
> om/get-node. Is there a mechanism to go the other way (i.e. given a DOM
> node, find the associated Om component)?
>
> Why do I need this? I’m working with selection ranges -
> window.getSelection() returns the first and last DOM nodes contained within
> the selection and I’d like to work out which components they correspond to.
>
> --
> paul.butcher->msgCount++
>
> Silverstone, Brands Hatch, Donington Park...
> Who says I have a one track mind?
>
> http://www.paulbutcher.com/
> LinkedIn: http://www.linkedin.com/in/paulbutcher
> Skype: paulrabutcher
>
> Author of Seven Concurrency Models in Seven Weeks: When Threads Unravel
> http://pragprog.com/book/pb7con
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>



On 1 June 2014 18:00, Paul Butcher <[email protected]> wrote:

> Given an Om component, I can find the associated DOM node with
> om/get-node. Is there a mechanism to go the other way (i.e. given a DOM
> node, find the associated Om component)?
>
> Why do I need this? I’m working with selection ranges -
> window.getSelection() returns the first and last DOM nodes contained within
> the selection and I’d like to work out which components they correspond to.
>
> --
> paul.butcher->msgCount++
>
> Silverstone, Brands Hatch, Donington Park...
> Who says I have a one track mind?
>
> http://www.paulbutcher.com/
> LinkedIn: http://www.linkedin.com/in/paulbutcher
> Skype: paulrabutcher
>
> Author of Seven Concurrency Models in Seven Weeks: When Threads Unravel
> http://pragprog.com/book/pb7con
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to