Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'use strict' and var shine = shine || {}; #42

Open
bmcbarron opened this issue May 24, 2017 · 1 comment
Open

'use strict' and var shine = shine || {}; #42

bmcbarron opened this issue May 24, 2017 · 1 comment

Comments

@bmcbarron
Copy link

Howdy! I'm enjoying moonshine, thank you!

I see that several files use the idiom:

'use strict'
var shine = shine || {};

In Chrome, this results in:

var shine;           // implicitly undefined
shine = shine || {}; // ... therefore always {}

Thus, you can't use this technique to augment the same object (e.g. including moonshine.js and distillery.moonshine.js together).

This is further confused because in moonshine.js, 'use strict' is not the first line of code, so it actually has no effect. Things sometimes work as intended, depending on the exact mechanism used to include those two files.

I verified two possible ways of fixing this:

  1. Remove 'use strict'.
  2. Use var shine = this.shine = this.shine || {};

If you pursue the second case, I recommend moving 'use strict'; to the top of moonshine.js, to get the intended effect.

Cheers, and thanks again!

@paulcuth
Copy link
Contributor

Hi,

Sorry for not picking this up sooner. Thanks for the spot!

I see you've fixed it in your fork. I agree that option 2 is the best solution; if you'd like to create a pull request, I'd be pleased to merge it back upstream.

Regards,
Paul.

bmcbarron added a commit to bmcbarron/moonshine that referenced this issue Oct 30, 2017
bmcbarron added a commit to bmcbarron/moonshine that referenced this issue Oct 30, 2017
Quote JS keyword "yield" used as dictionary key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants