Skip to content

Commit

Permalink
chore: review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
misbiheyv committed Jul 16, 2024
1 parent 074a640 commit bf96dcf
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Changelog
_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.?? (2024-07-??)

#### :bug: Bug Fix
* Fix bug, when event name sets as event modifier in v-attrs directive `core/component/directives/attrs`

## v4.0.0-beta.107 (2024-07-10)

#### :bug: Bug Fix
Expand Down
8 changes: 4 additions & 4 deletions src/core/component/directives/attrs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ Changelog
> - :house: [Internal]
> - :nail_care: [Polish]
## ??? (2024-07-15)
## v4.0.0-beta.?? (2024-07-??)

#### :house: Internal
#### :house: Internal

* Added new tests for cases when event named as registered key modifier

#### :bug: Bug Fix

* Remove event name from flags list to properly handle the event flags.
* Replaced the method calls to `componentCtx.$once` and `componentCtx.$on` to correctly handle events based on the isOnceEvent flag.
* Remove event name from flags list to properly handle the event flags
* Replaced the method calls to `componentCtx.$once` and `componentCtx.$on` to correctly handle events based on the isOnceEvent flag

## v4.0.0-alpha.1 (2022-12-14)

Expand Down
16 changes: 9 additions & 7 deletions src/core/component/directives/attrs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import type { ComponentInterface } from 'core/component/interface';
import type { DirectiveParams } from 'core/component/directives/attrs/interface';

//#if runtime has dummyComponents
import('core/component/directives/attrs/test/b-component-emitter-dummy');
import('core/component/directives/attrs/test/b-component-directives-emitter-dummy');
//#endif

export * from 'core/component/directives/attrs/const';
Expand Down Expand Up @@ -325,18 +325,20 @@ ComponentEngine.directive('attrs', {
function parseEventListener(attrName: string, attrVal: unknown) {
let
isDOMEvent = true,
event = attrName.slice(1).camelize(false);
event = attrName.slice(1).camelize(false),
isOnceEvent = false;

const
originalEvent = event,
eventChunks = event.split('.');

const
flags = Object.createDict<boolean>(),
isOnceEvent = flags.once;
eventChunks = event.split('.'),
flags = Object.createDict<boolean>();

/*
* First element is event name, we need to slice only part event modifiers
*/
eventChunks.slice(1).forEach((chunk) => flags[chunk] = true);
event = eventChunks[0];
isOnceEvent = Boolean(flags.once);

if (flags.right && !event.startsWith('key')) {
event = 'onContextmenu';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ $p = {

}

b-component-emitter-dummy extends i-block
b-component-directives-emitter-dummy extends i-block
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import iBlock, { component, system } from 'components/super/i-block/i-block';

export * from 'components/super/i-block/i-block';

@component({
functional: true
})

export default class bComponentEmitterDummy extends iBlock {
@component({functional: true})
export default class bComponentDirectivesEmitterDummy extends iBlock {
@system()
counter: number = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/

package('b-component-emitter-dummy')
package('b-component-directives-emitter-dummy')
.extends('i-block');
6 changes: 3 additions & 3 deletions src/core/component/directives/attrs/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import type { Watcher } from 'components/directives/on-resize';

import { Component } from 'tests/helpers';

import type bComponentEmitterDummy from 'core/component/directives/attrs/test/b-component-emitter-dummy/b-component-emitter-dummy'
import type bComponentDirectivesEmitterDummy from 'core/component/directives/attrs/test/b-component-directives-emitter-dummy/b-component-directives-emitter-dummy'

export async function renderDummy(page: Page, attrs: RenderComponentsVnodeParams['attrs']) {
return Component.createComponent<bComponentEmitterDummy>(page, 'b-component-emitter-dummy', {
return Component.createComponent<bComponentDirectivesEmitterDummy>(page, 'b-component-directives-emitter-dummy', {
'data-testid': 'target',
'v-attrs': {
...attrs
Expand Down Expand Up @@ -76,6 +76,6 @@ export function clickHandler(event: MouseEvent): void {
target.setAttribute('data-counter', nextValue.toString());
}

export function dummyDeleteHandler(target: bComponentEmitterDummy) {
export function dummyDeleteHandler(target: bComponentDirectivesEmitterDummy) {
target.counter++;
}

0 comments on commit bf96dcf

Please sign in to comment.