Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = postcss.plugin('postcss-mpvue-wxss', function (options) {
}
}
});

root.walkRules(rule => {
const { selector } = rule || {};

Expand All @@ -54,7 +54,7 @@ module.exports = postcss.plugin('postcss-mpvue-wxss', function (options) {
selectors.each(function (selector) {
selector.each(function (n) {
// 转换 tag 选择器
if (n.type === 'tag') {
if (n.type === 'tag'||n.type === 'universal') {
const k = n.value;
const v = options.replaceTagSelector[k];
if (v) {
Expand Down
9 changes: 8 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,25 @@ it('test replaceTagSelector with options', () => {
}
bbb {
width: 60rpx;
}
* {
box-sizing: border-box;
}`;
const output = `
._aaa {
width: 50rpx;
}
ccc, .ddd {
width: 60rpx;
}
view, text {
box-sizing: border-box;
}`;
const options = {
replaceTagSelector: {
aaa: 'replaceToClass',
bbb: 'ccc, .ddd'
bbb: 'ccc, .ddd',
'*': 'view, text'
}
};
return run(input, output, options);
Expand Down