| 8960 | } |
| 8961 | |
| 8962 | function createCompiler (baseOptions) { |
| 8963 | var functionCompileCache = Object.create(null); |
| 8964 | |
| 8965 | function compile ( |
| 8966 | template, |
| 8967 | options |
| 8968 | ) { |
| 8969 | var finalOptions = Object.create(baseOptions); |
| 8970 | var errors = []; |
| 8971 | var tips = []; |
| 8972 | finalOptions.warn = function (msg, tip$$1) { |
| 8973 | (tip$$1 ? tips : errors).push(msg); |
| 8974 | }; |
| 8975 | |
| 8976 | if (options) { |
| 8977 | // merge custom modules |
| 8978 | if (options.modules) { |
| 8979 | finalOptions.modules = (baseOptions.modules || []).concat(options.modules); |
| 8980 | } |
| 8981 | // merge custom directives |
| 8982 | if (options.directives) { |
| 8983 | finalOptions.directives = extend( |
| 8984 | Object.create(baseOptions.directives), |
| 8985 | options.directives |
| 8986 | ); |
| 8987 | } |
| 8988 | // copy other options |
| 8989 | for (var key in options) { |
| 8990 | if (key !== 'modules' && key !== 'directives') { |
| 8991 | finalOptions[key] = options[key]; |
| 8992 | } |
| 8993 | } |
| 8994 | } |
| 8995 | |
| 8996 | var compiled = baseCompile(template, finalOptions); |
| 8997 | { |
| 8998 | errors.push.apply(errors, detectErrors(compiled.ast)); |
| 8999 | } |
| 9000 | compiled.errors = errors; |
| 9001 | compiled.tips = tips; |
| 9002 | return compiled |
| 9003 | } |
| 9004 | |
| 9005 | function compileToFunctions ( |
| 9006 | template, |
| 9007 | options, |
| 9008 | vm |
| 9009 | ) { |
| 9010 | options = options || {}; |
| 9011 | |
| 9012 | /* istanbul ignore if */ |
| 9013 | { |
| 9014 | // detect possible CSP restriction |
| 9015 | try { |
| 9016 | new Function('return 1'); |
| 9017 | } catch (e) { |
| 9018 | if (e.toString().match(/unsafe-eval|CSP/)) { |
| 9019 | warn( |