Conversation
|
question: Does that mean that now we can have component and 2 directives that have the same input name and still apply diffrent values to them? Like: |
|
What element will be added to the DOM, For example, to convert this: into this: |
Yes, all the bindings are targeted so you can pass different values to each of them.
Yes, it will create the |
|
I supposse there will be a RFC but any thoughts about this syntax: this way we won't need to write so again clear distinction between what is html event and angular output also mayby Generic types?
|
eb3db92 to
25fd131
Compare
|
It think these are two features here. Selecterless would get a thumb up from me. Really useful to keep in line with web standard tags without nested weird tag names. The attribute style thing is sonething that needs discussion. |
I agree. Selectorlews been lovely using a lite version for a year now. But don't like the @ i much rather use the use: prefix makes it cleaner in my view. Take a look at solidjs |
|
I really like the distinction between html attributes and directives because right now when a directive isn't imported the language service thinks it is a html attribute, and targeted bindings is NEEDED since it solves the overlap when combining directives that have similar inputs/output. good stuff |
|
😅 <div @Dir(...props)></div> |
You could always do that with attribute component selectors: |
|
We apply styles to taiga.ui(but can be any lib) component/directives or add functionality that we need anytime we use libs Comp/Dir just applying our directive to the same selector as libs Comp/Dir. With the selectorless approach, I don't see a way to do so without manually adding our directives whenever we use libs Comp/Dir, even though we consider it a default state. |
11b96df to
426ca0f
Compare
Please don't limit this; at least make such a limitation optional. The only issue I can see right now is that someone might apply it to a void element, but I think the compiler can easily report an error about that. |
With the exception of some elements like input and textarea. Will this new syntax support using input as well? |
You are right, @waterplea, I confused it with this: and result should be: I think selectorless will not allow it either.
input is a void element, it can not have content. Applying components is pointless. |
Is this going to be possible? :D This my biggest pain point regarding this framework 😄 |
|
Will the newly proposed Template Syntax for selectorless components/directives also apply to existing components/directives that have a selector specified? In other words, will it be backward-compatible? I am considering reusing components/directives from older libraries or Angular versions. My idea is to ignore the selector definition when using the new approach. Is that possible? |
|
So why is it And why is it Also, something like I can see why you'd want to replace the host with an actual element one can use but I'm not sure if this is the right direction to go for. We could have the parent decide what the element should be, but also have the component itself decide (or even give multiple variants as part of its configuration where the parent can give input to what variant you want. In cases where you'd want a Sidenote: from the Flow Syntax, I preferred it when you gave the community multiple options and didn't start with a PR but rather a discussion and made clear why you'd want it and what limitations you can think of that decide the boundaries in which the community can provide feedback. |
There was a problem hiding this comment.
Can you explain this more? I'm not really following how this happens or what the special case is. Wouldn't @Dir(someAttr) have openParens===1?
There was a problem hiding this comment.
I'll elaborate the comment a bit more, but the explanation is that the @Dir( already got captured as other tokens (directive name and directive open) so at this point we're parsing someAttr). It'll keep parsing until it hits a termination character for an attribute name (whitespace, equals etc.). We can't just ignore all parens in attribute names, because it handles things like (click).
I'll also move the code around a bit since this is used both for attribute names and tag names. It should apply only for attributes.
There was a problem hiding this comment.
Should we update the error message? It seems like it could be more helpful. Like we know that we're expecting :button after MyComp so we could ask if they meant MyComp:button?
There was a problem hiding this comment.
Good point, I added some logic to suggest the opening tag name if it's currently inside an unclosed component.
What do you mean? You could use it on inputs too. I do that all the time. @e-oz while it's true that input is a void element and cannot have content it can still have template as a component where you can define
Limiting tags that components can be applied to absolutely makes sense. You can have a component that is applied to buttons only, because it takes care of disabled state and a version of it for links to look like buttons, for example, but it cannot be applied to random span/div. We often have the same component twice say
💯 @Martinspire — it definitely should be the other way around, especially keeping in mind my argument above. I want to type
Because
I want to reiterate, because scanning through this discussion it seems like people are missing this: you can do |
Sets up the tokenization for the new experimental selectorless components as a first step towards producing an AST.
Sets up tokenization for the new experimental directive syntax.
Adds `startSourceSpan` and `endSourceSpan` to the `Content` AST node so it's consistent with the rest of the element-like nodes.
… tag name Currently it's required to pass in the tag name when determining the security context, however with selectorless we might not have a tag name. These changes update the logic to account for it.
Adds the initial logic to produce the `Component` and `Directive` AST nodes from their equivalents in the HTML AST.
Updates the various visitors to add placeholders for the new AST nodes.
426ca0f to
2940727
Compare
crisbeto
left a comment
There was a problem hiding this comment.
Feedback has been addressed.
There was a problem hiding this comment.
I'll elaborate the comment a bit more, but the explanation is that the @Dir( already got captured as other tokens (directive name and directive open) so at this point we're parsing someAttr). It'll keep parsing until it hits a termination character for an attribute name (whitespace, equals etc.). We can't just ignore all parens in attribute names, because it handles things like (click).
I'll also move the code around a bit since this is used both for attribute names and tag names. It should apply only for attributes.
There was a problem hiding this comment.
Good point, I added some logic to suggest the opening tag name if it's currently inside an unclosed component.
I like that even more, so we can have |
|
@muuvmuuv what issues with VCR.createComponent and ng-container are you talking about? This changes nothing from writing |
I understand this, but if a user applies something like |
|
One thing i cant see in the inital PR comments and reading through the code. What happening about pipes. Surely same support should be added here. If not is the idea to drop pipes for signals computed values/function calls? |
This would be a good topic for the RFC :) None of the syntax here is set in stone, but we need to start somewhere. |
|
This PR was merged into the repository by commit 92c4123. The changes were merged into the following branches: main |
Sets up tokenization for the new experimental directive syntax. PR Close #60724
Updates the HTML parser to produce AST nodes from the tokens produced that were added to the lexer in the previous commit. PR Close #60724
Integrates the `Component` and `Directive` nodes into the various visitors. PR Close #60724
Adds `startSourceSpan` and `endSourceSpan` to the `Content` AST node so it's consistent with the rest of the element-like nodes. PR Close #60724
Adds the initial logic to produce the `Component` and `Directive` AST nodes from their equivalents in the HTML AST. PR Close #60724
Updates the various visitors to add placeholders for the new AST nodes. PR Close #60724
|
I like the new selector less syntax, also the host element is great and powerful, but I'm not sure about the @directive syntax. we're using @ for control flow statements. Maybe & like saying "and" <MatButton:a href="/admin"
&HasRipple
&Tooltip(message="Cannot navigate" [disabled]="hasPermissions")
>Admin</MatButton:a>So we could read it as "MatButton hosted with tag, and HasRipple, and Tooltip". |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
These changes are an initial implementation of the template parsing for selectorless templates. Here's an example showing most of the syntax where we create a
MatButtoncomponent as a link, we apply theHasRippledirective without any inputs and set a tooltip that's only enabled if the user doesn't have permissions to go to the admin page: