2015年6月25日 星期四

WebDev: Learn how to Entry Member Features in Polymer Parts

I am engaged on a foolish Polymer undertaking proper now, which parses a Pokémon database and returns an image of a Pokémon, then speaks the creature’s identify over your audio system. This is the supply code for my undertaking. It is my first time utilizing Polymer, and I am definitely getting snagged in a number of spots. Most just lately, it was making an attempt to return member features of a Polymer object that I created. Took me endlessly to determine this out, so I needed to share it with you on this tutorial. Sidenote: it’s also possible to seek for my extra detailed write-up on Net Elements right here. The Fallacious Approach I’ve a Net Element which seems to be like this: 1 If I attempt to entry it by its ID…. 1 2 var temp = doc.querySelector(“#radial-button-template”); // returns However I can’t entry any of the perform it. They return “undefined”. So if I attempted this: 1 2 var temp = doc.querySelector(“#radial-button-template”); temp.getFirstElement // returns undefined Why is This Occurring? The rationale behind that is because of the Shadow DOM’s encapsulation. It’s each a present and a curse. On this case, I’m accessing the factor, and never the shadowRoot, which can expose the general public strategies […]

沒有留言: