8000 Several selector fixes by Mellthas · Pull Request #3059 · dompdf/dompdf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Several selector fixes #3059

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

Merged
merged 5 commits into from
Nov 14, 2022
Merged

Several selector fixes #3059

merged 5 commits into from
Nov 14, 2022

Conversation

Mellthas
Copy link
Member
@Mellthas Mellthas commented Nov 7, 2022
  • Fix nth-child when combined with other conditions
  • Fix handling of empty string in attribute selectors
  • Fix overzealous ID selector matching

Applies on top of #3057

Fixes #2222
Partially addresses #3056

8000
@Mellthas
Copy link
Member Author
Mellthas commented Nov 7, 2022

Test case for the ID-selector fix

HTML
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<style>
@page {
    size: 400pt 300pt;
    margin: 50pt;
}

h1 {
    margin: 0 0 10pt 0;
    font-size: 1.5rem;
}

div + h1 {
    margin-top: 10pt;
}

#test {
    outline: medium solid red;
}

.test {
    outline: medium solid red;
}
</style>
</head>

<body>
    <h1>ID</h1>
    <div id="test">test</div>
    <div id="test with space">test with space</div>

    <h1>Class</h1>
    <div class="test">test</div>
    <div class="test with space">test with space</div>
</body>

</html>

id-before.pdf
id-after.pdf

@Mellthas
Copy link
Member Author
Mellthas commented Nov 7, 2022

Test case for the attribute-selector fixes

Red background and yellow font should not be applied.

HTML
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<style>
@page {
    size: 400pt 300pt;
    margin: 50pt;
}

html {
    font-size: 2em;
}

[title~=test] {
    text-decoration: underline;
}

[title~="I'm"] {
    font-weight: bold;
}

[title~="a test"] {
    background-color: red;
}

[title~=""] {
    color: yellow;
}

[title^="Ano"] {
    text-decoration: underline;
}

[title$="ther"] {
    font-weight: bold;
}

[title^=""] {
    color: yellow;
}

[title$=""] {
    background-color: red;
}

[title*="tain"] {
    font-weight: bold;
    text-decoration: underline;
}

[title*=""] {
    color: yellow;
    background-color: red;
}
</style>
</head>

<body style="background-color: transparent;">
    <div title="I'm a test">Space-separated</div>
    <div title="Another">Starts-with, ends-with</div>
    <div title="contains">Contains</div>
</body>

</html>

attribute-substring-before.pdf
attribute-substring-after.pdf

@bsweeney bsweeney added this to the 2.0.2 milestone Nov 8, 2022
Counting siblings obviates the need to apply the condition before
restricting to element type. The `position()` function depends on the
current node set, but the sibling queries do not.

Fixes #2222
Partially addresses #3056
The match must be exact, the ID attribute is not a space-separated
list of tokens like the class attribute.
@Mellthas Mellthas merged commit 450d00a into master Nov 14, 2022
@Mellthas Mellthas deleted the selector-fixes branch November 14, 2022 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The :nth-last-child(N) selector not working
2 participants
0