43 ms·
Looks like the regex is only used to strip comments?
by Froyoh 9y ago
Looks like the regex is only used to strip comments?
- evmar 9y agoThe line I linked to, sure. But under what conceptual model would a framework need logic to strip comments (an aspect of source text) at runtime? Follow it to its conclusion.
- pygy_ 9y agohttps://github.com/radi-js/radi/blob/eace84e9b74c944b233f631de314a6869ed21f0f/src/index.js#L585 https://github.com/radi-js/radi/blob/eace84e9b74c944b233f631... It parses the source code of the view function at run time, matching parentheses, but ignoring whether those are present in strings or regexes. Likewise, the comment stripper will turn "/*whoops*/" into the empty string... In other words, the parser is buggy :-/
- lhorie 9y agoHaving taken a closer look, it looks like the problems go even deeper than that: it rewrites `l()` calls in functions through a regex/replace on `fn.toString()`. This is similar to the mechanism that broke shorthand Angular.js DI in production. So code can break if it goes through some bundler than renames the `l` variable, or if a minifier does it, etc. I'd imagine closures also break.
- pygy_ 9y agoClosures will break, yes. It looks like it is intended to react to mutations to the properties of `this`... I hadn't thought of minification, yes it pretty bad :-/... It looks like the author is smart but has little JS experience (`var last = temp.splice(-1)[0]` where `temp.pop()` would do tells me that it may be one of his first JS project).