(btn, doc)
| 12473 | } |
| 12474 | |
| 12475 | function emuClick(btn, doc) { |
| 12476 | if (!doc) doc = document; |
| 12477 | let curScroll = getBody(doc).scrollTop || doc.documentElement.scrollTop; |
| 12478 | let orgHref = btn.getAttribute('href'); |
| 12479 | if (orgHref && orgHref.replace(location.origin + location.pathname, "").indexOf("#") === 0) { |
| 12480 | let hashAction = e => { |
| 12481 | e.preventDefault(); |
| 12482 | getBody(doc).scrollTop = curScroll; |
| 12483 | doc.documentElement.scrollTop = curScroll; |
| 12484 | btn.removeEventListener('click', hashAction, false); |
| 12485 | }; |
| 12486 | btn.addEventListener('click', hashAction, false); |
| 12487 | } |
| 12488 | if (!PointerEvent) return btn.click(); |
| 12489 | let eventParam = { |
| 12490 | isTrusted: true, |
| 12491 | altKey: false, |
| 12492 | azimuthAngle: 0, |
| 12493 | bubbles: true, |
| 12494 | button: 0, |
| 12495 | buttons: 0, |
| 12496 | clientX: 1, |
| 12497 | clientY: 1, |
| 12498 | cancelBubble: false, |
| 12499 | cancelable: true, |
| 12500 | composed: true, |
| 12501 | ctrlKey: false, |
| 12502 | defaultPrevented: false, |
| 12503 | detail: 1, |
| 12504 | eventPhase: 2, |
| 12505 | fromElement: null, |
| 12506 | height: 1, |
| 12507 | isPrimary: false, |
| 12508 | metaKey: false, |
| 12509 | pointerId: 1, |
| 12510 | pointerType: "mouse", |
| 12511 | pressure: 0, |
| 12512 | relatedTarget: null, |
| 12513 | returnValue: true, |
| 12514 | shiftKey: false, |
| 12515 | toElement: null, |
| 12516 | twist: 0, |
| 12517 | which: 1 |
| 12518 | }; |
| 12519 | let mouseEvent = new PointerEvent("mousedown", eventParam); |
| 12520 | btn.dispatchEvent(mouseEvent); |
| 12521 | mouseEvent = new PointerEvent("mouseup", eventParam); |
| 12522 | btn.dispatchEvent(mouseEvent); |
| 12523 | let dispatchTouchEvent = (ele, type) => { |
| 12524 | let touchEvent; |
| 12525 | try { |
| 12526 | touchEvent = document.createEvent('TouchEvent') |
| 12527 | touchEvent.initTouchEvent(type, true, true) |
| 12528 | } catch (err) { |
| 12529 | try { |
| 12530 | touchEvent = document.createEvent('UIEvent') |
| 12531 | touchEvent.initUIEvent(type, true, true) |
| 12532 | } catch (err) { |
no test coverage detected