In polymer 1.0, I have a custom element.
startPlayer: function() {
console.log('yow');
this.playAnimation('entry');
this.show = { backButton: true};
youtubePlayer = this.$$('google-youtube');
//for replay
if (youtubePlayer.playbackstarted) {
youtubePlayer.play();
}
},
enableElement: function(e) {
document.body.style.overflow = "hidden";
this.show = { video: true};
setTimeout(this.startPlayer.bind(this), 0);
},
`setTimeout` correctly binds the `this` shadow scope and `this.playAnimation('entry')` and the following functions are available in `startPlayer`.
But with:
startPlayer: function() {
console.log('yow');
this.playAnimation('entry');
this.show = { backButton: true};
youtubePlayer = this.$$('google-youtube');
//for replay
if (youtubePlayer.playbackstarted) {
youtubePlayer.play();
}
},
enableElement: function(e) {
document.body.style.overflow = "hidden";
this.show = { video: true};
var bob = this.startPlayer.bind(this);
bob();
},
this `window` object `this` is binded instead of the shadow element scope. This means the shadow element functions are not available as `this.foo` but instead are only available as `this.videoPlayer.foo`. How can I bind `this` of the shadow scope without using `setTimeout`?