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

DataGrid: Failed to set the 'innerHTML' property on 'Element' #8709

Closed
adamzhang1932 opened this issue May 10, 2024 · 6 comments · Fixed by #8718
Closed

DataGrid: Failed to set the 'innerHTML' property on 'Element' #8709

adamzhang1932 opened this issue May 10, 2024 · 6 comments · Fixed by #8718
Assignees

Comments

@adamzhang1932
Copy link

adamzhang1932 commented May 10, 2024

Describe the bug
When I call the 'updateRow' method in datagrid.js, an error occured:

Failed to set the 'innerHTML' property on 'Element': The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler?

To Reproduce

Sorry for that it is not easy to reproduce, the error just occurred after we upgrading IDS from v4.91.0 to v4.91.1.
And in v4.91.0, our codes worked well.

Expected behavior
A clear and concise description of what you expected to happen.

Version

  • ids-enterprise: v4.91.1

Screenshots
If applicable, add screenshots to help explain your problem.

Platform

  • Infor Application/Team Name: Infor SunSystems
  • Device:
  • OS Version: Windows 11
  • Browser Name: chrome
  • Browser Version: 124.0.6367.119 (Official Build) (64-bit)

Additional context
1.In firefox, it works well, the error occurred when I use the chrome browser.
2.For the codes in updateCellNode method in datagrid.js file:
wrapper[0].innerHTML = formatted; ,
I am wondering if the above codes in IDS can be changed through some solutions:
Solution 1:
Define a new method which can avoid the xss attack, for example escapeHtml and then:
wrapper.html(escapeHtml(formatted));
Solution 2:
// If using innerHTML throws an exception, then use the fallback method.

try {
  wrapper[0].innerHTML = formatted;
} catch (e) {
  wrapper.empty().append(formatted);
}
@tmcconechy tmcconechy changed the title DataGrid: Failed to set the 'innerHTML' property on 'Element': The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler? DataGrid: Failed to set the 'innerHTML' property on 'Element' May 10, 2024
@tmcconechy
Copy link
Member

@adamzhang1932 So this only happens in your app not in the examples? I think maybe we need to see why wrapper is empty?

The latest code has a check here..

    const wrapper = cellNode.find('.datagrid-cell-wrapper');
    if (!isInline && wrapper[0]) {
      wrapper[0].innerHTML = formatted;

So does the diff 4.91.0...4.91.1#diff-13c32b0c73b40992aa6d376fb22d6746845a3b7d6d2545e19bd30687bcabb5a5R11481

Can you test against the latest version? Even if you cant upgrade this would help us know. I personally dont like the try approach if we dont know why its happening or cant reproduce but willing to look at other solutions.

@adamzhang1932
Copy link
Author

adamzhang1932 commented May 11, 2024

1.The error happened in my app.
2.I tried the IDS v4.95.0 just now, the error is still here.

@adamzhang1932
Copy link
Author

adamzhang1932 commented May 11, 2024

Some things need to know is:
1.The error happened in my app indicated that it is caused by the code in IDS:
image

2.And only when I use Chrome browser, the error will occur, and when I use Firefox, everything is fine.
3.When I change the IDS code as below, everything will be fine in Chrome browser and Firefox browser.

if (!isInline && wrapper[0]) {
  wrapper.html(formatted;)

  const children = wrapper.children();
  if (children.length === 0) {
	wrapper.innerText = xssUtils.unescapeHTML(formatted);
  }
}

@InforBG
Copy link

InforBG commented May 14, 2024

This issue can be reproduced starting from 4.91.1+. The change is #8447.

@tmcconechy tmcconechy removed the status: clarification Issue needs clarification label May 14, 2024
@tmcconechy tmcconechy self-assigned this May 14, 2024
@tmcconechy
Copy link
Member

ok @adamzhang1932 @InforBG I tried the suggestion please review #8718
But still not sure why the existing check wouldnt work. But seems equal and didnt break anything so far.

@adamzhang1932
Copy link
Author

@tmcconechy Thanks a lot.
And I left one comment for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants