Skip to content

Commit

Permalink
refactor: extract some utility code
Browse files Browse the repository at this point in the history
Code splitting for better testing and mantainability
  • Loading branch information
matteobad committed May 1, 2019
1 parent 0183590 commit 8831003
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
7 changes: 2 additions & 5 deletions rollup.config.js
Expand Up @@ -2,14 +2,11 @@ import { eslint } from 'rollup-plugin-eslint'
import { terser } from 'rollup-plugin-terser'
import pkg from './package.json'

const isDev = process.env.BUILD === 'development'

let external = Object.keys(pkg.dependencies)
let plugins = [eslint()]

if (!isDev) {
plugins.push(terser())
}
const isDev = process.env.BUILD === 'development'
if (!isDev) plugins.push(terser())

export default {
input: 'src/focus-within.js',
Expand Down
34 changes: 0 additions & 34 deletions src/utils.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/utils/supportsFocusWithin.js
@@ -0,0 +1,16 @@
/**
* Check for :focus-within pseudo class support
* @returns {Boolean}
*/
function supportsFocusWithin () {
try {
document.querySelector(':focus-within')
console.info('focus-within-polyfill: focus-within supported')
return true
} catch (error) {
console.info('focus-within-polyfill: focus-within not supported')
return false
}
}

export default supportsFocusWithin

0 comments on commit 8831003

Please sign in to comment.