Skip to content

Conversation

@cossssmin
Copy link
Collaborator

@cossssmin cossssmin commented Nov 2, 2025

This PR introduces a new option, preservedSelectors, which is an array of strings representing CSS selectors that should be preserved in the <style> tag when either removeStyleTags or removeinlinedSelectors come into effect.

For example, this:

juice(`
  <style>
    div { color: red; } 
    .preserve-me { background: blue; }
  </style>
  <div class="preserve-me">Test</div>
  `, 
  { 
    removeStyleTags: true, 
    preservedSelectors: ['.preserve-me'] 
  }
)

... would return this HTML:

<style>
  .preserve-me { background: blue; }
</style>

<div class="preserve-me" style="color: red; background: blue">Test</div>

@cossssmin cossssmin merged commit 7d379fd into master Nov 2, 2025
3 checks passed
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