test: mobileBlockContaining ignore les commentaires CSS (CI #842)
CI / lint (push) Successful in 2m45s
CI / security (push) Successful in 1m58s
CI / test (push) Successful in 4m41s
CI / build (push) Successful in 1m52s
CI / e2e (push) Successful in 16m32s

- le helper choisissait le premier bloc media contenant la chaine 'mobile-toolbar' ; un commentaire citant ce selecteur (correctif BUG-103) le faisait retomber sur le mauvais bloc, sans la clearance .main-body (BUG-073)
- les commentaires sont maintenant retires avant la recherche de bloc
This commit is contained in:
2026-10-02 15:46:05 -04:00
parent 83e6a951dd
commit 34428ea7b3
10 changed files with 32 additions and 19 deletions
+10 -6
View File
@@ -42,19 +42,23 @@ function test(label, fn) {
/** Body of the first @media (max-width: 768px) block whose body contains `needle`. */
function mobileBlockContaining(needle) {
const marker = "@media (max-width: 768px)";
// Les commentaires sont ignorés : un sélecteur cité dans une annotation
// (ex. « .mobile-toolbar » dans un commentaire de style.css) ne doit pas
// faire rétrograder ce helper sur le mauvais bloc mobile (BUG-103/CI #842).
const source = css.replace(/\/\*[\s\S]*?\*\//g, "");
let idx = 0;
while ((idx = css.indexOf(marker, idx)) !== -1) {
const open = css.indexOf("{", idx);
while ((idx = source.indexOf(marker, idx)) !== -1) {
const open = source.indexOf("{", idx);
let depth = 0;
let end = open;
for (; end < css.length; end++) {
if (css[end] === "{") depth++;
else if (css[end] === "}") {
for (; end < source.length; end++) {
if (source[end] === "{") depth++;
else if (source[end] === "}") {
depth--;
if (depth === 0) break;
}
}
const body = css.slice(open + 1, end);
const body = source.slice(open + 1, end);
if (body.includes(needle)) return body;
idx = end + 1;
}