Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Strict mode at file level in locale files #9155

Closed
ArturDorochowicz opened this issue Sep 18, 2014 · 3 comments
Closed

Strict mode at file level in locale files #9155

ArturDorochowicz opened this issue Sep 18, 2014 · 3 comments

Comments

@ArturDorochowicz
Copy link

Strict mode is specified at file level in Angular locale files, e.g. see: angular-locale_aa-dj.js.

This makes them infeasible for concatenation with other scripts that may not be strict mode compliant.

Please remove strict mode from file level there. As far as I see this is a matter of applying some changes to i18n/src/closureI18nExtractor.js

@btford
Copy link
Contributor

btford commented Sep 18, 2014

It's better to wrap the file in an immediately invoked function expression:

(function () {
  /* file contents here */
}())

I don't think Angular should be making changes to accommodate brittle build systems.

@ArturDorochowicz
Copy link
Author

Reconsider this, please.

  1. Of course it's better to wrap the contents in IIF. It's even better to fix the problem once and for all - at the source, instead of requiring consumers to repeatedly deal with this problem.
  2. For some reason none of the other Angular deliverables require this "workaround". How about bringing locale in line with the rest of Angular?
  3. This violates a rather clear recommendation of not using global strict mode.

@gkalpak
Copy link
Member

gkalpak commented Sep 19, 2014

@btford: Since this seems to be such a trivial change (either wrap the contents in an IIFE or move the 'use strict' inside of the config function), is there any reason why Angular wouldn't want something like this (e.g. is it going to create problems elsewhere I don't know about) ?

If nothing else it is good coding style not to have global strict mode, isn't it ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants