-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2135 from dequelabs/esModulesCommonsMatches
chore: convert commons.matches to ES Modules
- Loading branch information
Showing
12 changed files
with
134 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
*/ | ||
|
||
var commons = {}; | ||
var matches; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,31 @@ | ||
/* exported matches */ | ||
/* global matches */ | ||
|
||
/** | ||
* Check if a virtual node matches a definition | ||
* | ||
* Example: | ||
* ```js | ||
* // Match a single nodeName: | ||
* axe.commons.matches(vNode, 'div') | ||
* | ||
* // Match one of multiple nodeNames: | ||
* axe.commons.matches(vNode, ['ul', 'ol']) | ||
* | ||
* // Match a node with nodeName 'button' and with aria-hidden: true: | ||
* axe.commons.matches(vNode, { | ||
* nodeName: 'button', | ||
* attributes: { 'aria-hidden': 'true' } | ||
* }) | ||
* | ||
* // Mixed input. Match button nodeName, input[type=button] and input[type=reset] | ||
* axe.commons.matches(vNode, ['button', { | ||
* nodeName: 'input', // nodeName match isn't case sensitive | ||
* properties: { type: ['button', 'reset'] } | ||
* }]) | ||
* ``` | ||
* | ||
* @deprecated HTMLElement is deprecated, use VirtualNode instead | ||
* | ||
* @namespace matches | ||
* @memberof axe.commons | ||
* @param {HTMLElement|VirtualNode} vNode virtual node to verify attributes against constraints | ||
* @param {Array<ElementDefinition>|String|Object|Function|Regex} definition | ||
* @return {Boolean} true/ false based on if vNode passes the constraints expected | ||
* Namespace for matching utilities. | ||
* @namespace commons.matches | ||
* @memberof axe | ||
*/ | ||
function matches(vNode, definition) { | ||
return matches.fromDefinition(vNode, definition); | ||
} | ||
import attributes from './attributes'; | ||
import condition from './condition'; | ||
import fromDefinition from './from-definition'; | ||
import fromFunction from './from-function'; | ||
import fromPrimative from './from-primative'; | ||
// TODO: es-module-commons. change to: | ||
// import matches from './matches' | ||
import matchesFn from './matches'; | ||
import nodeName from './node-name'; | ||
import properties from './properties'; | ||
|
||
commons.matches = matches; | ||
// TODO: es-module-commons. remove matches setter | ||
matches = matchesFn; | ||
matches.attributes = attributes; | ||
matches.condition = condition; | ||
matches.fromDefinition = fromDefinition; | ||
matches.fromFunction = fromFunction; | ||
matches.fromPrimative = fromPrimative; | ||
matches.nodeName = nodeName; | ||
matches.properties = properties; | ||
|
||
// TODO: es-module-commons. convert to: | ||
// export default matches | ||
commons.matches = matchesFn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import fromDefinition from './from-definition'; | ||
|
||
/** | ||
* Check if a virtual node matches a definition | ||
* | ||
* Example: | ||
* ```js | ||
* // Match a single nodeName: | ||
* axe.commons.matches(vNode, 'div') | ||
* | ||
* // Match one of multiple nodeNames: | ||
* axe.commons.matches(vNode, ['ul', 'ol']) | ||
* | ||
* // Match a node with nodeName 'button' and with aria-hidden: true: | ||
* axe.commons.matches(vNode, { | ||
* nodeName: 'button', | ||
* attributes: { 'aria-hidden': 'true' } | ||
* }) | ||
* | ||
* // Mixed input. Match button nodeName, input[type=button] and input[type=reset] | ||
* axe.commons.matches(vNode, ['button', { | ||
* nodeName: 'input', // nodeName match isn't case sensitive | ||
* properties: { type: ['button', 'reset'] } | ||
* }]) | ||
* ``` | ||
* | ||
* @deprecated HTMLElement is deprecated, use VirtualNode instead | ||
* | ||
* @namespace matches | ||
* @memberof axe.commons | ||
* @param {HTMLElement|VirtualNode} vNode virtual node to verify attributes against constraints | ||
* @param {Array<ElementDefinition>|String|Object|Function|Regex} definition | ||
* @return {Boolean} true/ false based on if vNode passes the constraints expected | ||
*/ | ||
function matches(vNode, definition) { | ||
return fromDefinition(vNode, definition); | ||
} | ||
|
||
export default matches; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters