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

dommy breaks when Polymer is in use #67

Closed
radix opened this issue Dec 13, 2013 · 9 comments
Closed

dommy breaks when Polymer is in use #67

radix opened this issue Dec 13, 2013 · 9 comments

Comments

@radix
Copy link

radix commented Dec 13, 2013

I have no idea whose fault this is, but I want to file the ticket so it's at least known. Whenever I have polymer enabled in Chrome, (dommy/append! (sel1 :body) "foo") fails, with the following error:

"Don't know how to make node from: #<[object HTMLBodyElement]>"

If I use (sel1 :#mybod) (or some other way to get the body), it works.

Maybe Polymer somehow changes the semantics of "document.body"?

To be specific, I'm only including Polymer's platform/platform.js in order to get this behavior.

@radix
Copy link
Author

radix commented Dec 13, 2013

  1. Verified on firefox as well
  2. I think I've traced it down as far as dommy.template.__GT_document_fragment(document.body) failing, but it's really hard for me to debug it further as I'm not very familiar with protocols and cljs yet.

Unfortunately neither chrome nor firefox are giving a traceback for this error, so it's really hard to track down.

@jeluard
Copy link

jeluard commented Dec 13, 2013

This might be due to how Polymer handle specially body as opposed to other elements. You probably won't have any issue with other selections (at least I don't here).

body normally has to be manually wrapped, see faq.

@radix
Copy link
Author

radix commented Jan 9, 2014

Sorry I never got back to you on this issue. So, the question is, whose responsibility is this incompatibility? Should Dommy work around it, or should this be filed as a bug against Polymer? Do you have any opinions on that?

@jeluard
Copy link

jeluard commented Jan 9, 2014

Good question. I don't think polymer will fix that as it's a deliberate trade-off for performance reason (I believe). On the other hand dommycan't reasonably implement a work around specific to polymer.

I guess your best option is not to use dommy to select document.body and relies on good old DOM:

(dommy/append! js/document.body "foo")

@cpetzold
Copy link
Contributor

Hmm, not sure why you're getting that issue as (sel1 :body) should just be expanding to js/document.body: https://github.com/Prismatic/dommy/blob/master/src/dommy/macros.clj#L70

@cpetzold
Copy link
Contributor

Ah sorry, I re-read your initial comment.. the issue is in append!, not sel1: https://github.com/Prismatic/dommy/blob/master/src/dommy/core.cljs#L74

The parent node in append! gets "coerced" to a node with template/->node-like. I wonder if it would be better if it was assumed that the parent is a valid dom node, instead of being looser. I'm not sure if anyone is taking advantage of it anyways..

@jeluard
Copy link

jeluard commented Feb 3, 2014

I believe this might help understanding the issue.
One theory could be that dommy somehow installs its own properties to a polymer wrapped element then later on access the non-wrapped version.

@jeluard
Copy link

jeluard commented Feb 15, 2014

FYI I got this issue and fixed it by using (.querySelector js/document "body") to select the body.

I don't think there is any other option when using polymer's polyfill as using document.body is not supported.

@cpetzold
Copy link
Contributor

Dommy no longer coerces nodes (see #85), and @jeluard's fix (using the native querySelector for body) seems reasonable for use with polymer.

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

3 participants