use of elemental2.dom.HTMLHeadElement in project console by hal.
the class ExtensionRegistry method jsInject.
// ------------------------------------------------------ JS methods
/**
* Injects the script and stylesheets of an extension. This method is used during development. Normally you don't have to
* call this method.
*
* @param script the extension's script.
* @param stylesheets an optional list of stylesheets.
*/
@JsMethod(name = "inject")
@SuppressWarnings({ "HardCodedStringLiteral", "DuplicateStringLiteralInspection" })
public void jsInject(String script, @EsParam("string[]") String[] stylesheets) {
HTMLHeadElement head = document.head;
if (stylesheets != null && stylesheets.length != 0) {
for (String stylesheet : stylesheets) {
HTMLLinkElement linkElement = (HTMLLinkElement) document.createElement("link");
linkElement.rel = "stylesheet";
linkElement.href = stylesheet;
head.appendChild(linkElement);
}
}
HTMLScriptElement scriptElement = (HTMLScriptElement) document.createElement("script");
scriptElement.src = script;
scriptElement.setAttribute("async", true);
head.appendChild(scriptElement);
}
Aggregations