Order of applying styles
Los mantenedores suelen responder en 5 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Reproduce with the two testcases in the issue body: div elements with classes text-b text-a and text-b text-c, then compare the computed styles. The payload does not name the source files, so search the codebase for where class selectors are matched and applied in order. Done means both class orderings produce the same declarations, with the later class in the attribute winning for conflicting properties.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Guidelines
- I understand that if I fail to adhere to contribution guidelines and/or fail to provide all required details, this issue may be closed without review.
Description of the bug
The order in which styles are applied is affected by the class name:
I've provided 2 examples that demonstrate this
Example 1:
<div class="text-b text-a">Foo</div>
Expected output:
- color: red;
- background-color: blue;
- text-transform: uppercase;
- text-decoration: line-through;
Actual output:
- color: green;
- background-color: black;
- text-transform: uppercase;
- text-decoration: line-through;
Since text-decoration: line-through was applied, this means that text-a was applied first and then text-b
But if we rename the text-a class to text-c, we will get the expected result
Example 2:
<div class="text-b text-c">Foo</div>
Actual output:
- color: red;
- background-color: blue;
- text-transform: uppercase;
- text-decoration: line-through;
It seems that the order in which classes are applied is affected by alphabetical order.
Note: If you render html in a browser, this problem does not occur.
mPDF version
v8.2.4
PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)
PHP 7.4.33 (cli) (built: Sep 27 2024 12:56:02) ( NTS ) and PHP 8.3.12 (cli) (built: Sep 24 2024 18:08:04) (NTS)
Reproducible PHP+CSS+HTML snippet suffering by the error
First testcase:
<?php
require __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8',
'format' => 'A4',
]);
$html = <<<HTML
<html lang="en">
<head>
<title>Testcase</title>
</head>
<style>
div {font-size: 108px;}
.text-b {
background-color: black;
text-transform: uppercase;
color: green;
}
.text-a {
background-color: blue;
color: red;
text-decoration: line-through;
}
</style>
<body>
<div id="root">
<div class="text-b text-a">Foo</div>
<hr>
<div class="text-a text-b">Bar</div>
</div>
</body>
</html>
HTML;
$mpdf->WriteHTML($html);
$mpdf->Output('test_b_a.pdf', 'F');
Second testcase:
<?php
require __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8',
'format' => 'A4',
]);
$html = <<<HTML
<html lang="en">
<head>
<title>Testcase</title>
</head>
<style>
div {font-size: 108px;}
.text-b {
background-color: black;
text-transform: uppercase;
color: green;
}
.text-c {
background-color: blue;
color: red;
text-decoration: line-through;
}
</style>
<body>
<div id="root">
<div class="text-b text-c">Foo</div>
<hr>
<div class="text-c text-b">Bar</div>
</div>
</body>
</html>
HTML;
$mpdf->WriteHTML($html);
$mpdf->Output('test_b_c.pdf', 'F');
- Lenguaje dominante
- PHP
- Estrellas
- 4.7k
- Forks
- 1.1k
- Merge medio
- 6 d 11 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de mpdf/mpdf
-
SVG path arcs with an explicit zero radius throw DivisionByZeroErrorPosiblemente ocupada @Syed-Shehroz-Sohail la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 5 días
-
Closing a column set with an image in it leaves the cursor below the page, wasting the rest of itAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 5 días
-
8.3: Local fallback for external stylesheets is inverted in CssLoader (basepathIsLocal check negated) — CSS silently dropped when remote fetch failsPosiblemente ocupada @hemreduru la tomó hace 12 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 5 días
-
Tag/Td.php silently clears cell top/bottom borders when a row has a partial border (plus two warnings and a deprecation)Posiblemente ocupada @alizamani1616 la tomó hace 61 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 5 días
-
AdjustHTML() collapses multiple spaces inside quoted attribute values (src, href)Posiblemente ocupada @sornapudisuresh la tomó hace 130 días. Abiertobug/fix help wanted HTML/CSS support
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
mpdf/mpdf#2208 · 1 comentario ·
Los mantenedores suelen responder en 5 días
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
sync-en
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
Перевод устарел
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
follow-up
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día