13

I use momentjs's library in my lightning application to manipulate javascript dates.

When my sandbox was updated from winter 17 to spring 17 I noticed the format function doesn't work any more.

Instead of returning a string with the correct format, it returns a string with a function.

enter image description here

I've been reading through the releases notes and there is no mention of the eval function not supported anymore, however, it's not used in that library.

I found a workaround by using the Lightning's LocalizationService for formatting in conjunction with the rest of the momentjs library now to make it work so I'm not actually looking for a solution to my problem but more of an explanation as to why it doesn't work any more. What does the momentjs format function do that Lightning doesn't support any more?

  • Looks like this has been fixed as of 2/16/2017. Can anyone else confirm? – unhinged Feb 17 '17 at 3:27
9

We are already working on this one - its a bit tricky to explain the cause but it has to do with one of the remaining changes required in Lightning to fully support the Content Security Policy requirements from our Security team. There is a use of instanceof (long listed as something that will cause an issue once this last phase of Locker goes live) in momentjs to determine if a value is a function if not momentjs treats it as a string (hence the bizarre display of the source).

If you have a case open on this already you can let support know that the R&D bug for this is W-3575534. Our plan is to get this fixed in Spring'17.

  • Fix has been deployed to all instances running Spring'17 – Doug Chasman Feb 17 '17 at 12:33

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.