I have a JavaScript class in my Rails application that uses Uglifier inside Sprockets to compress the JS (under the hood I believe it uses: https://github.com/mishoo/UglifyJS)
class FormValidation {
connect() {
this.element.setAttribute('novalidate', true)
this.element.addEventListener('blur', this.onBlur, true)
}
onBlur = (event) => {
this.validateField(event.target)
}
... rest of code hidden for benefit of question.
And UglifyJS is disliking the = in my onBlur named method... with Parse error: Unexpected token: operator (=).
Harmony is set to true to support ES6... but still getting this error... How can I get around this? As I have had to remove the compression so I can use my class in my code...
Without looking at your tooling (babel, packing, etc.), it's hard to say how to get it to build right. but you can always just do the following: