JedWatson / classnames

A simple javascript utility for conditionally joining classNames together
MIT License
17.6k stars 562 forks source link

'use strict' and eval #37

Closed daviferreira closed 9 years ago

daviferreira commented 9 years ago

I'm having this specific problem using classNames with webpack devtool option set to eval. It only happens on Chrome and when the console is not open. The issue is calling classNames inside the classNames function with the 'use strict' statement inside the function (https://github.com/JedWatson/classnames/blob/master/index.js#L22), this will cause a ReferenceError.

See:

https://github.com/webpack/webpack/issues/417

Explanation:

https://github.com/ftlabs/fastclick/pull/270

I would be happy to submit a PR with a umd wrapper if you guys are ok with it :)

Thanks for the great lib!

dcousens commented 9 years ago

@daviferreira could we just avoid the use of use strict? We can enforce most of the structuring properties of strictness through a linter.

JedWatson commented 9 years ago

I think we could take use strict out if it's causing trouble, or @daviferreira am happy to review your wrapper too if that solves the problem.

From what I understand, modern javascript engines are able to optimise certain code paths if they know a function is in strict mode, this may or may not be a major issue / benefit for classNames - unfortunately I'm not familiar enough with the inner workings to say for sure...

dcousens commented 9 years ago

@JedWatson this is apparently true, however I'd prefer to see some benchmarks before we just assume.