Вопрос

I have used JavaScript since it was called LiveScript,
and know to value persons who say "Eval is Evil"
(Classic SharePoint uses eval() at least 5 times in its core code)

So when a new kid on the block gets (a bit) Evil,
starts telling you how to behave,
and restricts your capabilities,
😇 you counter it with Creativity:

  this.domElement.innerHTML = eval(
      `var s=document.createElement("SCRIPT");
       s.type="text/javascript";
       s.src="https://365csi.nl/hello_spfx.CSI.js";
       document.head.appendChild(s);');

Questions

  • Can we safely use standard ECMAscript eval() in SPFX?

  • There are ways of crippling eval();
    as Classic SharePoint uses eval itself in its core code,
    will SPFx / New Experience not be more Evil on us?

  • Is eval used in new SharePoint code?
    Haven't had time yet to do a code analysis...
    Seems kinda pointless with an update every couple of weeks:

    (script:0 is my auto-check if UserCustomActions are enabled again)

Это было полезно?

Решение

I.believe you can use it. As you mention its generally not a good practice, but you can use it. I don't believe we use it in any of our code. Are you encountering any issue?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top