New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

makeup-roving-tabindex

Package Overview
Dependencies
Maintainers
5
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makeup-roving-tabindex - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

2

browser.json
{
"dependencies":[
"require-run: custom-event-polyfill",
"require-run: nodelist-foreach-polyfill",
"require: ./index.js"
]
}

252

index.js
'use strict';
/* Requires following polyfills or transforms for IE11
* Object.assign
* NodeList.forEach
* CustomEvent
*/
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var NavigationEmitter = require('makeup-navigation-emitter');
var Util = require('./util.js');
var defaultOptions = {
autoReset: null,
index: 0,
wrap: false
autoReset: null,
index: 0,
wrap: false
};
function onModelMutation() {
var modelIndex = this._navigationEmitter.model.index;
var modelIndex = this._navigationEmitter.model.index;
this._items.forEach(function (el, index) {
return el.setAttribute('tabindex', index !== modelIndex ? '-1' : '0');
});
this._items.forEach(function (el, index) {
return el.setAttribute('tabindex', index !== modelIndex ? '-1' : '0');
});
}
function onModelInit(e) {
this._index = e.detail.toIndex; // seems unused internally. scheduled for deletion.
this._index = e.detail.toIndex; // seems unused internally. scheduled for deletion.
var items = this._items;
var items = this._items;
items.filter(function (el, index) {
return index !== e.detail.toIndex;
}).forEach(function (el) {
return el.setAttribute('tabindex', '-1');
});
items[e.detail.toIndex].setAttribute('tabindex', '0');
_toConsumableArray(items).filter(function (el, index) {
return index !== e.detail.toIndex;
}).forEach(function (el) {
return el.setAttribute('tabindex', '-1');
});
items[e.detail.toIndex].setAttribute('tabindex', '0');
}
function onModelReset(e) {
this._index = e.detail.toIndex; // seems unused internally. scheduled for deletion.
this._index = e.detail.toIndex; // seems unused internally. scheduled for deletion.
var items = this._items;
var items = this._items;
items.filter(function (el, index) {
return index !== e.detail.toIndex;
}).forEach(function (el) {
return el.setAttribute('tabindex', '-1');
});
items[e.detail.toIndex].setAttribute('tabindex', '0');
_toConsumableArray(items).filter(function (el, index) {
return index !== e.detail.toIndex;
}).forEach(function (el) {
return el.setAttribute('tabindex', '-1');
});
items[e.detail.toIndex].setAttribute('tabindex', '0');
}
function onModelChange(e) {
var items = this._items;
var items = this._items;
var fromItem = items[e.detail.fromIndex];
var toItem = items[e.detail.toIndex];
var fromItem = items[e.detail.fromIndex];
var toItem = items[e.detail.toIndex];
if (fromItem) {
fromItem.setAttribute('tabindex', '-1');
}
if (fromItem) {
fromItem.setAttribute('tabindex', '-1');
}
if (toItem) {
toItem.setAttribute('tabindex', '0');
toItem.focus();
}
if (toItem) {
toItem.setAttribute('tabindex', '0');
toItem.focus();
this._el.dispatchEvent(new CustomEvent('rovingTabindexChange', {
detail: {
fromIndex: e.detail.fromIndex,
toIndex: e.detail.toIndex
}
this._el.dispatchEvent(new CustomEvent('rovingTabindexChange', {
detail: {
fromIndex: e.detail.fromIndex,
toIndex: e.detail.toIndex
}
}));
}));
}
var RovingTabindex = function () {
function RovingTabindex(el) {
_classCallCheck(this, RovingTabindex);
var RovingTabindex =
/*#__PURE__*/
function () {
function RovingTabindex(el) {
_classCallCheck(this, RovingTabindex);
this._el = el;
this._onMutationListener = onModelMutation.bind(this);
this._onChangeListener = onModelChange.bind(this);
this._onInitListener = onModelInit.bind(this);
this._onResetListener = onModelReset.bind(this);
this._el = el;
this._onMutationListener = onModelMutation.bind(this);
this._onChangeListener = onModelChange.bind(this);
this._onInitListener = onModelInit.bind(this);
this._onResetListener = onModelReset.bind(this);
this._el.addEventListener('navigationModelMutation', this._onMutationListener);
this._el.addEventListener('navigationModelChange', this._onChangeListener);
this._el.addEventListener('navigationModelInit', this._onInitListener);
this._el.addEventListener('navigationModelReset', this._onResetListener);
}
this._el.addEventListener('navigationModelMutation', this._onMutationListener);
_createClass(RovingTabindex, [{
key: 'destroy',
value: function destroy() {
this._el.removeEventListener('navigationModelMutation', this._onMutationListener);
this._el.removeEventListener('navigationModelChange', this._onChangeListener);
this._el.removeEventListener('navigationModelInit', this._onInitListener);
this._el.removeEventListener('navigationModelReset', this._onResetListener);
}
}]);
this._el.addEventListener('navigationModelChange', this._onChangeListener);
return RovingTabindex;
}();
this._el.addEventListener('navigationModelInit', this._onInitListener);
var LinearRovingTabindex = function (_RovingTabindex) {
_inherits(LinearRovingTabindex, _RovingTabindex);
this._el.addEventListener('navigationModelReset', this._onResetListener);
}
function LinearRovingTabindex(el, itemSelector, selectedOptions) {
_classCallCheck(this, LinearRovingTabindex);
_createClass(RovingTabindex, [{
key: "destroy",
value: function destroy() {
this._el.removeEventListener('navigationModelMutation', this._onMutationListener);
var _this = _possibleConstructorReturn(this, (LinearRovingTabindex.__proto__ || Object.getPrototypeOf(LinearRovingTabindex)).call(this, el));
this._el.removeEventListener('navigationModelChange', this._onChangeListener);
_this._options = _extends({}, defaultOptions, selectedOptions);
this._el.removeEventListener('navigationModelInit', this._onInitListener);
_this._itemSelector = itemSelector;
_this._navigationEmitter = NavigationEmitter.createLinear(el, itemSelector, {
autoInit: _this._options.index,
autoReset: _this._options.autoReset,
wrap: _this._options.wrap
});
return _this;
this._el.removeEventListener('navigationModelReset', this._onResetListener);
}
}]);
_createClass(LinearRovingTabindex, [{
key: 'destroy',
value: function destroy() {
this._navigationEmitter.destroy();
}
}, {
key: 'index',
get: function get() {
return this._navigationEmitter.model.index;
},
set: function set(newIndex) {
this._navigationEmitter.model.index = newIndex;
}
}, {
key: 'wrap',
set: function set(newWrap) {
this._navigationEmitter.model.options.wrap = newWrap;
}
return RovingTabindex;
}();
// we cannot use a cached version of the items in question since the DOM may change without notice
var LinearRovingTabindex =
/*#__PURE__*/
function (_RovingTabindex) {
_inherits(LinearRovingTabindex, _RovingTabindex);
}, {
key: '_items',
get: function get() {
return Util.querySelectorAllToArray(this._itemSelector, this._el);
}
}]);
function LinearRovingTabindex(el, itemSelector, selectedOptions) {
var _this;
return LinearRovingTabindex;
_classCallCheck(this, LinearRovingTabindex);
_this = _possibleConstructorReturn(this, _getPrototypeOf(LinearRovingTabindex).call(this, el));
_this._options = _extends({}, defaultOptions, selectedOptions);
_this._itemSelector = itemSelector;
_this._navigationEmitter = NavigationEmitter.createLinear(el, itemSelector, {
autoInit: _this._options.index,
autoReset: _this._options.autoReset,
wrap: _this._options.wrap
});
return _this;
}
_createClass(LinearRovingTabindex, [{
key: "destroy",
value: function destroy() {
this._navigationEmitter.destroy();
}
}, {
key: "index",
get: function get() {
return this._navigationEmitter.model.index;
},
set: function set(newIndex) {
this._navigationEmitter.model.index = newIndex;
}
}, {
key: "wrap",
set: function set(newWrap) {
this._navigationEmitter.model.options.wrap = newWrap;
} // we cannot use a cached version of the items in question since the DOM may change without notice
}, {
key: "_items",
get: function get() {
return this._el.querySelectorAll(this._itemSelector);
}
}]);
return LinearRovingTabindex;
}(RovingTabindex);
/*

@@ -167,8 +196,9 @@ class GridRovingTabindex extends RovingTabindex {

function createLinear(el, itemSelector, selectedOptions) {
return new LinearRovingTabindex(el, itemSelector, selectedOptions);
return new LinearRovingTabindex(el, itemSelector, selectedOptions);
}
module.exports = {
createLinear: createLinear
createLinear: createLinear
};
{
"name": "makeup-roving-tabindex",
"description": "Implements a roving tab index on given collection of elements",
"version": "0.1.3",
"version": "0.2.0",
"main": "index.js",

@@ -11,14 +11,16 @@ "repository": "https://github.com/makeup-js/makeup-roving-tabindex.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",
"fix": "eslint src/index.js src/util.js --fix",
"lint": "eslint src/index.js src/util.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",
"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 && 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 && babel src/util.js --out-file util.js",
"watch": "onchange src/*.js docs/src/index.js -- npm run build",
"version": "npm run prepublishOnly && git add -A docs/static test/static"

@@ -33,6 +35,8 @@ },

"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",

@@ -43,13 +47,16 @@ "eslint": "^5",

"karma": "^4",
"karma-chrome-launcher": "^2",
"karma-coverage": "^1",
"karma-html-reporter": "~0.2",
"karma-jasmine": "^2",
"karma-phantomjs-launcher": "^1",
"lasso-cli": "^2",
"onchange": "^5",
"parallelshell": "^3",
"puppeteer": "^1",
"rimraf": "^2"
},
"dependencies": {
"makeup-navigation-emitter": "~0.1.4"
"custom-event-polyfill": "^1",
"makeup-navigation-emitter": "~0.2.0",
"nodelist-foreach-polyfill": "^1"
},

@@ -59,5 +66,4 @@ "files": [

"index.js",
"util.js",
"yarn.lock"
]
}

@@ -95,2 +95,7 @@ # makeup-roving-tabindex

## Requirements
* CustomEvent polyfill for IE11 (included if bundling with Lasso)
* NodeList.forEach polyfill for IE11 (included if bundling with Lasso)
## Development

@@ -97,0 +102,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc