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

Function parseEndTag

vue.js:12940–13053  ·  view source on GitHub ↗
(
            tagName,   //标签名称
            start,  //结束标签开始位置
            end    //结束标签结束位置
        )

Source from the content-addressed store, hash-verified

12938 //调用options.end函数,删除当前节点的子节点中的最后一个如果是空格或者空的文本节点则删除,
12939 //为stack出栈一个当前标签,为currentParent变量获取到当前节点的父节点
12940 function parseEndTag(
12941 tagName, //标签名称
12942 start, //结束标签开始位置
12943 end //结束标签结束位置
12944 ) {
12945 var pos,
12946 lowerCasedTagName;
12947 if (start == null) { //如果没有传开始位置
12948 start = index; //就那当前索引
12949 }
12950 if (end == null) { //如果没有传结束位置
12951 end = index; //就那当前索引
12952 }
12953
12954 if (tagName) { //结束标签名称
12955 lowerCasedTagName = tagName.toLowerCase(); //将字符串转化成小写
12956 }
12957
12958 // Find the closest opened tag of the same type 查找最近打开的相同类型的标记
12959 if (tagName) {
12960 // 获取stack堆栈最近的匹配标签
12961 for (pos = stack.length - 1; pos >= 0; pos--) {
12962 //找到最近的标签相等
12963 if (stack[pos].lowerCasedTag === lowerCasedTagName) {
12964 break
12965 }
12966 }
12967 } else {
12968 // If no tag name is provided, clean shop
12969 //如果没有提供标签名称,请清理商店
12970 pos = 0;
12971 }
12972
12973
12974 if (pos >= 0) { //这里就获取到了stack堆栈的pos索引
12975 // Close all the open elements, up the stack 关闭所有打开的元素,向上堆栈
12976 console.log(pos)
12977
12978 for (var i = stack.length - 1; i >= pos; i--) {
12979
12980 if ("development" !== 'production' && //如果stack中找不到tagName 标签的时候就输出警告日志,找不到标签
12981 (i > pos || !tagName) &&
12982 options.warn
12983 ) {
12984 options.warn(
12985 ("tag <" + (stack[i].tag) + "> has no matching end tag.")
12986 );
12987 }
12988 if (options.end) {
12989 console.log(options.end)
12990 //调用options.end函数,删除当前节点的子节点中的最后一个如果是空格或者空的文本节点则删除,
12991 //为stack出栈一个当前标签,为currentParent变量获取到当前节点的父节点
12992 options.end(
12993 stack[i].tag,//结束标签名称
12994 start, //结束标签开始位置
12995 end //结束标签结束位置
12996 );
12997 }

Callers 2

parseHTMLFunction · 0.85
handleStartTagFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected