- Creator 版本:3.6
有疑惑的代码是201行对图片解析的返回值
html-text-parser.js
最近使用富文本时候发现,带下划线+图片的组合时,会导致下划线结束不准确
如文本为:
<u><color=#2ea4ff><on click="elemClickHandler" >疯疯癫癫的的人<color=#ffffff><img src='chat_vip_text_labelatlas' offset=0,-1.5/></color>:</on></color></u><color=#ffb50f>grgr</color></color>
后面的grgr也会带上下划线,后来看html-text-parser 解析发现
在 _attributeToObject 函数对图片的解析时,最后返回了{}
private _attributeToObject (attribute: string) {
....
header = attribute.match(/^(img(\s)*src(\s)*=[^>]+\/)/);
...
if (isValidImageTag && obj.isImage) {
this._resultObjectArray.push({ text: '', style: obj });
}
return {};
}
}
....
}
我试了下返回obj后就没有下划线的问题了
但是不理解这里为何是返回{},是有什么特殊意义吗