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

Augmenting wrapped content elements not working as expected #2988

Closed
patricekaufmann opened this issue May 26, 2020 · 3 comments
Closed

Augmenting wrapped content elements not working as expected #2988

patricekaufmann opened this issue May 26, 2020 · 3 comments

Comments

@patricekaufmann
Copy link

patricekaufmann commented May 26, 2020

I already attempted a fix 1.5 years ago: #2281 but it got rejected. I keep running into this issue while developing modular Neos components.

The issue:

When passing wrapped content elements to a fusion renderer via @props, a script tag gets added when evaluating:

$wrappedContent = $this->htmlAugmenter->addAttributes($content, $attributes, 'div');
$wrappedContent .= "<script data-neos-nodedata>(function(){(this['@Neos.Neos.Ui:Nodes'] = this['@Neos.Neos.Ui:Nodes'] || {})['{$node->getContextPath()}'] = {$serializedNode}})()</script>";

This leads to the xPath query in HtmlAugmenter.php not detecting a root element since the html is of structure <div></div><script></script>. It will break functionality for the Neos.Fusion:Augmenter since it will wrap the actual root element one more time.

More specific: It is not possible to use the Neos.Fusion:Augmenter to augment Neos.Neos:ContentCollection passed via props Context to a Neos.Fusion:Renderer because instead of augmenting the attributes on the ContentCollection div, the HtmlAugmenter can't detect a single root element and now wraps the ContentCollection div into another div.

Neos 5.2
Neos UI 5.2

@patricekaufmann
Copy link
Author

In case anyone else finds this issue: The original PR got denied some years ago and we have been using an augmenter modification like this ever since:

$rootElement = $xPath->query('//html/body/*[not(self::script and @data-neos-nodedata)]|//html/head/*[not(self::script and @data-neos-nodedata)]');

@mhsdesign
Copy link
Member

Hi ;) Thanks for this issue, i never though of this usecase ^^

The fact that there are script tags in the markup is already quite hacky and we though already of a "Minimally Invasive Content Element Wrapping" via html comments: neos/neos-ui#3231 (comment)

Once we have reworked the content element wrapping, you should not face this problem any longer. But i also have to admit that this will still likely take some time until it is ready (if it ever will be).

@Sebobo
Copy link
Member

Sebobo commented Aug 12, 2024

The script tag is gone now with #3770

@Sebobo Sebobo closed this as completed Aug 12, 2024
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

3 participants