Skip to content
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

[LiveComponent] Tokenize classes on all allowed whitespaces #1828

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from

Conversation

aleho
Copy link

@aleho aleho commented May 6, 2024

Q A
Bug fix? yes
New feature? no
Issues Fix #1819
License MIT

The class attribute can be tokenized by any white space as defined by the HTML spec.

When a class attribute contains whitespaces other than a space change tracking fails and invalid classes are applied resulting in Uncaught (in promise) DOMException: DOMTokenList.remove: The empty string is not a valid token..

@carsonbot carsonbot added Bug Bug Fix LiveComponent Status: Needs Review Needs to be reviewed labels May 6, 2024
@aleho
Copy link
Author

aleho commented May 6, 2024

I don't understand why .splice() was used instead of a new array. Can't be for performance reasons, or can it?

@aleho
Copy link
Author

aleho commented May 6, 2024

Also, forgot to mention: I'd consider a regex to tokenize the string a more elegant solution.

Any objections against that?

@smnandre
Copy link
Collaborator

smnandre commented May 8, 2024

Could you rebuild the packages ? (that's the origin of the CI failures)

(yarn run build from the repository root i think)

@aleho
Copy link
Author

aleho commented May 8, 2024

Of course! Didn't find anything in the docs and wasn't sure whether that's something that actually has to be done in the PR or will be done on release.

@smnandre
Copy link
Collaborator

smnandre commented May 8, 2024

Yep this would need some CONTRIB file.. i'll open an issue :)

@smnandre
Copy link
Collaborator

smnandre commented May 8, 2024

#1836 :)

@smnandre
Copy link
Collaborator

smnandre commented May 8, 2024

Do you think you could add a quick test, to prevent any future regression ? 😊

@aleho
Copy link
Author

aleho commented May 13, 2024

I would like to but I didn't see any browser tests in LiveComponents.

Could you point me in the right direction where actual browser integration is tested for live_controller.js?

aleho added 2 commits May 13, 2024 14:51
The class attribute can be tokenized by any white space as defined by
the HTML spec. A class string containing new lines was not correctly
cleaned / trimmed, resulting in incorrectly detected class changes and a
browser error if empty classes or classes with newlines were applied.

Fixes symfony#1819
@aleho aleho force-pushed the 2.x branch 3 times, most recently from 292f19d to 268b2df Compare May 13, 2024 13:04
@aleho
Copy link
Author

aleho commented May 13, 2024

Never mind. I figured LiveComponent doesn't have any browser tests yet and tried to add them.

This PR got bigger than expected, please let me know if anything's missing.

@smnandre
Copy link
Collaborator

wow indeed :) I'll look in the week as soon as i can ! Thank you for the efforts :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[LiveComponent] Morph error trying to apply invalid classes
3 participants