-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix whitespace bug in x-bind:class class list #437
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, is there a reason the bundle changed so much? Looks to me like the output should only change as much as your code changes
} else { | ||
classNames.split(' ').forEach(className => el.classList.remove(className)) | ||
classNames.split(' ').filter(Boolean).forEach(className => el.classList.remove(className)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have a getClassNames
util/helper that does the split + filter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, makes sense. It's repeated three times in this PR
@HugoDF Yeah, There are some changes mixed up with the PR. Build files has some ghost changes. |
Yeah, it felt a bit odd to me as well. I didn't do anything besides installing the dependencies with |
Weirdly, it seems like Would you mind deleting the node_modules folder, using The dependency should probably be updated but not in the scope of this PR. Thanks for your fix, it looks good. |
Right, Yarn doesn't use package-lock unless you run
Mistery solved. |
Aha, didn't know that. TIL |
@@ -420,3 +420,14 @@ test('setSelectionRange is not called for inapplicable input types', async () => | |||
expect(document.querySelector('input').value).toEqual('baz') | |||
}) | |||
}) | |||
|
|||
test('unnecessary whitespaces in class list are ignored', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to have tests for when it's using array syntax or string syntax?
Good fix! Thanks @felixsc! |
Fixes #436
When the class list declaration in a x-bind:class is ended with a whitespace or contains multiple consecutive whitespaces an error is thrown.
This PR filters the class list after it is split and removes the empty classes.