提交 4f87f081 编写于 作者: D DCloud_LXH

fix(h5): rich-text 在 h5 端 nodes 属性不支持 class 样式

上级 3c43b470
......@@ -38,7 +38,7 @@ export default {
if (typeof nodes === 'string') {
nodes = parseHtml(nodes)
}
const nodeList = parseNodes(nodes, document.createDocumentFragment())
const nodeList = parseNodes(nodes, document.createDocumentFragment(), this)
nodeList.appendChild(this.$refs.sensor.$el)
const content = this.$refs.content
content.innerHTML = ''
......
......@@ -96,7 +96,13 @@ function decodeEntities (htmlString) {
})
}
export default function parseNodes (nodes, parentNode) {
export default function parseNodes (nodes, parentNode, $vm) {
let scopeId = ''
while ($vm) {
!scopeId && (scopeId = $vm.$options._scopeId)
$vm = $vm.$parent
}
nodes.forEach(function (node) {
if (!isPlainObject(node)) {
return
......@@ -124,6 +130,7 @@ export default function parseNodes (nodes, parentNode) {
Array.isArray(value) && (value = value.join(' '))
case 'style':
elem.setAttribute(name, value)
scopeId && elem.setAttribute(scopeId, '')
break
default:
if (tagAttrs.indexOf(name) !== -1) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册