-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add ignore-nullish
modifier to x-html
and x-text
#4579
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
base: main
Are you sure you want to change the base?
Conversation
I like the modifier approach. I think I'd be more partial to |
initTree(el) | ||
delete el._x_ignoreSelf | ||
}) | ||
if (!modifiers.includes('ignore-nullish') || value !== null) { |
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.
if (!modifiers.includes('ignore-nullish') || value !== null) { | |
if (!modifiers.includes('ignore-nullish') || value == null) { |
Then you can remove the above value = value ?? null
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 would rather explicitly coerce to null
and be able to do a strict check. It makes it more clear what the intent is here.
initTree(el) | ||
delete el._x_ignoreSelf | ||
}) | ||
if (!modifiers.includes('ignore-nullish') || value !== null) { |
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.
if (!modifiers.includes('ignore-nullish') || value !== null) { | |
if (!modifiers.includes('ignore-nullish') || value != null) { |
NIT: Then you can remove the above value = value ?? null
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 would rather explicitly coerce to null
and be able to do a strict check. It makes it more clear what the intent is here.
value = value ?? null; | ||
|
||
if (!modifiers.includes('ignore-nullish') || value !== null) { |
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.
value = value ?? null; | |
if (!modifiers.includes('ignore-nullish') || value !== null) { | |
if (!modifiers.includes('ignore-nullish') || value != null) { |
NIT
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 would rather explicitly coerce to null
and be able to do a strict check. It makes it more clear what the intent is here.
|
Yeah....but |
What is the value becomes |
@Tim-Wils no, as the name infers, it ignores any nullish values and does not change the HTML/text. It will be most useful on initial state. |
This adds an
ignore-nullish
modifier tox-html
andx-text
. If the value is set tonull
orundefined
, the currently set HTML/text will remain unchanged.The main use case for this is to have the initial HTML/text set in the markup on page load. See the updates to the documentation for examples.