Skip to content
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

fix(vue): fixes model conflict between two components start with start with same tag #215

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yigityuce
Copy link

@yigityuce yigityuce commented Jan 3, 2022

Output Target: Vue

Issue Definition:
If you have a component with a tag which is included by other component tag name and the "other" component has model config with single string "elements" property, this causes wrongly definition of model config for the first component.

Example:

const componentConfig: ComponentModelConfig[] = [
  {
    elements: 'my-list-item',
    event: 'selectedChange',
    targetAttr: 'selected'
  }
];

Lets say I have a model config definition for "my-list-item" component and I have 2 components; "my-list-item" and "my-list".
The current behavior of the autogenerated component definition is:

export const MyListItem = /*@__PURE__*/ defineContainer<Components.MyListItem>('my-list-item', undefined, [],
'selected', 'selectedChange');

export const MyList = /*@__PURE__*/ defineContainer<Components.MyList>('my-list', undefined, [],
'selected', 'selectedChange');

Expected behavior:

export const MyListItem = /*@__PURE__*/ defineContainer<Components.MyListItem>('my-list-item', undefined, [],
'selected', 'selectedChange');

export const MyList = /*@__PURE__*/ defineContainer<Components.MyList>('my-list', undefined);

Workaround for current implementation:
If the user defines the element tag as an array within the model config this fixes the issue by applying a workaround.

const componentConfig: ComponentModelConfig[] = [
  {
    elements: ['my-list-item'],
    event: 'selectedChange',
    targetAttr: 'selected'
  }
];

However the better way is to check the elements property is array and find the model config regarding this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant