提交 9f25ea92 编写于 作者: E Elie Bariche

fix(csp): Make setCursor CSP compliant

上级 a8158e0d
......@@ -127,7 +127,7 @@ namespace Uno.UI {
private containerElement: HTMLDivElement;
private rootElement: HTMLElement;
private cursorStyleElement: HTMLElement;
private cursorStyleRule: CSSStyleRule;
private allActiveElementsById: { [id: string]: HTMLElement | SVGElement } = {};
private uiElementRegistrations: {
......@@ -1731,22 +1731,16 @@ namespace Uno.UI {
if (unoBody) {
//always cleanup
if (this.cursorStyleElement != undefined) {
this.cursorStyleElement.remove();
this.cursorStyleElement = undefined
}
//only add custom overriding style if not auto
if (cssCursor != "auto") {
if (this.cursorStyleRule === undefined) {
const styleSheet = document.styleSheets[document.styleSheets.length - 1];
// this part is only to override default css: .uno-buttonbase {cursor: pointer;}
const ruleId = styleSheet.insertRule(".uno-buttonbase { }", styleSheet.cssRules.length);
this.cursorStyleElement = document.createElement("style");
this.cursorStyleElement.innerHTML = ".uno-buttonbase { cursor: " + cssCursor + "; }";
document.body.appendChild(this.cursorStyleElement);
this.cursorStyleRule = <CSSStyleRule>styleSheet.cssRules[ruleId];
}
this.cursorStyleRule.style.cursor = cssCursor !== "auto" ? cssCursor : null;
unoBody.style.cursor = cssCursor;
}
return "ok";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册