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 4fad6e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/taro-h5/src/api/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,11 @@ function processOpenapi (apiName, defaultOptions, formatResult = res => res, for
}
}

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

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

0 comments on commit 4fad6e0

Please sign in to comment.