I was reading the docs on Validate Secure Window Public API (secure-window) for LockerService and I'm not able to understand the example given:

The following patterns are considered problematic:

onclick: function (cmp, evt, help) {

The following patterns use features of the Lightning Components framework and are suggested as an alternative:

onclick: function (cmp, evt, help) {
    setTimeout(function () {}, 100);

I'm supposed to be using window.open inside the setTimeout function or should I implement a similar function to window.open inside the setTimeout? Either way It's not clear enough for me.


It just means that setTimeout is considered a safe function and is allowed whereas open is not. You can invoke setTimeout with LockerService enabled and not have problems, but if you invoke open you'll get an error due to LockerService.

Directly above the examples on the doc page, Validate Secure Window Public API (secure-window), the following lists the window methods that are allowed:

Supported window functions and properties include the following:

  • addEventListener
  • setInterval
  • setTimeout
  • $A
  • document
  • location
  • navigator
  • window

Note that setTimeout is listed, whereas open is not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.