fix(uniapp): 修复 notifications.vue 中样式未声明 scss 导致微信开发工具 wxss 嵌套报错
这个提交包含在:
@@ -35,4 +35,39 @@ describe('第九十七批小程序脚本语法闸门', () => {
|
||||
}
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
it('未声明 lang="scss" 的 <style> 中不得出现嵌套选择器,杜绝微信 WXSS unexpected { 编译报错', () => {
|
||||
const problems: string[] = [];
|
||||
for (const file of walk(root, [])) {
|
||||
const src = fs.readFileSync(file, 'utf-8');
|
||||
const styleMatches = src.matchAll(/<style([^>]*)>([\s\S]*?)<\/style>/g);
|
||||
for (const m of styleMatches) {
|
||||
const attrs = m[1] || '';
|
||||
if (/lang\s*=\s*["']scss["']/.test(attrs)) continue;
|
||||
const body = m[2];
|
||||
const lines = body.split('\n');
|
||||
let depth = 0;
|
||||
let inAtRule = false;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i].trim();
|
||||
if (line.startsWith('@keyframes') || line.startsWith('@media')) {
|
||||
inAtRule = true;
|
||||
}
|
||||
for (const ch of line) {
|
||||
if (ch === '{') {
|
||||
depth++;
|
||||
if (depth > 1 && !inAtRule) {
|
||||
problems.push(`${path.relative(root, file)}: line ${i + 1}`);
|
||||
break;
|
||||
}
|
||||
} else if (ch === '}') {
|
||||
depth = Math.max(0, depth - 1);
|
||||
if (depth === 0) inAtRule = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户