I defined a component with polymer like this:
CONTENT
I wrote simple helper in TypeScript to solve this problem:
class DomUtils {
public static getShadowElementById(id: string):any {
try {
// Try to get it by simple id in case of browser doesn't support shadow DOM
var element = $("#" + id);
if (element.length <= 0) {
// Support Chrome browser
element = $("body /deep/ #" + id);
}
return element;
} catch (error) {
console.log("Error: " + error + ", while trying to get shadow element with id: " + id);
return null;
}
}
}
Usage:
var element = DomUtils.getShadowElementById('mainContainer');
Tested on desktop Chrome, Internet Explorer, Firefox