I play with the Polymer-Project web component library from Google. I want to create a custom tag with the canvas element enabled and access it from the user element through javascript. but I just can't access it using document.querySelector or document.getElementById - any hint or experience with a similar problem is appreciated.
Here is my source:
<polymer-element name="sprite-canvas"> <template> <style> .leinwand { width:200px; height:200px; background-color: lightblue; } </style> <canvas class="leinwand" width="200" height="200"></canvas> </template> <script> Polymer('sprite-canvas', { leinwand : null, ready: function() { console.log(document.getElementsByTagName('canvas')); console.log(document.querySelector('.leinwand')); }, domReady: function() { console.log(document.getElementsByTagName('canvas')); console.log(document.querySelector('.leinwand')); }, detached: function() { }, }); </script>
The output of console.log always returns a NULL / empty collection, it does not matter in which part of the life cycle I am trying to invoke the canvas. Where is my mistake and what am I doing wrong?
Regards, Lupo
javascript html5-canvas canvas polymer shadow-dom
Lupo
source share