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