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

Built in element selectors should respect component encapsulation #29

Open
skulptur opened this issue Jun 28, 2020 · 4 comments
Open

Built in element selectors should respect component encapsulation #29

skulptur opened this issue Jun 28, 2020 · 4 comments

Comments

@skulptur
Copy link
Contributor

A component should only be able to select elements that are in the scope of this data-component element. Elements within other data-component elements should be handled in their own component. If that access is needed it should be explicit.

@ThaNarie
Copy link
Member

This pattern is already somewhat enforced through the existing getElement:
https://github.com/mediamonks/muban-core/blob/master/src/lib/CoreComponent.ts#L35

Passing a second container argument (that is different from the element) makes it already more explicit (although it's probably mostly used for more specific selectors, rather than from other components, but still).

What do you propose?

@skulptur
Copy link
Contributor Author

I think what we have only takes care of selecting elements down the tree. But it should be down the tree except if it's in a child component's scope, if that makes sense.

@skulptur
Copy link
Contributor Author

The parents are breaking encapsulation of their children right now.

@ThaNarie
Copy link
Member

That I agree with!

Maybe we can do something that the queried elements first will be checked in which (nearest) parent they are situated, and throw an error before returning them - unless you explicitly pass a flag that overrides this behaviour.

this.getElement('.some-class-in-child-compment', { ignoreCheck: true });

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

No branches or pull requests

2 participants