Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This introduces a
has-network
attribute which allows us to show or hide things based on network status ("online" or "offline")One thing that might be worth noting: when
has-network
is present but set to an invalid value (ie. something other thanonline
oroffline
) the matcher will always returnfalse
. I wasn't totally sure what the best approach here was: another option would be to returnundefined
and effectively ignore the matcher, but treating other values as false seemed more consistent with how the other conditional attributes behave in cases where a value is invalid, and maybe less likely to lead to confusion where someone, eg. makes a typo.Related Issue(s)
An earlier attempt at this used an
is-offline
attribute. However, on that PR, @mirisuzanne suggested thathas-network="offline | online"
might be a better syntax. I agree, because this has the advantage of putting "online" and "offline" on the same logical footing, making "online" equally targetable for showing / hiding purposes, rather than treating it as a default state.Steps to test/reproduce
Use the
has-network
attribute to show/hide based on network status: