@asamuzakjp/dom-selector
Advanced tools
Comparing version 5.1.0 to 5.2.0
@@ -26,3 +26,3 @@ { | ||
"dependencies": { | ||
"@asamuzakjp/nwsapi": "^2.2.9", | ||
"@asamuzakjp/nwsapi": "^2.2.10", | ||
"bidi-js": "^1.0.3", | ||
@@ -42,3 +42,3 @@ "css-tree": "^2.3.1", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-jsdoc": "^48.11.0", | ||
"eslint-plugin-jsdoc": "^50.0.1", | ||
"eslint-plugin-regexp": "^2.6.0", | ||
@@ -49,3 +49,3 @@ "eslint-plugin-unicorn": "^55.0.0", | ||
"linkedom": "^0.18.4", | ||
"mocha": "^10.7.0", | ||
"mocha": "^10.7.3", | ||
"sinon": "^18.0.0", | ||
@@ -66,3 +66,3 @@ "typescript": "^5.5.4", | ||
}, | ||
"version": "5.1.0" | ||
"version": "5.2.0" | ||
} |
@@ -38,3 +38,2 @@ # DOM Selector | ||
- `opt` **[object][60]?** options | ||
- `opt.event` **[object][60]?** instance of MouseEvent, KeyboardEvent | ||
- `opt.noexcept` **[boolean][61]?** no exception | ||
@@ -55,3 +54,2 @@ - `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class | ||
- `opt` **[object][60]?** options | ||
- `opt.event` **[object][60]?** instance of MouseEvent, KeyboardEvent | ||
- `opt.noexcept` **[boolean][61]?** no exception | ||
@@ -72,3 +70,2 @@ - `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class | ||
- `opt` **[object][60]?** options | ||
- `opt.event` **[object][60]?** instance of MouseEvent, KeyboardEvent | ||
- `opt.noexcept` **[boolean][61]?** no exception | ||
@@ -90,3 +87,2 @@ - `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class | ||
- `opt` **[object][60]?** options | ||
- `opt.event` **[object][60]?** instance of MouseEvent, KeyboardEvent | ||
- `opt.noexcept` **[boolean][61]?** no exception | ||
@@ -136,7 +132,7 @@ - `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class | ||
|E:future|Unsupported| | | ||
|E:active|✓|Enabled if a `mousedown` / `pointerdown` event is passed as an option.| | ||
|E:hover|✓|Enabled if a `mouseover` / `pointerover` event is passed as an option.| | ||
|E:active|✓| | | ||
|E:hover|✓| | | ||
|E:focus|✓| | | ||
|E:focus‑within|✓| | | ||
|E:focus‑visible|✓|Enabled if a `keydown` event is passed as an option.| | ||
|E:focus‑visible|✓| | | ||
|E:open<br>E:closed|Partially supported|Matching with <select>, e.g. `select:open`, is not supported.| | ||
@@ -143,0 +139,0 @@ |E:enabled<br>E:disabled|✓| | |
@@ -121,7 +121,8 @@ /** | ||
export const REG_TYPE_CHECK = /^(?:checkbox|radio)$/; | ||
export const REG_TYPE_DATE = /^(?:date(?:time-local)?|month|time|week)$/; | ||
export const REG_TYPE_INPUT = | ||
/^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|week)$/; | ||
export const REG_TYPE_RANGE = | ||
/(?:date(?:time-local)?|month|number|range|time|week)$/; | ||
/^(?:date(?:time-local)?|month|number|range|time|week)$/; | ||
export const REG_TYPE_RESET = /^(?:button|reset)$/; | ||
export const REG_TYPE_SUBMIT = /^(?:image|submit)$/; | ||
export const REG_TYPE_TEXT = /^(?:email|number|password|search|tel|text|url)$/; |
@@ -14,4 +14,4 @@ /** | ||
DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, REG_DIR, REG_FILTER_COMPLEX, | ||
REG_FILTER_COMPOUND, REG_FILTER_SIMPLE, REG_SHADOW_MODE, TEXT_NODE, | ||
TYPE_FROM, TYPE_TO, WALKER_FILTER | ||
REG_FILTER_COMPOUND, REG_FILTER_SIMPLE, REG_SHADOW_MODE, REG_TYPE_INPUT, | ||
TEXT_NODE, TYPE_FROM, TYPE_TO, WALKER_FILTER | ||
} from './constant.js'; | ||
@@ -371,2 +371,64 @@ | ||
/** | ||
* is focus visible | ||
* @param {object} node - Element node | ||
* @returns {boolean} - result | ||
*/ | ||
export const isFocusVisible = node => { | ||
let res; | ||
if (node?.nodeType === ELEMENT_NODE) { | ||
const { localName, type } = node; | ||
switch (localName) { | ||
case 'input': { | ||
if (!type || REG_TYPE_INPUT.test(type)) { | ||
res = true; | ||
} | ||
break; | ||
} | ||
case 'textarea': { | ||
res = true; | ||
break; | ||
} | ||
default: { | ||
res = isContentEditable(node); | ||
} | ||
} | ||
} | ||
return !!res; | ||
}; | ||
/** | ||
* is focusable | ||
* NOTE: workaround for jsdom issue: https://github.com/jsdom/jsdom/issues/3464 | ||
* @param {object} node - Element node | ||
* @returns {boolean} - result | ||
*/ | ||
export const isFocusable = node => { | ||
let res; | ||
if (node?.nodeType === ELEMENT_NODE) { | ||
const window = node.ownerDocument.defaultView; | ||
let refNode = node; | ||
res = true; | ||
while (refNode) { | ||
if (refNode.disabled || refNode.hasAttribute('disabled') || | ||
refNode.hidden || refNode.hasAttribute('hidden')) { | ||
res = false; | ||
break; | ||
} else { | ||
const { display, visibility } = window.getComputedStyle(refNode); | ||
res = !(display === 'none' || visibility === 'hidden'); | ||
if (!res) { | ||
break; | ||
} | ||
} | ||
if (refNode.parentNode && refNode.parentNode.nodeType === ELEMENT_NODE) { | ||
refNode = refNode.parentNode; | ||
} else { | ||
break; | ||
} | ||
} | ||
} | ||
return !!res; | ||
}; | ||
/** | ||
* get namespace URI | ||
@@ -373,0 +435,0 @@ * @param {string} ns - namespace prefix |
Sorry, the diff of this file is too big to display
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
439106
4980
364
Updated@asamuzakjp/nwsapi@^2.2.10