MCPcopy Index your code
hub / github.com/ygs-code/vue / transformNode$1

Function transformNode$1

vue.js:12414–12442  ·  view source on GitHub ↗
(el, options)

Source from the content-addressed store, hash-verified

12412 transformNode$1获取 style属性和:style或者v-bind的动态属性值,并且转化成字符串 添加到staticStyle和styleBinding属性中
12413 * */
12414 function transformNode$1(el, options) {
12415 var warn = options.warn || baseWarn;
12416 var staticStyle = getAndRemoveAttr(el, 'style');
12417 if (staticStyle) {
12418 /* istanbul ignore if */
12419 {
12420 //匹配view 指令,并且把他转换成 虚拟dom vonde 需要渲染的函数,比如指令{{name}}转换成 _s(name)
12421 var res = parseText(staticStyle, options.delimiters);
12422 //如果在静态的class中有动态 指令的话 则发出警告
12423 //当用户设置 style="{ width: num }" data={ num:'100px'}, 应该用户是不是忘记加 : 点了
12424 if (res) {
12425 warn(
12426 "style=\"" + staticStyle + "\": " +
12427 'Interpolation inside attributes has been removed. ' +
12428 'Use v-bind or the colon shorthand instead. For example, ' +
12429 'instead of <div style="{{ val }}">, use <div :style="val">.'
12430 );
12431 }
12432 }
12433 //把style 字符串 转换成对象 比如'width:100px;height:200px;' 转化成 {width:100px,height:200px}
12434 // 然后在转换成字符串
12435 el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
12436 }
12437
12438 var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
12439 if (styleBinding) {
12440 el.styleBinding = styleBinding;
12441 }
12442 }
12443
12444 //style 数据转换
12445 function genData$1(el) {

Callers

nothing calls this directly

Calls 3

getAndRemoveAttrFunction · 0.85
parseTextFunction · 0.85
getBindingAttrFunction · 0.85

Tested by

no test coverage detected