-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Further wrap Polymer.dom(elem).children in Polymer.dom
#2186
Comments
Polymer.dom
Here is a Sneaky hack that lets me do this by wrapping a I don't know much about the performance impact of this, I wouldn't be surprised if this defeats the whole point of Shady DOM. I'd love to have someone review this piece of code. |
We have an experimental layer in https://github.com/PolymerLabs/polymer-experiments/ that patches the DOM traversal API's (parent/children/childNodes, etc.) where needed for this exact case (interacting with other 3rd-party libs that don't know about See https://github.com/PolymerLabs/polymer-experiments/blob/master/patch-dom.html#L12-L21 You basically just need to put this after your <link rel="import" href="bower_components/polymer.html">
<link rel="import" href="bower_components/polymer-experiments/patch-dom.html"> Note, this may have negative performance implications (at the cost of more interoperability), and for the time being we definitely want users who are creating reusable components for others to consume to continue using We are continuing to work on better framework interoperability, so watch this space. |
BIG 👍 |
I was able to work around this for my purposes with virtual-dom using a little more code than the gist above. I think I will avoid patch-dom.html since it is experimental and a lot of code I don't completely understand. Thanks @kevinpschaaf for the help though :) I'll look forward to better interoperability. |
When you do
Polymer.dom(elem).children
, an array of light DOM children is obtained, but the elements are not further wrapped inPolymer.dom
. I think this is a missed opportunity to completely mimic Shadow DOM-style tree scoping. A function that takes a root node and looks up a node down the tree will have to now be aware of wrapping all the children withPolymer.dom
. (Same goes for functions that might use.parentNode
,.firstChild
and so on...)Specifically the current behavior makes interop with DOM libraries such as virtual-dom more complicated than it should be (see discussion at Matt-Esch/virtual-dom#296).
Are there some arguments against this?
Thanks!
The text was updated successfully, but these errors were encountered: