initial commit
This commit is contained in:
commit
026f835a87
176 changed files with 10613 additions and 0 deletions
23
src/app/atoms/button/script.js
Normal file
23
src/app/atoms/button/script.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* blur [selector] element in bubbling path.
|
||||
* @param {Event} e Event
|
||||
* @param {string} selector element selector for Element.matches([selector])
|
||||
* @return {boolean} if blured return true, else return false with warning in console
|
||||
*/
|
||||
|
||||
function blurOnBubbling(e, selector) {
|
||||
const bubblingPath = e.nativeEvent.composedPath();
|
||||
|
||||
for (let elIndex = 0; elIndex < bubblingPath.length; elIndex += 1) {
|
||||
if (bubblingPath[elIndex] === document) {
|
||||
console.warn(blurOnBubbling, 'blurOnBubbling: not found selector in bubbling path');
|
||||
break;
|
||||
}
|
||||
if (bubblingPath[elIndex].matches(selector)) {
|
||||
setTimeout(() => bubblingPath[elIndex].blur(), 50);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export { blurOnBubbling };
|
||||
Loading…
Add table
Add a link
Reference in a new issue