-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
refactor: do not add data attribute when it's value is empty #2543
refactor: do not add data attribute when it's value is empty #2543
Conversation
What are the steps to reproduce the bug(s) please? How is it visible to users? |
Asking because:
|
Well, I'm in doubt here. I'm not sure how/whether the user can see this. Let me provide you a bit more context. Previously the test for test attributes were written like: const testComponentClasses = async (
taskLine: string,
layoutOptions: Partial<LayoutOptions>,
mainClass: string,
attributes: AttributesDictionary,
) => {
// skipping unrelated code
// Now verify the attributes
for (const key in attributes) {
expect(listItem.dataset[key]).toEqual(attributes[key]);
} and now take a look at the call: await testComponentClasses(
'- [ ] Full task ⏫ 📅 2022-07-02 ⏳ 2022-07-03 🛫 2022-07-04 🔁 every day',
{},
fieldRenderer.className('recurrenceRule'),
{},
); The |
Perfectly valid questions. I would say it is more of a theoretical internal bug |
Thanks for the replies.
|
Ah ok, I will take note for that =) I had a thought like I see you closed the PR, would you like me to submit with a different branch starting with |
Thanks for pointing that out. It was certainly not my intention... 😢 |
There's basically a dividing line in the release notes in to two halves... Almost aways, all the This is done by me manually editing the PR text to group related items together... The 5.3.0 release was trickier as a bunch of fixes and features were made, on a feature not yet released - and so those were not relevant to users... This is what I ended up doing: |
Ok, clear, thanks =) |
I'm trying to find a reference to why it is wrong for a data attribute to not have a value. And not succeeding. https://stackoverflow.com/questions/56957757/are-empty-boolean-html-attributes-the-same-as-no-value-attributes |
Asking as, if it's not a user-visible issue right now, as there is no current scenario where users can create empty data attribute values - and there is no technical reason to prevent them - might this actually create a pitfall for our future selves, if a future styling development might actually want to allow empty data attributes in future? |
Please note that in the examples above, the questions were asked for data attributes with boolean types, where an attribute’s presence equals attribute presence with empty value, equals attribute presence with “true” value. Here we are talking about data attributes with actual values, they don’t have a sense at all without a value. My feeling is that the tests were written with total absence of attributes in the HTMLElements.
Good question. I would say that 1) YAGNI ;) 2) it will be quick to change in this case. One more thing, my objective is to remove the ‘it.failing()’ tests. The other way could be to change the expected value in the tests. Pls lmk if you would prefer this solution. |
Indeed. My concern is exactly that I do not understand the intention of the code, so am unable to say whether the correct answer is to change the tests or to change the code. I will go ahead and merge the PR, as you clearly know more about how this code works than I do. |
That's helpful. Thanks. |
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.
I ran the styling smoke test, as the PR changed production code...
It of course passed.
Thanks~~ |
Description
After refactoring tests, a bug has been revealed (it was present before, but unseen due to the way the tests were done).
Current behaviour: data attributes with empty values are added.
Fixed behaviour: data attributes with empty values are not added.
Motivation and Context
Fix bugs =)
How has this been tested?
Unit tests.
Types of changes
Changes visible to users:
fix
- non-breaking change which fixes an issue)Checklist
yarn run lint
.Terms