*Function: createCompilerCreator * Description: 函数科里化 创建一个对象,并且把字符串转换成 对象函数方式存在在对象中,导出去匿名函数 *Input: baseCompile 基本编译函数 *Return: function 返回一个函数
(
baseCompile //基本的编译函数
)
| 15615 | *Return: function 返回一个函数 |
| 15616 | **********************************************************************************/ |
| 15617 | function createCompilerCreator( |
| 15618 | baseCompile //基本的编译函数 |
| 15619 | ) { |
| 15620 | |
| 15621 | console.log(baseCompile) |
| 15622 | |
| 15623 | |
| 15624 | return function createCompiler(baseOptions) { |
| 15625 | console.log(baseOptions) |
| 15626 | |
| 15627 | |
| 15628 | function compile( |
| 15629 | template, //字符串模板 |
| 15630 | options //options 参数 |
| 15631 | ) { |
| 15632 | console.log(options) |
| 15633 | |
| 15634 | |
| 15635 | //template 模板 options 参数 |
| 15636 | // 创建一个对象 拷贝baseOptions 拷贝到 原型 protype 中 |
| 15637 | var finalOptions = Object.create(baseOptions); //为虚拟dom添加基本需要的属性 |
| 15638 | console.log(finalOptions) |
| 15639 | console.log(finalOptions.__proto__) |
| 15640 | console.log(finalOptions.property) |
| 15641 | |
| 15642 | var errors = []; |
| 15643 | var tips = []; |
| 15644 | //声明警告函数 |
| 15645 | finalOptions.warn = function (msg, tip) { |
| 15646 | (tip ? tips : errors).push(msg); |
| 15647 | }; |
| 15648 | |
| 15649 | if (options) { |
| 15650 | console.log(options) |
| 15651 | |
| 15652 | // merge custom modules |
| 15653 | //baseOptions中的modules参数为 |
| 15654 | // modules=modules$1=[ |
| 15655 | // { // class 转换函数 |
| 15656 | // staticKeys: ['staticClass'], |
| 15657 | // transformNode: transformNode, |
| 15658 | // genData: genData |
| 15659 | // }, |
| 15660 | // { //style 转换函数 |
| 15661 | // staticKeys: ['staticStyle'], |
| 15662 | // transformNode: transformNode$1, |
| 15663 | // genData: genData$1 |
| 15664 | // }, |
| 15665 | // { |
| 15666 | // preTransformNode: preTransformNode |
| 15667 | // } |
| 15668 | // ] |
| 15669 | |
| 15670 | |
| 15671 | |
| 15672 | if (options.modules) { // |
| 15673 | finalOptions.modules = (baseOptions.modules || []).concat(options.modules); |
| 15674 | } |
no test coverage detected