RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.4k stars 2.17k forks source link

Masking not working when javascript minified #2091

Open tanelsuurhans opened 5 years ago

tanelsuurhans commented 5 years ago

I am seeing an issue where if I run the javascript libraries through Uglifier (which Rails uses by default for JS compression), the masking stops working. It does not produce any exceptions or errors, it just starts behaving erratically. I have narrowed it down to the compressions specifically, and tried both unminified and minified versions of the library with the same results.

Due to what seems to cause the issue, its tough to replicate in JSFiddle obviously. The best I can do is include a GIF of what happens with the masking.

dobbug

RobinHerbots commented 5 years ago

@tanelsuurhans ,

Try these uglify options

 uglifyOptions: {
                warnings: "verbose",
                mangle: false,
                compress: {
                    keep_fnames: true,
                    unused: false,
                    typeofs: false,
                    dead_code: false,
                    collapse_vars: false
                },
                output: {
                    ascii_only: true,
                    beautify: false,
                    comments: /^!/
                }

Anyway, I need to investigate this more deeply, so I can avoid this.

tanelsuurhans commented 5 years ago

It seems to work with those settings on my first try at least. The only thing the ruby wrapper for UglifyJS does not support is the warning setting - so sadly I'm unable to see any output from that, in case it would lead to something more specific of whats going on during the compression.

Sounds like you have a hunch about what might be going on? I'm curious to know what that could be, if you don't mind sharing.

pk-rawat commented 5 years ago

@tanelsuurhans try updating uglifier gem and use new harmony mode in production.rb

config.assets.js_compressor = Uglifier.new(harmony: true)
possatto commented 5 years ago

I'm having the same problem but I have not found a solution yet :/

pogorivan commented 5 years ago

I have such error when minifiing inputmask

15289 | if (isValidElement(this[0])) { 15290 | var eventRegistry = this[0].eventRegistry, elem = this[0]; 15291 | function addEvent(ev, namespace) { | ^ In strict mode code, functions can only be declared at top level or immediately within another function.

The problem is in inputmask.dependencyLib.js