pierrejeambrun commented on PR #42063:
URL: https://github.com/apache/airflow/pull/42063#issuecomment-2343175943
Ok, as I recall html attribute values are string, therefore, we end up with
`attribute='True'` or `attribute='False'`.
Which does not work indeed, both are truthy.
Jquery `has` method is smart enought to convert a js string bool into an
actual bool ('true', 'false'), but he does not recognize python bool of course
i.e 'True' 'False' which remain strings. This is why casting to lower solves
the issue.
The problem is that this is too implicit. People reading that code will not
understand why it's here in a couple of weeks and will have to get back here. I
would prefer something more explicit like we do with `checked` attribute. Also
usually the convention is `if a boolean attribute is present then it's true,
otherwise it's false, independently of its value`. For instance just `checked`
is enough, no need to `checked='true'`.
I would only set the attribute if True like this:
```
{{ "data-require-confirmation" if
appbuilder.require_confirmation_dag_change else "" }}
```
Then adapt the jquery query to check if the attribute is set or not,
something like:
```
const requireConfirmation = $input.is("[data-require-confirmation]");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]