Skip to content

Commit

Permalink
Added onload to insertCSSIntoShadowRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
eterna2 committed Nov 16, 2017
1 parent 713b307 commit 31f0d4d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions polymer-vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@
* @alias module:insertCssIntoShadowRoot
* @param {String} cssSrc url to the css file
* @param {String} shadowRoot Node to insert the `style` element
* @param {Function} onload callback when CSS is inserted
* @param {String} id id for style element
* @example
* PolymerVis.insertCssIntoShadowRoot('https://some.css', ele.shadowRoot, 'custom');
*/
PolymerVis.insertCssIntoShadowRoot = function insertCssIntoShadowRoot(
cssSrc,
shadowRoot,
onload,
id = 'custom'
) {
var httpRequest = new XMLHttpRequest();
Expand All @@ -85,6 +87,7 @@
style.id = id;
style.textContent = httpRequest.responseText;
shadowRoot.appendChild(style);
if (onload) onload(style);
} else {
console.warn(`cannot load ${cssSrc}`);
}
Expand Down

0 comments on commit 31f0d4d

Please sign in to comment.