mdevils/css-selector-parser

Unsupported pseudo elements

Closed this issue · 4 comments

Hi. I wanted to use your npm but I have a problem. Your parser throws errors when I use ::selection pseudo-element. I looked through your code and I saw that you don't support any pseudo-elements from css 3. Could you fix this issue because I am not able to use your npm. Could you add full support for any css feature.

I mean about syntax-definitions.ts file. line number 315.

This is good solution (example)

pseudoElements: { notation: 'both', definitions: ['selection'] },

Hello @jaqba98. From your issue I didn't understand what exact CSS selector you are trying to parse and what options you are using in order to parse the selector. Could you please provide more details?

I wanted to parser this css selector:

.example::selection

And this made an error. The same situation was with others css pseudo-element which was not specified in that typescript file which I mentioned in this post.

Chech whether you can parse that css selector: .example::selection

I can fix this and make pull request if you want.

@jaqba98, oh, you mean this spec draft: https://www.w3.org/TR/css-pseudo-4/

This is not supported yet in a form of built-in css-level, but I'm going to include specs option later to include other drafts aside from selector-N ones.

For now you can define those pseudo-elements in your config, i.e. const parse = createParser({syntax: {baseSyntax: 'latest', pseudoElements: {definitions: {NoArgument: ['selection']}}}}); or just accept all unknown presudo-elements: const parse = createParser({syntax: 'progressive'}).

Hope this helps.