Skip to content

Commit

Permalink
Rename value-non-empty to non-empty-value
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekxix committed Oct 11, 2024
1 parent d052bb8 commit e5827f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/toggle-attribute/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ import '@travelopia/web-components/dist/toggle-attribute/style.css';
<div class="toggle-target-variable" data-toggle-value="First,All">
Toggled First
</div>
<div class="toggle-target-variable" data-toggle-value-non-empty="yes">
<!-- add the data-toggle-value-non-empty="yes" attribute to toggle on with all non empty values. -->
<div class="toggle-target-variable" data-toggle-non-empty-value="yes">
<!-- add the data-toggle-non-empty-value="yes" attribute to toggle on with all non empty values. -->
This will be toggled for all non empty values.
</div>
<div class="toggle-target-variable" data-toggle-value="Second,All">
Expand All @@ -86,7 +86,7 @@ import '@travelopia/web-components/dist/toggle-attribute/style.css';
<p>Toggle with non empty values</p>

<!-- Select value -->
<tp-toggle-attribute target=".toggle-target-non-empty" value-non-empty="yes">
<tp-toggle-attribute target=".toggle-target-non-empty" non-empty-value="yes">
<select>
<option value="">Select</option>
<option value="First">First</option>
Expand Down Expand Up @@ -134,7 +134,7 @@ import '@travelopia/web-components/dist/toggle-attribute/style.css';
| value | No | <comma separated values to match> | If this is specified, these comma separated values are matched with the value of the trigger. If they match, the target(s) is/are toggled. Same goes for having a `data-toggle-value` attribute on a target. |
| trigger | No | <selector of the trigger> | If this is not specified, the direct child is treated as the trigger. If it is mentioned, it looks for this selector within the context |
| closest-ancestor | No | <selector of the closest ancestor> | Default: `body`. If this is specified, the target is searched for within this selector, not on `body`. |
| value-non-empty | No | yes | A boolean attribute that signifies whether or not the targets should be toggled for all non empty values on the trigger.
| non-empty-value | No | yes | A boolean attribute that signifies whether or not the targets should be toggled for all non empty values on the trigger.

## Events

Expand Down
6 changes: 3 additions & 3 deletions src/toggle-attribute/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
<div class="toggle-target-variable" data-toggle-value="First,All">
Toggled First
</div>
<div class="toggle-target-variable" data-toggle-value-non-empty="yes">
<!-- add the data-toggle-value-non-empty="yes" attribute to toggle on with all non empty values. -->
<div class="toggle-target-variable" data-toggle-non-empty-value="yes">
<!-- add the data-toggle-non-empty-value="yes" attribute to toggle on with all non empty values. -->
This will be toggled for all non empty values.
</div>
<div class="toggle-target-variable" data-toggle-value="Second,All">
Expand All @@ -88,7 +88,7 @@
<p>Toggle with non empty values</p>

<!-- Select value -->
<tp-toggle-attribute target=".toggle-target-non-empty" value-non-empty="yes">
<tp-toggle-attribute target=".toggle-target-non-empty" non-empty-value="yes">
<select>
<option value="">Select</option>
<option value="First">First</option>
Expand Down
6 changes: 3 additions & 3 deletions src/toggle-attribute/tp-toggle-attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class TPToggleAttributeElement extends HTMLElement {
// Check if trigger has a value, example: form inputs.
if ( value || '' === value ) {
// Check if we have a value.
if ( this.hasAttribute( 'value' ) || this.hasAttribute( 'value-non-empty' ) ) {
if ( this.hasAttribute( 'value' ) || this.hasAttribute( 'non-empty-value' ) ) {
this.toggleByValueAttribute( value );
} else {
this.toggleByTargetDataValue( value );
Expand Down Expand Up @@ -92,7 +92,7 @@ export class TPToggleAttributeElement extends HTMLElement {

// Get value to listen for.
const valuesAttribute = this.getAttribute( 'value' );
const nonEmptyValuesAttribute = this.hasAttribute( 'value-non-empty' );
const nonEmptyValuesAttribute = this.hasAttribute( 'non-empty-value' );

// Can we proceed?
if ( ! valuesAttribute && ! nonEmptyValuesAttribute ) {
Expand Down Expand Up @@ -136,7 +136,7 @@ export class TPToggleAttributeElement extends HTMLElement {
targetElements.forEach( ( target: HTMLElement ): void => {
// Get values and split them. Set an empty array otherwise.
const valuesAttribute = target.getAttribute( 'data-toggle-value' );
const nonEmptyValuesAttribute = target.hasAttribute( 'data-toggle-value-non-empty' );
const nonEmptyValuesAttribute = target.hasAttribute( 'data-toggle-non-empty-value' );

// Can we proceed?
if ( ! valuesAttribute && ! nonEmptyValuesAttribute ) {
Expand Down

0 comments on commit e5827f1

Please sign in to comment.