makeup-focusables
Advanced tools
Comparing version 0.0.3 to 0.0.4
21
index.js
'use strict'; | ||
var focusableElList = ['a[href]', 'area[href]', 'button:not([disabled])', 'embed', 'iframe', 'input:not([disabled])', 'object', 'select:not([disabled])', 'textarea:not([disabled])', '*[tabindex]', '*[contenteditable]']; | ||
var focusableElSelector = focusableElList.join(); | ||
module.exports = function (el) { | ||
var keyboardOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var keyboardOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var focusableEls = Array.prototype.slice.call(el.querySelectorAll(focusableElSelector)); // filter out elements with display: none | ||
var focusableEls = Array.prototype.slice.call(el.querySelectorAll(focusableElSelector)); | ||
focusableEls = focusableEls.filter(function (focusableEl) { | ||
return window.getComputedStyle(focusableEl).display !== 'none'; | ||
}); | ||
// filter out elements with display: none | ||
if (keyboardOnly === true) { | ||
focusableEls = focusableEls.filter(function (focusableEl) { | ||
return window.getComputedStyle(focusableEl).display !== 'none'; | ||
return focusableEl.getAttribute('tabindex') !== '-1'; | ||
}); | ||
} | ||
if (keyboardOnly === true) { | ||
focusableEls = focusableEls.filter(function (focusableEl) { | ||
return focusableEl.getAttribute('tabindex') !== '-1'; | ||
}); | ||
} | ||
return focusableEls; | ||
return focusableEls; | ||
}; |
{ | ||
"name": "makeup-focusables", | ||
"description": "Returns an array of all focusable descendants of the given element", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
@@ -11,18 +11,18 @@ "repository": "https://github.com/makeup-js/makeup-focusables.git", | ||
"start": "npm run build && parallelshell \"npm run server\" \"npm run watch\"", | ||
"test": "npm run transpile && npm run lasso:test && npm run clean && karma start --autoWatch false --singleRun true", | ||
"prepublishOnly": "npm run clean && npm run lint && npm run build && npm run test", | ||
"build": "npm run transpile && npm run lasso", | ||
"test": "npm run build:module && npm run lasso:tests && karma start --autoWatch false --singleRun true", | ||
"prepublishOnly": "npm run lint && npm run test && npm run clean:tests && npm run build:docs", | ||
"prep": "npm run prepublishOnly", | ||
"build": "npm run build:module && npm run build:docs", | ||
"build:module": "babel src/index.js --out-file index.js", | ||
"build:docs": "babel docs/src/index.js --out-file docs/index.js && npm run lasso:docs && npm run clean:docs", | ||
"fix": "eslint src/index.js --fix", | ||
"lint": "eslint src/index.js > lint.txt", | ||
"lasso": "lasso require-run:./docs/index.js --out docs/static --inject-into docs/index.html --name bundle && npm run clean:lasso", | ||
"lasso:test": "lasso require-run:./test/index.js --name bundle-test --out test/static --config ./test/lasso-config.json && npm run clean:lasso", | ||
"clean": "rimraf reports .DS_Store test/.DS_Store src/.DS_Store docs/.DS_Store && npm run clean:lasso", | ||
"clean:lasso": "rimraf .cache build", | ||
"lint": "eslint src/index.js > lint.txt && eslint docs/src/index.js > lint.txt", | ||
"lasso:docs": "lasso require-run:./docs/index.js --out docs/static --inject-into docs/index.html --name bundle", | ||
"lasso:tests": "npm run clean:tests && lasso require-run:./test/index.js --name bundle-test --out test/static --config ./test/lasso-config.json", | ||
"clean:docs": "rimraf .cache build docs/index.js", | ||
"clean:tests": "rimraf lint.txt reports", | ||
"server": "browser-sync start -s --ss docs --index docs/index.html --files docs/index.html", | ||
"watch": "onchange src/*.js docs/index.js -- npm run build", | ||
"transpile": "babel src/index.js --out-file index.js" | ||
"watch": "onchange src/*.js docs/src/index.js -- npm run build", | ||
"version": "npm run prepublishOnly && git add -A docs/static test/static" | ||
}, | ||
"pre-commit": [ | ||
"prepublishOnly" | ||
], | ||
"keywords": [ | ||
@@ -35,19 +35,21 @@ "makeup", | ||
"devDependencies": { | ||
"babel-cli": "^6", | ||
"@babel/cli": "^7", | ||
"@babel/core": "^7", | ||
"@babel/preset-env": "^7", | ||
"babel-plugin-transform-object-assign": "^6", | ||
"babel-preset-env": "^1", | ||
"browser-sync": "^2", | ||
"core-js-pure": "^3", | ||
"coveralls": "^3", | ||
"eslint": "^4", | ||
"eslint-config-ebay": "~0.1", | ||
"jasmine-core": "^2", | ||
"karma": "^1", | ||
"eslint": "^5", | ||
"eslint-config-ebay": "^1", | ||
"jasmine-core": "^3", | ||
"karma": "^4", | ||
"karma-chrome-launcher": "^2", | ||
"karma-coverage": "^1", | ||
"karma-html-reporter": "~0.2", | ||
"karma-jasmine": "^1", | ||
"karma-phantomjs-launcher": "^1", | ||
"karma-jasmine": "^2", | ||
"lasso-cli": "^2", | ||
"onchange": "^3", | ||
"onchange": "^5", | ||
"parallelshell": "^3", | ||
"pre-commit": "^1", | ||
"puppeteer": "^1", | ||
"rimraf": "^2" | ||
@@ -54,0 +56,0 @@ }, |
@@ -72,2 +72,6 @@ # makeup-focusables | ||
## Polyfills | ||
* None | ||
## Development | ||
@@ -82,7 +86,2 @@ | ||
The following hooks exist, and do not need to be invoked manually: | ||
* `npm prepublishOnly` cleans, lints, tests and builds on every `npm publish` command | ||
* `pre-commit` cleans, lints, tests and builds on every `git commit` command | ||
## Test Reports | ||
@@ -89,0 +88,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
251419
0
20
21
99