Skip to content

Prevent InvalidCharacterError by correctly rendering x-cloak attribute #2266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025

Conversation

pascalberski
Copy link

@pascalberski pascalberski commented May 13, 2025

Description

This PR addresses a bug that caused an InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': '0' is not a valid attribute name.

The root cause was that 'x-cloak' was added as a value without an explicit key in PHP arrays responsible for generating HTML attributes (e.g., in getTopLevelAttributesArray()). This led to PHP assigning a numeric index, which was then incorrectly used as the attribute name.

The fix changes the array definition from ..., 'x-cloak', ... to ..., 'x-cloak' => '', .... This ensures x-cloak is rendered as a proper attribute (x-cloak=""), resolving the JavaScript error and allowing Alpine.js to function as expected.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests and did you add any new tests needed for your feature?
  1. Did you test locally to make sure your feature works as intended?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@pascalberski pascalberski changed the title Development Fix Error with 0="x-cloak" May 13, 2025
@pascalberski pascalberski changed the title Fix Error with 0="x-cloak" Prevent InvalidCharacterError by correctly rendering x-cloak attribute May 14, 2025
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.23%. Comparing base (b34c385) to head (98f5f24).
Report is 8 commits behind head on development.

Additional details and impacted files
@@              Coverage Diff               @@
##             development    #2266   +/-   ##
==============================================
  Coverage          90.23%   90.23%           
  Complexity          2176     2176           
==============================================
  Files                242      242           
  Lines               4896     4896           
==============================================
  Hits                4418     4418           
  Misses               478      478           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lrljoe
Copy link
Collaborator

lrljoe commented May 25, 2025

Will look to merge this in this weekend, appreciated!

@lrljoe lrljoe merged commit 0201904 into rappasoft:development Jun 4, 2025
12 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