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: Multiple maxkb tag specifies different ids #1865

Closed
wants to merge 1 commit into from

Conversation

shaohuzhang1
Copy link
Contributor

fix: Multiple maxkb tag specifies different ids Closes #1659

Copy link

f2c-ci-robot bot commented Dec 18, 2024

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

f2c-ci-robot bot commented Dec 18, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -131,7 +131,7 @@ const initChat=(root)=>{
function initMaxkb(){
const maxkb=document.createElement('div')
const root=document.createElement('div')
root.id="maxkb"
root.id=crypto.randomUUID()
initMaxkbStyle(maxkb)
maxkb.appendChild(root)
document.body.appendChild(maxkb)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few issues in the provided code:

  1. Missing const initMaxkbStyle definition:
    The function initMaxkbStyle is called after being declared, but no actual implementation of this function exists.

  2. Redundant use of document.body.appendChild(root):
    Since root is added to maxkb, it should not be appended again to body.

  3. Incorrect argument passing when creating crypto.randomUUID():
    It seems like you intended to pass root.id into crypto.randomUUID(). However, crypto.randomUUID() returns a string that cannot be directly assigned to a variable without modification (e.g., converting it to an integer). You may need further clarification on how to use cryptography in your application.

Here's a simplified version with some improvements:

function initChat(root) {
  // ... existing code ...
}

let maxkb = document.createElement('div');
// Assuming crypto.randomUUID() can be used as-is, though its exact usage depends on context
let uid = crypto.randomUUID();

maxkb.setAttribute("id", uid);
initMaxkbStyle(maxkb);

document.body.appendChild(maxkb);

If there are specific parts of your project where these changes might have security implications or other constraints, please let me know!

@liuruibin liuruibin closed this Dec 18, 2024
@liuruibin liuruibin deleted the pr@main@fix_add_div2 branch December 18, 2024 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]动态注入第三方script资源时,存在重复添加maxkb标签问题
2 participants