MCPcopy
hub / github.com/ygs-code/vue / makeMap

Function makeMap

vue.js:141–155  ·  view source on GitHub ↗

* Make a map and return a function for checking if a key * is in that map. * * //map 对象中的[name1,name2,name3,name4] 变成这样的map{name1:true,name2:true,name3:true,name4:true} * 并且传进一个key值取值,这里用到策略者模式

(str,
        expectsLowerCase)

Source from the content-addressed store, hash-verified

139 * 并且传进一个key值取值,这里用到策略者模式
140 */
141 function makeMap(str,
142 expectsLowerCase) {
143 var map = Object.create(null); //创建一个新的对象
144 var list = str.split(','); //按字符串,分割
145 for (var i = 0; i < list.length; i++) {
146 map[list[i]] = true; //map 对象中的[name1,name2,name3,name4] 变成这样的map{name1:true,name2:true,name3:true,name4:true}
147 }
148 return expectsLowerCase
149 ? function (val) {
150 return map[val.toLowerCase()];
151 } //返回一个柯里化函数 toLowerCase转换成小写
152 : function (val) {
153 return map[val];
154 } //返回一个柯里化函数 并且把map中添加一个 属性建
155 }
156
157 /**
158 * Check if a tag is a built-in tag.

Callers 3

vue.jsFile · 0.85
createPatchFunctionFunction · 0.85
genStaticKeys$1Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected