Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions google-chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
-->
<dom-module id="google-chart">
<template>
<div id="styles"></div>
<style include="google-chart-styles"></style>
<google-chart-loader id="loader" type="[[type]]"></google-chart-loader>
<div id="chartdiv"></div>
Expand Down Expand Up @@ -310,6 +311,33 @@
_typeChanged: function() {
this.$.loader.create(this.type, this.$.chartdiv)
.then(function(chart) {

// get all gchart stylesheets
var stylesheets =
Polymer.dom(document.head)
.querySelectorAll('link[rel="stylesheet"][type="text/css"]');
var gchartStylesheets = Array.from(stylesheets).filter(
function(element) {
return element.id.indexOf('load-css-') == 0;
});

// clone necessary attributes
var clonedSheets = gchartStylesheets.map(
function(stylesheet) {
var link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.setAttribute('href', stylesheet.getAttribute('href'));
return link;
}
);

// append them to this local dom (for sdom support)
clonedSheets.forEach(
function(stylesheet) {
Polymer.dom(this.$.styles).appendChild(stylesheet);
}.bind(this));

var loader = this.$.loader;
Object.keys(this.events.concat(['select', 'ready'])
.reduce(function(set, eventName) {
Expand Down