Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • suzyb 474 posts 932 karma points
    Dec 14, 2017 @ 11:48
    suzyb
    0

    "Strict mode code may not include a with statement" error with Client Dependency on

    We have Newsletter Studio installed on an Umbraco 7.5.7 site however are getting errors when we switch debug to false and the Client Dependency kicks in.

    The error is Strict mode code may not include a with statement and it seems to be related to newsletter studio, in particular this piece of code with(myiframedoc).

    I believe the problem is because with statements are not allowed with use strict however newsletter studio doesn't set use strict, other packages do but not newsletter studio. Is the use strict on these other packages causing this error. Can anyone advise how to resolve this issue.

  • Kevin Jump 2341 posts 14868 karma points MVP 8x c-trib
    Dec 14, 2017 @ 12:21
    Kevin Jump
    101

    Hi

    yes it's probibly another package setting 'use strict' ; at a global level and when the scripts are stuck together it's conflicting :(

    I would search the App_Plugins folder for 'use strict' and then see if there is a script in there where it is set at the top of the script and not wrapped with a function.

    if you see something like

    'use strict';
    
    function modulecodefunctions() {
    }
    ...
    

    this file is your problem.

    ideally anyone useing strict should wrap their code

    (function() {
        'use strict';
    
         // pluging code here 
    })(); 
    

    so if you see it like that then it's not the file causing your problem.

    to test you could either

    a) remove use strict from the start of any plugin scripts that are declare it outside of a function.

    or b) wrap that file in the (function() { })() syntax.

    remember to increment the version in config/clientdependency.config once you have made any changes.

    I would also drop a post into the relevant forum if you happen to find out which plugin is causing the issue (crossing my fingers it's not one of mine)

  • suzyb 474 posts 932 karma points
    Dec 15, 2017 @ 10:09
    suzyb
    0

    It looks like it was the God Mode package that was causing the issue. It's not really needed on live where we'll be using client dependency so I've just uninstalled it for now.

    Going to report the issue on the packages github. Thanks for pointing me in the right direction.

  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    Dec 16, 2017 @ 11:26
    Markus Johansson
    0

    Hi!

    Nice to see that you found a solution for this and thanks Kevin Jump for providing a great fix!

    Cheers guys!

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jan 19, 2018 @ 12:42
    Dan Diplo
    0

    So, I've crawled out of my hole and (hopefully) fixed this by taking Kev's sterling advise. Apologies for any inconvenience! (I forget that Angular and Client Dependency munge everything into one big blob of monolithic mutated JavaScript that sits like an angry spider in a web looking for innocent victims such as myself who don't quite get "namespacing" in JS :) )

    The new version of God Mode should address this:

    https://www.nuget.org/packages/Diplo.GodMode/

    https://our.umbraco.org/projects/developer-tools/diplo-god-mode/

    If you have any more issues let me know.

Please Sign in or register to post replies

Write your reply to:

Draft