phoenix_live_view changelog


Hey there, code wizards! 🌟 We've got some exciting updates for you in the world of Phoenix LiveView. Let's dive into the magical improvements that are sure to make your development experience smoother and more enchanting!

New feature: Evaluate JS Commands During Form Recovery
We've sprinkled some JavaScript pixie dust on the form recovery process! Now, when you're working with forms in LiveView, JS commands will be evaluated, ensuring a seamless experience even if you're dealing with those pesky disconnections and reconnections. This update makes sure your input values stay put and behave like the good little elements they are, even in the face of adversity! 🧙‍♂️✨

Improvement: Update Assets
Our event handling just got a major glow-up! We've revamped the way event handlers are defined and executed, making sure everything runs as smooth as butter. By introducing a new handler function, we've ensured that events are only pushed if the target view is connected, making event processing more efficient and user-friendly. Your LiveView experience just got a whole lot more magical! 🪄

Improvement: Track Braces State in Tokenizer
Brace yourselves—literally! We've enhanced our tokenizer to keep track of brace states during tokenization. This means your HTML templates will handle expressions like a pro, especially when using the phx-no-curly-interpolation attribute. Our tests confirm that everything's working as intended, preserving your literal braces in the rendered HTML. So, go ahead and unleash your creativity with dynamic content, because we've got your back! 🛡️

That's all for now, folks! Keep coding and may your bugs be few and your features be plentiful! 🚀

Included Commits

2025-01-02T07:56:59 See commit

The recent commit enhances the tokenizer functionality in the Phoenix LiveView framework by introducing a mechanism to track the state of braces during tokenization. This change addresses issue #3613 and modifies several files within the library, specifically html_formatter.ex, tag_engine.ex, and tokenizer.ex. The primary adjustment involves updating the continuation state from a simple :text to a more complex {:text, :enabled}, allowing the tokenizer to better manage brace states, which is crucial for handling expressions within HTML templates.

Additionally, the commit includes updates to the test files, adding new tests to ensure that the tokenizer correctly processes HTML with the phx-no-curly-interpolation attribute. This attribute is designed to prevent curly braces from being evaluated, and the tests confirm that the output remains as intended, preserving the literal braces in the rendered HTML. Overall, these changes improve the robustness of the HTML rendering process in Phoenix LiveView, particularly in scenarios involving dynamic content.

Files changed

  • lib/phoenix_live_view/html_formatter.ex
  • lib/phoenix_live_view/tag_engine.ex
  • lib/phoenix_live_view/tokenizer.ex
  • test/phoenix_live_view/html_engine_test.exs
  • test/phoenix_live_view/tokenizer_test.exs
2024-12-29T10:44:38 See commit

This commit addresses issue #3607 by enhancing the JavaScript functionality during form recovery in the Phoenix LiveView framework. It modifies the existing JavaScript code to evaluate JS commands when a form is being recovered, allowing for a more seamless user experience. Specifically, it introduces a new handler that processes events for the target view and context, ensuring that if the form recovery process is initiated, the appropriate target view and context are utilized instead of relying solely on the real DOM.

Additionally, the commit includes changes to the form handling logic, ensuring that JS commands can be executed during the recovery phase. It updates the test suite to verify that JS commands in the phx-change event are functional during this recovery process, confirming that the input retains its value and behaves as expected even after a disconnection and reconnection of the LiveView socket. Overall, these changes improve the robustness of form interactions within the LiveView environment.

Files changed

  • assets/js/phoenix_live_view/js.js
  • assets/js/phoenix_live_view/view.js
  • test/e2e/support/form_live.ex
  • test/e2e/tests/forms.spec.js
2024-12-29T10:45:05 See commit

This commit updates several files related to the Phoenix LiveView JavaScript assets, specifically enhancing the event handling functionality within the framework. The primary changes involve modifying the way event handlers are defined and executed, particularly in the context of managing target views and contexts. The code refactoring introduces a new handler function that checks if the target view is connected before pushing events, improving the robustness of event handling. Additionally, it streamlines the logic for handling target views and contexts by allowing for direct invocation of the handler when specific arguments are provided.

In total, the commit includes modifications to the phoenix_live_view.cjs.js, phoenix_live_view.esm.js, phoenix_live_view.js, and their respective source map files. The changes consist of 19 additions and 7 deletions in each of the main JavaScript files, reflecting a total of 26 changes per file. These updates aim to enhance the overall functionality and maintainability of the LiveView framework, ensuring a smoother user experience and more efficient event processing.

Files changed

  • priv/static/phoenix_live_view.cjs.js
  • priv/static/phoenix_live_view.cjs.js.map
  • priv/static/phoenix_live_view.esm.js
  • priv/static/phoenix_live_view.esm.js.map
  • priv/static/phoenix_live_view.js
  • priv/static/phoenix_live_view.min.js