Skip to content

Commit

Permalink
Merge pull request #1 from nota/es5
Browse files Browse the repository at this point in the history
ES2015の記法を撤去
  • Loading branch information
mountainboooy committed Feb 18, 2019
2 parents 53df0c6 + cd454f2 commit c05722c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function () {
// is keyboard last used input source?
let wasKeyboardInput = false
var wasKeyboardInput = false

const modifierKeys = [
var modifierKeys = [
16, // shift
17, // control
18, // alt
Expand All @@ -12,9 +12,9 @@
]

function supportsPassiveEvent () {
let exist = false
var exist = false
try {
const opts = Object.defineProperty({}, 'passive', {
var opts = Object.defineProperty({}, 'passive', {
get: function () { exist = true }
})
window.addEventListener('test', null, opts)
Expand All @@ -25,8 +25,8 @@
function init () {
// set useCapture to true to capture all events
// some components like Boostrap Dropdown menu call stopPropagate()
const useCapture = true
const options = supportsPassiveEvent()
var useCapture = true
var options = supportsPassiveEvent()
? { passive: true, capture: useCapture }
: useCapture

Expand All @@ -48,17 +48,17 @@
}

function updateDoc () {
const body = document.body
var body = document.body
if (wasKeyboardInput) {
body.dataset.focusVisible = ''
} else {
delete body.dataset.focusVisible
}
// add class that can not apply css with [data-focus-visible] selector
// eg: input[type="range"]:focus::-webkit-slider-thumb
const elements = document.querySelectorAll('[data-require-focus-visible-class]')
for (let i = 0; i < elements.length; i++) {
const element = elements[i]
var elements = document.querySelectorAll('[data-require-focus-visible-class]')
for (var i = 0; i < elements.length; i++) {
var element = elements[i]
if (wasKeyboardInput) {
element.classList.add('focus-visible')
} else {
Expand Down

0 comments on commit c05722c

Please sign in to comment.