MCPcopy Index your code
hub / github.com/ygs-code/vue / handleStartTag

Function handleStartTag

vue.js:12810–12933  ·  view source on GitHub ↗
(match)

Source from the content-addressed store, hash-verified

12808 //为parseHTML 节点标签堆栈 插入一个桟数据
12809 //调用options.start 为parse函数 stack标签堆栈 添加一个标签
12810 function handleStartTag(match) {
12811 /*
12812 * match = {
12813 tagName: start[1], //标签名称
12814 attrs: [], //标签属性集合
12815 start: index, //开始标签的开始索引
12816 match:index , //开始标签的 结束位置
12817 unarySlash:'' //如果是/>标签 则unarySlash 是/。 如果是>标签 则unarySlash 是空
12818 };
12819 * */
12820
12821 var tagName = match.tagName; //开始标签名称
12822 var unarySlash = match.unarySlash; //如果是/>标签 则unarySlash 是/。 如果是>标签 则unarySlash 是空
12823 console.log(expectHTML)
12824 console.log('lastTag==')
12825 console.log(lastTag)
12826 console.log(tagName)
12827
12828 if (expectHTML) { //true
12829
12830 if (
12831 lastTag === 'p' //上一个标签是p
12832 /*
12833 判断标签是否是
12834 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
12835 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
12836 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
12837 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
12838 'title,tr,track'
12839 */
12840 && isNonPhrasingTag(tagName)
12841 ) {
12842 //查找parseHTML的stack栈中与当前tagName标签名称相等的标签,
12843 //调用options.end函数,删除当前节点的子节点中的最后一个如果是空格或者空的文本节点则删除,
12844 //为stack出栈一个当前标签,为currentParent变量获取到当前节点的父节点
12845 parseEndTag(lastTag);
12846 }
12847 if (
12848 canBeLeftOpenTag$$1(tagName) && //判断标签是否是 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
12849 lastTag === tagName //上一个标签和现在标签相同 <li><li> 编译成 <li></li> 但是这种情况是不会出现的 因为浏览器解析的时候会自动补全如果是<li>我是li标签<li> 浏览器自动解析成 <li>我是li标签</li><li> </li>
12850 ) {
12851 //查找parseHTML的stack栈中与当前tagName标签名称相等的标签,
12852 //调用options.end函数,删除当前节点的子节点中的最后一个如果是空格或者空的文本节点则删除,
12853 //为stack出栈一个当前标签,为currentParent变量获取到当前节点的父节点
12854 parseEndTag(tagName);
12855 }
12856 }
12857
12858 var unary = isUnaryTag$$1(tagName) || //函数匹配标签是否是 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen, link,meta,param,source,track,wbr'
12859 !!unarySlash; //如果是/> 则为真
12860
12861 var l = match.attrs.length;
12862 var attrs = new Array(l); //数组属性对象转换正真正的数组对象
12863 for (var i = 0; i < l; i++) {
12864 var args = match.attrs[i]; //获取属性对象
12865 // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
12866 //对FF bug进行黑客攻击:https://bugzilla.mozilla.org/show_bug.cgi?id=369778
12867 if (

Callers 1

parseHTMLFunction · 0.85

Calls 2

parseEndTagFunction · 0.85
decodeAttrFunction · 0.85

Tested by

no test coverage detected