*Function: createCompileToFunctionFn * Description: 函数科里化 创建一个对象,并且把字符串转换成 对象函数方式存在在对象中,导出去匿名函数 *Calls: *Called By: //调用本函数的清单 *Input: template 模板字符串 options参数 vm vnode节点 *Return: function 返回一个匿名函数
(compile)
| 15476 | *Return: function 返回一个匿名函数 |
| 15477 | **********************************************************************************/ |
| 15478 | function createCompileToFunctionFn(compile) { |
| 15479 | |
| 15480 | //创建一个空的对象 |
| 15481 | var cache = Object.create(null); |
| 15482 | //函数科里化 |
| 15483 | // 把字符串 编译变成 真正的js 并且以对象函数方式导出去 |
| 15484 | /********************************************************************************* |
| 15485 | *Function: compileToFunctions |
| 15486 | * Description: 把字符串 编译变成 真正的js 并且以对象函数方式导出去 |
| 15487 | *Calls: |
| 15488 | *Called By: |
| 15489 | *Input: template 模板字符串 options参数 vm vnode节点 |
| 15490 | *Return: object 对象函数 //函数返回值的说明 |
| 15491 | **********************************************************************************/ |
| 15492 | return function compileToFunctions( |
| 15493 | template, //字符串模板 |
| 15494 | options, //参数 |
| 15495 | vm //vmnode |
| 15496 | ) { |
| 15497 | //浅拷贝参数 |
| 15498 | options = extend({}, options); |
| 15499 | //警告 |
| 15500 | var warn$$1 = options.warn || warn; |
| 15501 | //删除参数中的警告 |
| 15502 | delete options.warn; |
| 15503 | |
| 15504 | /* istanbul ignore if */ |
| 15505 | { |
| 15506 | // detect possible CSP restriction |
| 15507 | try { |
| 15508 | new Function('return 1'); |
| 15509 | } catch (e) { |
| 15510 | if (e.toString().match(/unsafe-eval|CSP/)) { |
| 15511 | warn$$1( |
| 15512 | 'It seems you are using the standalone build of Vue.js in an ' + |
| 15513 | 'environment with Content Security Policy that prohibits unsafe-eval. ' + |
| 15514 | 'The template compiler cannot work in this environment. Consider ' + |
| 15515 | 'relaxing the policy to allow unsafe-eval or pre-compiling your ' + |
| 15516 | 'templates into render functions.' |
| 15517 | ); |
| 15518 | } |
| 15519 | } |
| 15520 | } |
| 15521 | |
| 15522 | // check cache 拦阻索 |
| 15523 | /* |
| 15524 | *这个选项只在完整构建版本中的浏览器内编译时可用。 |
| 15525 | * 详细:改变纯文本插入分隔符。 |
| 15526 | * |
| 15527 | * 示例: |
| 15528 | new Vue({ |
| 15529 | delimiters: ['${', '}'] |
| 15530 | }) |
| 15531 | // 分隔符变成了 ES6 模板字符串的风格 |
| 15532 | * |
| 15533 | * */ |
| 15534 | |
| 15535 | var key = options.delimiters ? String(options.delimiters) + template : template; |
no test coverage detected