Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bindings/php/stubs/css_inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class CssInliner
* @param int $preallocateNodeCapacity Pre-allocate capacity for HTML nodes
* @param StylesheetCache|null $cache Cache for external stylesheets
* @param bool $removeInlinedSelectors Remove selectors that were successfully inlined from style blocks
* @param bool $applyWidthAttributes Add width HTML attributes from CSS width properties on supported elements
* @param bool $applyHeightAttributes Add height HTML attributes from CSS height properties on supported elements
*/
public function __construct(
bool $inlineStyleTags = true,
Expand All @@ -81,6 +83,8 @@ public function __construct(
int $preallocateNodeCapacity = 32,
?StylesheetCache $cache = null,
bool $removeInlinedSelectors = false,
bool $applyWidthAttributes = false,
bool $applyHeightAttributes = false,
) {}

/**
Expand Down
24 changes: 24 additions & 0 deletions bindings/php/tests/CssInlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,30 @@ public function testLoadRemoteStylesheetsDisabled(): void
$this->assertIsString($result);
}

public function testApplyWidthAttributes(): void
{
$inliner = new CssInliner(
applyWidthAttributes: true,
);

$html = '<html><head><style>td { width: 100px; }</style></head><body><table><tr><td>Test</td></tr></table></body></html>';
$result = $inliner->inline($html);

$this->assertStringContainsString('width="100"', $result);
}

public function testApplyHeightAttributes(): void
{
$inliner = new CssInliner(
applyHeightAttributes: true,
);

$html = '<html><head><style>td { height: 50px; }</style></head><body><table><tr><td>Test</td></tr></table></body></html>';
$result = $inliner->inline($html);

$this->assertStringContainsString('height="50"', $result);
}

public function testRemoveInlinedSelectors(): void
{
$inliner = new CssInliner(
Expand Down
Loading