Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support check evaluate functions as an id string #2162

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/core/base/check.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/*global CheckResult,DqElement */
/*global CheckResult,DqElement, metadataFunctionMap */

function createExecutionContext(spec) {
/*eslint no-eval:0 */
'use strict';
if (typeof spec === 'string') {
if (metadataFunctionMap.has(spec)) {
return metadataFunctionMap.get(spec);
}

return new Function('return ' + spec + ';')();
}
return spec;
Expand Down
9 changes: 9 additions & 0 deletions lib/core/base/metadata-function-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*eslint no-unused-vars:0*/
// TODO: es-modules-checks
// TODO: es-modules-rules
// import all check evaluate and after functions, and all rule matches functions

const metadataFunctionMap = new Map();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were going to have a map for checks and a map for rules? How will we differenciate between the different types of functions here?

For example:

map.set('some-fn', (some, args) => { /* ... */ })

Is the above for a check eval, a check after or a rule matches?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id for each function will be unique and include the type in the name. E.g. aria-allowed-attr-matches, aria-allowed-attr-evaluate, aria-allowed-attr-after


// TODO: es-modules-core
// export default metadataFunctionMap;