* Build a getter function. Requires eval. * * We isolate the try/catch so it doesn't affect the * optimization of the parse function when it is not called. * * @param {String} body * @return {Function|undefined}
(body)
| 2921 | */ |
| 2922 | |
| 2923 | function makeGetterFn(body) { |
| 2924 | try { |
| 2925 | /* eslint-disable no-new-func */ |
| 2926 | return new Function('scope', 'return ' + body + ';'); |
| 2927 | /* eslint-enable no-new-func */ |
| 2928 | } catch (e) { |
| 2929 | if ('development' !== 'production') { |
| 2930 | /* istanbul ignore if */ |
| 2931 | if (e.toString().match(/unsafe-eval|CSP/)) { |
| 2932 | warn('It seems you are using the default build of Vue.js in an environment ' + 'with Content Security Policy that prohibits unsafe-eval. ' + 'Use the CSP-compliant build instead: ' + 'http://vuejs.org/guide/installation.html#CSP-compliant-build'); |
| 2933 | } else { |
| 2934 | warn('Invalid expression. ' + 'Generated function body: ' + body); |
| 2935 | } |
| 2936 | } |
| 2937 | return noop; |
| 2938 | } |
| 2939 | } |
| 2940 | |
| 2941 | /** |
| 2942 | * Compile a setter function for the expression. |
no test coverage detected