(
el, //虚拟dom vonde
options //用户 new Vue 的参数
)
| 12354 | * 获取 class 属性和:class或者v-bind的动态属性值,并且转化成字符串 添加到staticClass和classBinding 属性中 |
| 12355 | * */ |
| 12356 | function transformNode( |
| 12357 | el, //虚拟dom vonde |
| 12358 | options //用户 new Vue 的参数 |
| 12359 | ) { |
| 12360 | var warn = options.warn || baseWarn; //警告日志 |
| 12361 | var staticClass = getAndRemoveAttr(el, 'class'); //获取class |
| 12362 | |
| 12363 | if ("development" !== 'production' && staticClass) { |
| 12364 | //匹配view 指令,并且把他转换成 虚拟dom vonde 需要渲染的函数,比如指令{{name}}转换成 _s(name) |
| 12365 | var res = parseText( |
| 12366 | staticClass, //class 属性值 |
| 12367 | options.delimiters //指令 {{ }} 或者自定义指令['${', '}'] |
| 12368 | ); |
| 12369 | //如果在静态的class中有动态 指令的话 则发出警告 |
| 12370 | //当用户设置 class="{ active: isActive }" data={ active:true}, 应该用户是不是忘记加 : 点了 |
| 12371 | if (res) { |
| 12372 | warn( |
| 12373 | "class=\"" + staticClass + "\": " + |
| 12374 | 'Interpolation inside attributes has been removed. ' + |
| 12375 | 'Use v-bind or the colon shorthand instead. For example, ' + |
| 12376 | 'instead of <div class="{{ val }}">, use <div :class="val">.' |
| 12377 | ); |
| 12378 | } |
| 12379 | } |
| 12380 | if (staticClass) { |
| 12381 | //获取原始class属性的值 转化成字符串 |
| 12382 | el.staticClass = JSON.stringify(staticClass); |
| 12383 | } |
| 12384 | //获取 :class或者v-bind的动态属性值 |
| 12385 | var classBinding = getBindingAttr(el, 'class', false /* getStatic */); |
| 12386 | if (classBinding) { |
| 12387 | el.classBinding = classBinding; |
| 12388 | } |
| 12389 | } |
| 12390 | |
| 12391 | //创数据,转换class |
| 12392 | function genData(el) { |
nothing calls this directly
no test coverage detected