提交 accb765b 编写于 作者: d-u-a's avatar d-u-a

update: findRefByVNode 改为 findRefByElm

上级 e8e0f55b
......@@ -46,26 +46,22 @@ export function invokeVmMethod (vm, method, args, extras) {
}
export function findElmById (id, vm) {
return findElmByVNode(id, vm._vnode)
return findRefByElm(id, vm.$el)
}
function findElmByVNode (id, vnode) {
if (!id || !vnode) {
function findRefByElm (id, elm) {
if (!id || !elm) {
return
}
if (
vnode.data &&
vnode.data.attrs &&
vnode.data.attrs.id === id
) {
return vnode.elm
if (elm.attr.id === id) {
return elm
}
const children = vnode.children
const children = elm.children
if (!children) {
return
}
for (let i = 0, len = children.length; i < len; i++) {
const elm = findElmByVNode(id, children[i])
const elm = findRefByElm(id, children[i])
if (elm) {
return elm
}
......@@ -112,4 +108,4 @@ function normalizeCallback (method, callbacks) {
isFn(complete) && complete(ret)
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册