@vaadin/vaadin-custom-field
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -13,3 +13,3 @@ { | ||
"name": "@vaadin/vaadin-custom-field", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"main": "vaadin-custom-field.js", | ||
@@ -16,0 +16,0 @@ "author": "Vaadin Ltd", |
@@ -83,4 +83,13 @@ import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js'; | ||
const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); | ||
this.addEventListener('keydown', e => { | ||
if (e.keyCode === 9) { | ||
// FIXME (yuriy): remove this workaround once this issue is fixed: | ||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1014868&can=2&num=100&q=slot%20shift%20tab | ||
if (e.target.parentElement.localName === 'slot' && | ||
!e.defaultPrevented && isChrome) { | ||
const slot = e.target.parentElement; | ||
slot.setAttribute('tabindex', -1); | ||
setTimeout(() => slot.removeAttribute('tabindex')); | ||
} | ||
if (this.inputs.indexOf(e.target) < this.inputs.length - 1 && !e.shiftKey || | ||
@@ -138,15 +147,19 @@ this.inputs.indexOf(e.target) > 0 && e.shiftKey) { | ||
/* Like querySelectorAll('*') but also gets all elements through any nested slots recursively */ | ||
__queryAllAssignedElements(elem) { | ||
const result = []; | ||
let elements; | ||
if (elem.tagName === 'SLOT') { | ||
elements = elem.assignedNodes({flatten: true}).filter(node => node.nodeType === Node.ELEMENT_NODE); | ||
} else { | ||
result.push(elem); | ||
elements = Array.from(elem.children); | ||
} | ||
elements.forEach(elem => result.push(...this.__queryAllAssignedElements(elem))); | ||
return result; | ||
} | ||
__getInputsFromSlot() { | ||
const isInput = (node => node.validate || node.checkValidity); | ||
const slottedElements = this.$.slot.assignedNodes({flatten: true}).filter(node => node.nodeType === Node.ELEMENT_NODE); | ||
const inputs = []; | ||
slottedElements.forEach(elem => { | ||
if (isInput(elem)) { | ||
inputs.push(elem); | ||
} else { | ||
const newInputs = Array.from(elem.querySelectorAll('*')).filter(isInput); | ||
inputs.push(...newInputs); | ||
} | ||
}); | ||
return inputs; | ||
return this.__queryAllAssignedElements(this.$.slot).filter(isInput); | ||
} | ||
@@ -153,0 +166,0 @@ |
@@ -92,3 +92,3 @@ /** | ||
static get version() { | ||
return '1.0.8'; | ||
return '1.0.9'; | ||
} | ||
@@ -95,0 +95,0 @@ |
33373
475