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

add multi-selector rules test cases, fix #5 #9

Merged
merged 1 commit into from Feb 15, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
@@ -1,8 +1,9 @@
2.2 2017/2/15
2.3 2017/2/15

* refactor
* add npm badge
* support rules with non-bidi declarations
* support multiple selectors in a rule

2.1 2017/2/8

Expand Down
8 changes: 8 additions & 0 deletions index.js
Expand Up @@ -150,9 +150,17 @@ module.exports = postcss.plugin('postcss-bidirection', function (opts) {
updateRtlItem(item);

root.insertAfter(item.rule, item.rtlRule);

// overwrite rtlRule.raws.before since its been lazy evaluated
item.rtlRule.raws.before = '\n\nhtml[dir="rtl"] ';

// multiple selectors in a rule
let selectors = item.rtlRule.selector.split(/\s*[,\n]+\s*/);
if (selectors.length) {
item.rtlRule.selector =
selectors.join(',\nhtml[dir="rtl"] ');
}

log('<', item.rule.raws.before,
'>', item.rtlRule.raws.before);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "postcss-bidirection",
"version": "2.2.0",
"version": "2.3.0",
"description": "PostCSS plugin that polyfill Mozilla's Bi-directional CSS proposal to suppot direction-sensitive rules, a.k.a Left-To-Right (LTR) and Right-To-Left (RTL), in single syntax",
"keywords": [
"postcss",
Expand Down
8 changes: 8 additions & 0 deletions tests/fixtures/multi-selectors-input.css
@@ -0,0 +1,8 @@
.file svg,
.domain svg,
.folder svg,
.refresh svg,
.worker svg {
top: 7px;
margin-inline-end: 5px;
}
16 changes: 16 additions & 0 deletions tests/fixtures/multi-selectors-output.css
@@ -0,0 +1,16 @@
.file svg,
.domain svg,
.folder svg,
.refresh svg,
.worker svg {
top: 7px;
margin-right: 5px;
}

html[dir="rtl"] .file svg,
html[dir="rtl"] .domain svg,
html[dir="rtl"] .folder svg,
html[dir="rtl"] .refresh svg,
html[dir="rtl"] .worker svg {
margin-left: 5px;
}
5 changes: 5 additions & 0 deletions tests/test.js
Expand Up @@ -270,3 +270,8 @@ test('text-align start', t => {
const { input, output } = read('text-align');
return run(t, input, output, { });
});

test('should render rtl before each multi-selector rule', t => {
const { input, output } = read('multi-selectors');
return run(t, input, output, { });
});