kosiew opened a new pull request, #1177:
URL: https://github.com/apache/datafusion-python/pull/1177

   ## Which issue does this PR close?
   
   - Closes #1171.
   
   ## Rationale for this change
   
   This change simplifies the logic for injecting HTML styles in the 
`DataFrameHtmlFormatter` class. The previous implementation relied on a 
class-level `_styles_loaded` flag to prevent redundant style injection, which 
introduced state management complexity and testing challenges. By using a 
`<script>` block that conditionally appends styles based on DOM inspection, 
this new approach avoids side effects and supports better isolation across 
render calls and notebook sessions.
   
   ## What changes are included in this PR?
   
   - Removed `_styles_loaded` flag and associated logic.
   - Replaced conditional style injection with DOM-based script that ensures 
styles are added once.
   - Removed the `reset_styles_loaded_state` function and its test usages.
   - Updated tests to validate the presence of injected script and consistent 
behavior across renders.
   - Ensured fallback CSS inclusion and custom styles are still respected.
   
   ## Are these changes tested?
   
   Yes, all existing relevant tests have been updated to reflect the new 
behavior. Assertions now check for presence of the injected script rather than 
`<style>` tags. This ensures that styles are being correctly applied through 
the new mechanism.
   
   ## Are there any user-facing changes?
   
   Yes, but minimal:
   - Users no longer need to manually reset styles between sessions using 
`reset_styles_loaded_state`.
   - HTML output now uses `<script>`-based style injection, which improves 
compatibility and reduces potential styling issues across multiple renderings.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to