Skip to content

Let style sheet rules override presentation attributes - #148

Open
Niksac wants to merge 1 commit into
dompdf:masterfrom
Niksac:fix-presentation-attribute-precedence
Open

Niksac wants to merge 1 commit into
dompdf:masterfrom
Niksac:fix-presentation-attribute-precedence

Conversation

@Niksac

@Niksac Niksac commented Nov 15, 2026

Copy link
Copy Markdown

A presentation attribute such as fill="blue" currently wins over a style sheet rule, because makeStyle() applies the style sheets first. In SVG the order is: presentation attributes < style sheet rules < style attribute.

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
  <style>.x { fill: red }</style>
  <rect class="x" width="100" height="100" fill="blue"/>
</svg>

Expected (browsers): red. Before: blue.

Documents that relied on the previous order render differently after this change.

Disclaimer:
Most of the code was written by AI (Claude) and reviewed / tested by me.

@bsweeney bsweeney added this to the 1.0.3 milestone Nov 16, 2026
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.

2 participants