File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
packages/esl/src/esl-trigger/core Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,8 @@ export abstract class ESLBaseTrigger extends ESLBaseElement {
134
134
public updateState ( ) : boolean {
135
135
const { active, isTargetActive} = this ;
136
136
137
- this . toggleAttribute ( 'active' , isTargetActive ) ;
137
+ this . $$attr ( 'no-target' , ! this . $target ) ;
138
+ this . $$attr ( 'active' , isTargetActive ) ;
138
139
const clsTarget = ESLTraversingQuery . first ( this . activeClassTarget , this ) as HTMLElement ;
139
140
clsTarget && CSSClassUtils . toggle ( clsTarget , this . activeClass , isTargetActive ) ;
140
141
@@ -159,7 +160,8 @@ export abstract class ESLBaseTrigger extends ESLBaseElement {
159
160
/** Handles ESLToggleable state change */
160
161
@listen ( {
161
162
event : ( that : ESLBaseTrigger ) => that . OBSERVED_EVENTS ,
162
- target : ( that : ESLBaseTrigger ) => that . $target
163
+ target : ( that : ESLBaseTrigger ) => that . $target ,
164
+ condition : ( that : ESLBaseTrigger ) => ! ! that . $target
163
165
} )
164
166
protected _onTargetStateChange ( originalEvent ?: Event ) : void {
165
167
if ( ! this . updateState ( ) ) return ;
Original file line number Diff line number Diff line change 1
1
esl- trigger {
2
2
cursor : pointer ;
3
+ // Default behaviour if no target is specified
4
+ & [no- target] {
5
+ filter : grayscale (100% );
6
+ cursor : not-allowed ;
7
+ pointer-events : none ;
8
+ }
3
9
}
Original file line number Diff line number Diff line change @@ -62,12 +62,8 @@ export class ESLTrigger extends ESLBaseTrigger {
62
62
/** Update `$target` Toggleable from `target` selector */
63
63
public updateTargetFromSelector ( ) : void {
64
64
if ( ! this . target ) return ;
65
- this . $target = ESLTraversingQuery . first ( this . target , this ) as ESLToggleable ;
66
-
67
- if ( this . $target instanceof ESLToggleablePlaceholder && this . $target . $origin ) {
68
- // change target if it is an instance of the placeholder element
69
- this . $target = this . $target . $origin ;
70
- }
65
+ const $target = ESLTraversingQuery . first ( this . target , this ) as ESLToggleable | ESLToggleablePlaceholder ;
66
+ this . $target = ( $target instanceof ESLToggleablePlaceholder ) ? $target . $origin : $target ;
71
67
}
72
68
73
69
/** Check if the event target should be ignored */
You can’t perform that action at this time.
0 commit comments