-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Fusion Attributes with dots don't get correct rendered #3112
Comments
That's strange. I would've expected that writing it like this |
The fusion parser doesn't understand quoted keys, it's not something it understands. That might be possible to implement but I am not sure it's easy or even a great idea. Looking at Alpine.js website I would say they do not conform to HTML spec for attribute names (dots are allowed but colons and a couple of other things I don't think). |
But it seems to be supported or at least it has been supported at some point. But I haven't tested this any further. This is from the Fusion parser:
|
I'm also running into the issue, and reading it I'm wondering 2 things:
|
Quoted keys basically work. I use something like this in the SEO package:
But dots are still a no-go. |
That's a valid point IMO. No matter if the value doesn't conform to standard X/Y/Z, there needs to be a way to escape a sequence of characters in the language syntax, such that the output is unaltered. What is the reason that a dot within a quoted property needs to be interpreted (and removed)? |
What I still fail to understand is why this wouldn't work. Is Like:
should turn into And even for:
Fusion has no notion of I didn't dig code yet, so I'm not sure how afx / fusion work in detail. But I can imagine afx not passing attributes that start with an '@' if they are not known to fusion anyway. And for the dotted notation I personally can not think of a use case that would really require parsing Fusion objects in the attribute name... |
I would love to know how the "dotted annotation" should work by the way... If I can really use a fusion object in the attribute name something like this should work too ;) but then I'd love to know what the syntax should be like :p Currently it outputs
|
In your example For Fusion components in AFX all attributes are directly passed as props. See also https://github.com/neos/fusion-afx |
ok, so to make it "work" my example should create the following (pseudo code :p ):
where the problem with the dotted annotation would be "we don't know if the deeper path with .away" exists?
|
That seems to be a viable solution for this part of the issue: neos/fusion-afx#34
Can we make up a list of examples with dots in the attribute name that would actually lead to a valid / expected result in afx which do not start with |
Structured apis are not uncommon in fusion; A very basic example is tag-attributes. Offcourse this can be written in afx easier but it is valid: Also NeosFusionForm uses things like this: |
Ok, so
Would conflict if one has code like
And there's basically no fair chance to detect that probably. Can't we simply configure a list of "ignored" prefixes? Like:
While playing around with the
is valid, but this leads to an error:
|
The main switch we do in afx is between html tags and fusion-component tags. The latter ones are defined as containing an ':'. I think as long as we limit the effects to html tags it would be fine and fair to support dots in attributes so: Question is is this a rule that people will understand? |
I'm not in favour of introducing too many behaviours for html tags that are different for components. Already the attributes behaviour sometimes confuses people and makes AFX less transparent (even though it helps a lot). |
What do you think about the solution to something like this:
|
I've been thinking about it during a walk. I was on the track that having the dotted annotation being directly passed to the fusion component is wrong, but I changed my mind. I think a frontend developer would expect the dotted notation to translate to the object structure of the component. And that's exactly what afx / fusion is doing now. So then the question would be what syntax would be most self-explaining / easiest to understand / handle. Patterns could work, an extra registered meta char (that marks 'skipping') could work, but maybe the quoting is the closest to actual Fusion and it's probably the most performant one. And if we would also require the quotes for the |
fixes neos#3112 - Fusion parser: dont split paths at dots, who are inside quotes. - AFX: allow quoted attribute identifier. Example: AFX: ```html <div '@foo.bar'='baz'></div> ``` Fusion: ```ts Neos.Fusion:Tag { attributes.'@foo.bar' = 'baz' } ``` Fusion ast (excerpt): ```php 'attributes' => [ '@foo.bar' => 'baz' ] ``` Before this, AFX doesnt allow quoted attribute identifier, and the Fusion Parser split at dots in quotes too, making those paths nested.
i played around with this and made a pr. With ~10 lines of changed code this would be solved (the rest are tests ^^) #3442 As in the pr explained, there a two problems:
That means that allowing this AFX so this Fusion :
should be parsed to: {
"__objectType": "Neos.Fusion:Tag",
"attributes": {
"@foo.bar": "baz"
}
} but it gets parsed to: {
"__objectType": "Neos.Fusion:Tag",
"attributes": {
"@foo": {
"bar'": "baz"
}
}
} |
If I want to use special attributes which contains dots, these attributes don't get rendered correct
x-on:click.away
x-on:click
x-on:keydown.window.escape
You may ask why to use such attributes. Well, if you use libraries like Alpine.js you'll need these kind of attributes.
Currently, I solved this like this:
x-on:keydown_DOT_window_DOT_escape
and add a@process
like this${String.replace(value, '_DOT_', '.')}
. But I don't really like this aproach…The text was updated successfully, but these errors were encountered: