What is the difference between this. $ And that. $$ in Polymer?

I read the documentation again and again and I was out of luck. docs start explaining this. $ With an example, but then they don’t give an example of what it is. $$ does

As far as I understand this. $ will find something in my template with the ID I want. For example, I can use this. $. Test.textContent = "hey there"

But for that. $$ he just says "dynamically created nodes" - maybe someone can explain with an example what the difference is between static and dynamic created nodes and how to use it. $$ - Thanks in advance

+5
source share
1 answer

Polymer.dom(this.root).querySelector uses the shadow DOM API.

A polymer with a shadow DOM (default is 1.0) is not a fully polyfill shadow DOM.

To ensure that all Polymer features that are not supported by the browser are taken into account correctly (e.g., <content> projection) when using querySelector() ), you need to use the Polymer.dom(...) wrapper Polymer.dom(...) .

  • this.$ is the receiver that returns a static map from the element identifier to the element reference. Elements created by dom-repeat or hidden by dom-if or otherwise created dynamically are not included.

  • this.$$() is an abbreviated function for Polymer.dom(this.root).querySelector() and therefore takes into account dynamically created elements, since it actually queries the DOM at runtime.

+3
source

Source: https://habr.com/ru/post/1263645/


All Articles