'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function findVmById (id, vm) {
  if (id === vm._$id) {
    return vm
  }
  const childVms = vm.$children
  const len = childVms.length
  for (let i = 0; i < len; i++) {
    const childVm = findVmById(id, childVms[i])
    if (childVm) {
      return childVm
    }
  }
}
 
export function findElm (component, pageVm) {
  if (!pageVm) {
    return console.error('page is not ready')
  }
  if (!component) {
    return pageVm.$el
  }
  if (__PLATFORM__ === 'app-plus') {
    if (typeof component === 'string') {
      const componentVm = findVmById(component, pageVm)
      if (!componentVm) {
        throw new Error(`Not Found:Page[${pageVm.$page.id}][${component}]`)
      }
      return componentVm.$el
    }
  }
  return component.$el
}
 
export function elementMatchesPolyfill (Element) {
  if (!Element.matches) {
    Element.matches =
        Element.matchesSelector ||
        Element.mozMatchesSelector ||
        Element.msMatchesSelector ||
        Element.oMatchesSelector ||
        Element.webkitMatchesSelector ||
        function (s) {
          var matches = (this.document || this.ownerDocument).querySelectorAll(s)
          var i = matches.length
          while (--i >= 0 && matches.item(i) !== this) {}
          return i > -1
        }
  }
  return Element
}