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 double rendering of components in SSR mode after hydration in Angular #28685

Open
wants to merge 8 commits into
base: 25_1
Choose a base branch
from
Next Next commit
Fix double rendering of renovated components in ssr mode angular (T12…
…55582)
GoodDayForSurf committed Jan 8, 2025
commit 147d5a21a0e356c4c0e3938b87f2bdc556c75186
12 changes: 9 additions & 3 deletions packages/devextreme-angular/src/server/render.ts
Original file line number Diff line number Diff line change
@@ -21,15 +21,21 @@ export class DxServerModule {
const el = infernoRenderer.createElement(component, props);
const document = container.ownerDocument;
const temp = document.createElement(container.tagName);

temp.innerHTML = renderToString(el);

const mainElement = temp.childNodes[0];
const childString = mainElement.innerHTML;

for (let i = 0; i < mainElement.attributes.length; i++) {
temp.setAttribute(mainElement.attributes[i].name, mainElement.attributes[i].value);
const attr = mainElement.attributes[i];

if (!container.hasAttribute(attr.name)) {
container.setAttribute(attr.name, attr.value);
}
}
temp.innerHTML = childString;
container.outerHTML = temp.outerHTML;

container.innerHTML = childString;
},
});
}