-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix class + element matches #8
Changes from all commits
0849370
5067c3d
82f9463
681606c
ad99f24
e45fdfa
50f9960
5a3d7ce
07a3bb2
5f8a6db
ce6a610
12a7986
e565aff
ab7f214
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,3 +1,6 @@ | ||
{ | ||
"stage": 0 | ||
"presets": [ | ||
"es2015", | ||
"stage-2" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
dist | ||
node_modules | ||
npm-debug.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- "6" | ||
- "4" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,21 @@ import balancedMatch from "balanced-match" | |
|
||
const pseudoClass = ":matches" | ||
|
||
function isElementSelector(selector) { | ||
return !selector.match(/(\:|\.)/g) | ||
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. Any feedback about this Regex? If you have any dot or colon then you are not an element. 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. I guess according to the tests, it's ok? 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. @MoOx everything pass 😄 |
||
} | ||
|
||
function normalizeSelector(selector, preWhitespace, pre) { | ||
const selectorIsElement = isElementSelector(selector) | ||
const preIsElement = isElementSelector(pre) | ||
|
||
if (selectorIsElement && !preIsElement) { | ||
return `${preWhitespace}${selector}${pre}` | ||
} | ||
|
||
return `${preWhitespace}${pre}${selector}` | ||
} | ||
|
||
function explodeSelector(selector, options) { | ||
if (selector && selector.indexOf(pseudoClass) > -1) { | ||
let newSelectors = [] | ||
|
@@ -33,7 +48,9 @@ function explodeSelector(selector, options) { | |
|
||
let newParts | ||
if (postSelectors.length === 0) { | ||
newParts = bodySelectors.map((s) => preWhitespace + pre + s) | ||
newParts = bodySelectors.map((s) => { | ||
return normalizeSelector(s, preWhitespace, pre) | ||
}) | ||
} | ||
else { | ||
newParts = [] | ||
|
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.
@MoOx I need your confirmation that this is the correct configuration. When I upgraded the package the configuration changed to this style. Please confirm that this is correct.
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.
lgtm