Skip to content

Commit

Permalink
fix: findRef
Browse files Browse the repository at this point in the history
  • Loading branch information
helsonxiao committed Sep 14, 2020
1 parent d16d30f commit 098249d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packages/taro-h5/src/api/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,15 @@ function processOpenapi (apiName, defaultOptions, formatResult = res => res, for
}
}

const findRef = (refId, componentInstance) => {
const findRef = (refId, componentInstance = {}) => {
if (componentInstance.isRoute) return
return componentInstance[refId] || findRef(refId, componentInstance.vnode._owner)
if (componentInstance[refId]) {
return componentInstance[refId]
}
if (componentInstance.vnode) {
return findRef(refId, componentInstance.vnode._owner)
}
return document.getElementById(refId).childNodes[0]
}

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/taro-h5/src/api/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,5 @@ export function chooseVideo (options) {
* @param {object} componentInstance 在自定义组件下,当前组件实例的this,以操作组件内 <video> 组件
*/
export function createVideoContext (id, componentInstance) {
const refId = `__taroref_${id}`
return findRef(refId, componentInstance)
return findRef(id, componentInstance)
}

0 comments on commit 098249d

Please sign in to comment.