Skip to content

feat: migrate comments.js from jquery to vanilla js#3

Merged
bmp-mmiekus merged 1 commit into
6.xfrom
feature/BM-164_migrate-from-jquery-to-vanilljs
Jan 28, 2026
Merged

feat: migrate comments.js from jquery to vanilla js#3
bmp-mmiekus merged 1 commit into
6.xfrom
feature/BM-164_migrate-from-jquery-to-vanilljs

Conversation

@bmp-mmiekus

Copy link
Copy Markdown
Collaborator

Migrate from jQuery to Vanilla JavaScript and update configuration API

Description

Complete migration of FOSCommentBundle JavaScript code from jQuery to vanilla JavaScript (ES6+). This includes removing jQuery and easyXDM dependencies, implementing modern JavaScript features (Fetch API, const/let, arrow functions, CustomEvents), and introducing a new object-based configuration format for better API design.

Breaking Changes

Configuration API:

  • Old global variables (fos_comment_thread_id, fos_comment_thread_api_base_url, fos_comment_thread_view) replaced with window.FosComment.config object
  • easyXDM cross-domain support removed
  • jQuery dependency removed

Scope

  • Update async.html.twig template to use new configuration syntax (window.FosComment.config)
  • Replace var with const in JavaScript code for modern practices
  • Update documentation comments in comments.js with new configuration examples and modern JavaScript syntax
  • Update all documentation files to reflect new API usage
  • Remove jQuery dependency from test templates

Files Changed

Template files:

  • src/Resources/views/Thread/async.html.twig - Updated to use new configuration object

JavaScript:

  • src/Resources/public/js/comments.js - Updated JSDoc comments, replaced var with const/let, modernized code

Documentation:

  • docs/4-enable_comments_on_a_page.md - Updated basic usage examples
  • docs/10-other_ways_of_adding_comments_to_a_page.md - Added configuration example for manual loading
  • docs/13-hooking_into_the_js_code.md - Updated event listener examples
  • docs/99-faq.md - Minor documentation update

Test files:

  • tests/Functional/Bundle/CommentBundle/Resources/views/Comment/async.html.twig - Removed jQuery dependency
  • tests/Functional/Bundle/CommentBundle/Resources/views/Comment/inline.html.twig - Removed jQuery script tag

Technical Changes

Old syntax (removed):

var fos_comment_thread_id = '{{ id }}';
var fos_comment_thread_view = '{{ view|default('tree') }}';
var fos_comment_thread_api_base_url = '{{ path('fos_comment_get_threads') }}';

New syntax:

window.FosComment = window.FosComment || {};
window.FosComment.config = {
    threadId: '{{ id }}',
    view: '{{ view|default('tree') }}',
    apiBaseUrl: '{{ path('fos_comment_get_threads') }}'
};

@bmp-mmiekus bmp-mmiekus force-pushed the feature/BM-164_migrate-from-jquery-to-vanilljs branch from 009d0dd to 624e0c2 Compare January 27, 2026 14:35
@bmp-mmiekus bmp-mmiekus merged commit d9f8710 into 6.x Jan 28, 2026
0 of 4 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