jsmin-php
jsmin-php copied to clipboard
javascript variable that starts with '$' parsed incorrectly
Hello,
If you have javascript variable that starts with '$' jsmin-php parse it incorrectly resulting in javascript error. In mootools/mif tree project (http://github.com/creaven/miftree) the author use this.$ = {} or this.$index = null. Jsmin-php is unable to recognize this syntax.
Same problem here.
Nobody for a patch to correct this issue ?
I saw a patch for this at some point but lost it. I'm terrible at regexes but I think the problem is in the isAlphaNum function.
Below is what the function looks like in the current master:
protected function isAlphaNum($c) {
return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
I added the mif.tree library (1.2.6.4 as of this writing) as a test case in my fork on js-min-php and it passes against the C version of jsmin. The output from my fork doesn't exhibit a JS error, possibly an outdated bug?
https://github.com/jaydiablo/jsmin-php