makeup-roving-tabindex
Advanced tools
Comparing version 0.1.2 to 0.1.3
54
index.js
@@ -26,7 +26,3 @@ 'use strict'; | ||
this._items.forEach(function (el, index) { | ||
if (index !== modelIndex) { | ||
el.setAttribute('tabindex', '-1'); | ||
} else { | ||
el.setAttribute('tabindex', '0'); | ||
} | ||
return el.setAttribute('tabindex', index !== modelIndex ? '-1' : '0'); | ||
}); | ||
@@ -36,25 +32,33 @@ } | ||
function onModelInit(e) { | ||
this._index = e.detail.toIndex; | ||
this._index = e.detail.toIndex; // seems unused internally. scheduled for deletion. | ||
this._items.forEach(function (el) { | ||
el.setAttribute('tabindex', '-1'); | ||
var items = this._items; | ||
items.filter(function (el, index) { | ||
return index !== e.detail.toIndex; | ||
}).forEach(function (el) { | ||
return el.setAttribute('tabindex', '-1'); | ||
}); | ||
this._items[e.detail.toIndex].setAttribute('tabindex', '0'); | ||
items[e.detail.toIndex].setAttribute('tabindex', '0'); | ||
} | ||
function onModelReset(e) { | ||
this._index = e.detail.toIndex; | ||
this._index = e.detail.toIndex; // seems unused internally. scheduled for deletion. | ||
this._items.forEach(function (el) { | ||
el.setAttribute('tabindex', '-1'); | ||
var items = this._items; | ||
items.filter(function (el, index) { | ||
return index !== e.detail.toIndex; | ||
}).forEach(function (el) { | ||
return el.setAttribute('tabindex', '-1'); | ||
}); | ||
this._items[e.detail.toIndex].setAttribute('tabindex', '0'); | ||
items[e.detail.toIndex].setAttribute('tabindex', '0'); | ||
} | ||
function onModelChange(e) { | ||
var fromItem = this._items[e.detail.fromIndex]; | ||
var toItem = this._items[e.detail.toIndex]; | ||
var items = this._items; | ||
var fromItem = items[e.detail.fromIndex]; | ||
var toItem = items[e.detail.toIndex]; | ||
if (fromItem) { | ||
@@ -71,4 +75,4 @@ fromItem.setAttribute('tabindex', '-1'); | ||
detail: { | ||
toIndex: e.detail.toIndex, | ||
fromIndex: e.detail.fromIndex | ||
fromIndex: e.detail.fromIndex, | ||
toIndex: e.detail.toIndex | ||
} | ||
@@ -133,2 +137,10 @@ })); | ||
}, { | ||
key: 'index', | ||
get: function get() { | ||
return this._navigationEmitter.model.index; | ||
}, | ||
set: function set(newIndex) { | ||
this._navigationEmitter.model.index = newIndex; | ||
} | ||
}, { | ||
key: 'wrap', | ||
@@ -144,3 +156,3 @@ set: function set(newWrap) { | ||
get: function get() { | ||
return Util.nodeListToArray(this._el.querySelectorAll(this._itemSelector)); | ||
return Util.querySelectorAllToArray(this._itemSelector, this._el); | ||
} | ||
@@ -154,3 +166,3 @@ }]); | ||
class GridRovingTabindex extends RovingTabindex { | ||
constructor(el, rowSelector, cellSelector) { | ||
constructor(el, rowSelector, cellSelector, selectedOptions) { | ||
super(el); | ||
@@ -157,0 +169,0 @@ } |
{ | ||
"name": "makeup-roving-tabindex", | ||
"description": "Implements a roving tab index on given collection of elements", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"main": "index.js", | ||
@@ -37,12 +37,12 @@ "repository": "https://github.com/makeup-js/makeup-roving-tabindex.git", | ||
"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-coverage": "^1", | ||
"karma-html-reporter": "~0.2", | ||
"karma-jasmine": "^1", | ||
"karma-jasmine": "^2", | ||
"karma-phantomjs-launcher": "^1", | ||
"lasso-cli": "^2", | ||
"onchange": "^3", | ||
"onchange": "^5", | ||
"parallelshell": "^3", | ||
@@ -52,3 +52,3 @@ "rimraf": "^2" | ||
"dependencies": { | ||
"makeup-navigation-emitter": "~0.1.3" | ||
"makeup-navigation-emitter": "~0.1.4" | ||
}, | ||
@@ -55,0 +55,0 @@ "files": [ |
@@ -38,3 +38,3 @@ # makeup-roving-tabindex | ||
// create a roving tabindex instance on the element | ||
const rovingTabindex = RovingTabindex.createLinear(widgetEl, 'li', { autoReset: null, index: 0 }); | ||
const rovingTabindex = RovingTabindex.createLinear(widgetEl, 'li'); | ||
@@ -73,6 +73,14 @@ // listen for events (optional) | ||
* `autoReset`: specify an index value that should receive tabindex="0" on navigationModelReset event (default: null) | ||
* `index`: the index position of the active item (default: 0) | ||
* `autoReset`: the index position that should receive the roving tabindex when model is reset (default: null) | ||
* `index`: the initial index position of the roving tabindex (default: 0) | ||
* `wrap` : specify whether arrow keys should wrap/loop (default: false) | ||
## Properties | ||
* `index`: the index position of the roving tabindex (i.e. the element with tabindex="0") | ||
## Methods | ||
* `destroy`: destroys all event listeners | ||
## Custom Events | ||
@@ -79,0 +87,0 @@ |
@@ -7,4 +7,9 @@ "use strict"; | ||
function querySelectorAllToArray(selector, parentNode) { | ||
parentNode = parentNode || document; | ||
return nodeListToArray(parentNode.querySelectorAll(selector)); | ||
} | ||
module.exports = { | ||
nodeListToArray: nodeListToArray | ||
querySelectorAllToArray: querySelectorAllToArray | ||
}; |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
240734
153
118
0