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

Support for selector escape characters #8

Closed
yisibl opened this issue Mar 23, 2022 · 1 comment
Closed

Support for selector escape characters #8

yisibl opened this issue Mar 23, 2022 · 1 comment
Labels
wontfix This will not be worked on

Comments

@yisibl
Copy link

yisibl commented Mar 23, 2022

import Specificity from '@bramus/specificity'
const [specificity] = Specificity.calculate('not(#\9) .foo')
console.log(specificity.value)
const [specificity] = Specificity.calculate('not(#\9) .foo');
                                                  ^
SyntaxError: \8 and \9 are not allowed in strict mode.
    at Loader.moduleStrategy (node:internal/modules/esm/translators:146:18)
    at async link (node:internal/modules/esm/module_job:67:21)

Expected output {a: 1, b: 1, c: 0 }

@bramus
Copy link
Owner

bramus commented Mar 23, 2022

This is a side-effect of using strict mode, which is runtime related. This package is exposed as an ECMAScript module, which uses strict mode by default, so I don't think there's a way to fix it there, and I would make me label this as “Intended Behavior”.

As a workaround, though, you can use the CJS build of the package (which does not use strict mode):

const Specificity = require('@bramus/specificity').default;
console.log(Specificity.calculate(':not(#\9) .foo')[0].value); // { a: 1, b: 1, c: 0 }

I did notice that when importing the build from Skypack, it does work, as seen in this CodePen demo.

import Specificity from "https://cdn.skypack.dev/@bramus/specificity@next";

@bramus bramus added the wontfix This will not be worked on label Mar 24, 2022
@bramus bramus closed this as completed Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants