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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/application/template/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
Loading