-
Notifications
You must be signed in to change notification settings - Fork 781
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: deprecate axe.imports and upgrade to css-selector-parser 3 #4264
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
import { CssSelectorParser } from 'css-selector-parser'; | ||||||
import { createParser } from 'css-selector-parser'; | ||||||
import doT from '@deque/dot'; | ||||||
import emojiRegexText from 'emoji-regex'; | ||||||
import memoize from 'memoizee'; | ||||||
|
@@ -40,10 +40,36 @@ if (window.Uint32Array) { | |||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* @deprecated | ||||||
*/ | ||||||
class CSSSelectorParser { | ||||||
constructor() { | ||||||
this.parser = createParser({ | ||||||
syntax: { | ||||||
pseudoClasses: { | ||||||
definitions: { | ||||||
Selector: ['is', 'not'] | ||||||
} | ||||||
}, | ||||||
combinators: ['>'], | ||||||
attributes: { | ||||||
operators: ['^=', '$=', '*=', '~='] | ||||||
} | ||||||
} | ||||||
}); | ||||||
} | ||||||
|
||||||
parse(selector) { | ||||||
return this.parser.parse(selector); | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* Namespace `axe.imports` which holds required external dependencies | ||||||
* | ||||||
* @namespace imports | ||||||
* @deprecated | ||||||
* @memberof axe | ||||||
*/ | ||||||
export { CssSelectorParser, doT, emojiRegexText, memoize, Color as Colorjs }; | ||||||
export { CSSSelectorParser, doT, emojiRegexText, memoize, Color as Colorjs }; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't update the casing of CSS otherwise this is a breaking change
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import { CssSelectorParser } from 'css-selector-parser'; | ||
import { createParser } from 'css-selector-parser'; | ||
|
||
const parser = new CssSelectorParser(); | ||
parser.registerSelectorPseudos('not'); | ||
parser.registerSelectorPseudos('is'); | ||
parser.registerNestingOperators('>'); | ||
parser.registerAttrEqualityMods('^', '$', '*', '~'); | ||
const parse = createParser({ | ||
syntax: { | ||
pseudoClasses: { | ||
definitions: { | ||
Selector: ['is', 'not'] | ||
} | ||
}, | ||
combinators: ['>'], | ||
attributes: { | ||
operators: ['^=', '$=', '*=', '~='] | ||
} | ||
} | ||
}); | ||
|
||
export default parser; | ||
export default { parse }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changed the export to a named export so you'll also need to update the import in matches. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class isn't a 1:1 back compatible wrapper. The return of
CssSelectorParser
was a class, but the class also had additional functions that were used to configure the parser (registerSelectorPseudos
,registerNestingOperators
, etc.). In order to fully be back compatible, this class would need to implement those functions and probably then callcreateParser
in theparse
function with all the settings the user has set using the configuration functions.