0

The issue

[Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them]

Founded on f.Application> __proto__ > * from Marionette.JS' object (Backbone.Marionette.Application();):

Issue

Knowledge

ES5 prohibited the use of arguments.callee according MDN. However, I am using some third-party library that probably use it and I don't know how to deal with.

My environment is:

  • jQuery
  • Require.JS
  • Underscore.JS
  • Backbone.JS
  • Marionette.JS
  • Handlebars

General

I removed 'use strict'; from all my own js files – not third-party libraries; my own scripts coded from scratch – and I can't see what's going wrong here – I need to be enlightened.

So, can someone suggest me something? And yes, I saw similar threads web-around, but no success at all – I think my issue is more specific than others.

The past

For those who ask, I wasn't working with Marionette.JS before in this application – just Backbone.JS. The error began to happen when I migrated my application from "native" Backbone to Marionette.

Guilherme Oderdenge
  • 4,935
  • 6
  • 61
  • 96
  • Found a similar, though seemingly outdated bug here: https://github.com/marionettejs/backbone.marionette/issues/387. Could you perhaps mention in the question the browsers you test in as well, as not all support strict mode? And the problem comes from Marionnette then, right? Personally, I've been reading you should avoid strict mode unless you thoroughly tested & retested it in different environments. Perhaps file an issue at the Github page? – webketje Jun 23 '14 at 22:35
  • I wouldn't say "prohibited", more that strict mode prevents access to them. I expect you can remove `'use strict'` everywhere, there shouldn't be anything that works in strict mode that fails in non–strict mode (given that the code likely runs in browsers that don't implement strict mode, such as IE 9). – RobG Jun 23 '14 at 23:54
  • @RobG Do you mean remove `'use strict';` even from all third-party libraries? – Guilherme Oderdenge Jun 24 '14 at 00:42
  • @GuilhermeOderdenge—yes. [*Strict mode*](http://ecma-international.org/ecma-262/5.1/#sec-C) just makes some parts of the language stricter (no access to *callee*, *caller*, *eval*, *with*, etc.) but doesn't add any features. A lot of browsers in use don't use strict mode, so any general library it must be written to work at least in non–strict mode. – RobG Jun 24 '14 at 02:10
  • A case where strict mode matters is `if (tyepof this == 'undefined')` which will always be false in non–strict mode, but might be true in strict mode. But I can't see that anyone would do that. – RobG Jun 24 '14 at 02:19
  • possible duplicate of [Disable 'use strict' in Google Maps Drawing Library (for compatibility with asp.net \_\_doPostBack)](http://stackoverflow.com/questions/13742051/disable-use-strict-in-google-maps-drawing-library-for-compatibility-with-asp) – Paul Sweatte Sep 11 '14 at 20:47
  • @RobG with regards to what you wrote "there shouldn't be anything that works in strict mode that fails in non–strict mode", are you sure this is the case? Also, are you sure that this is STILL the case? I am asking because of this question: https://stackoverflow.com/questions/70655625/is-it-safe-to-remove-use-strict-from-a-third-party-library – Vic Seedoubleyew Jan 10 '22 at 16:21

1 Answers1

0

In the Marionette source:

there is no 'use strict' on the functions themselves, but there is 'use strict' on the Marionette core:

Compare the downloaded source to the project source, and verify that your addInitializer method is within a scope that does not include the 'use strict' pragma.

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265