mirror of
https://github.com/open-webui/open-webui.git
synced 2026-03-24 20:14:58 -05:00
refac: Multiple document.getElementById accross the codebase #405
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Carlos-err406 on GitHub (Mar 3, 2024).
Bug Report
Description
Bug Summary:
there are many document.getElementById across the code see img.
this has performace and code cleanness issues as well as a safety impact, see
additional informationsection below.Steps to Reproduce:
Expected Behavior:
use a bind:this to the needed elements to save the element into a store so is more accessible, does less queries to the dom and keeps the code cleaner
Actual Behavior:
there are many queries to the DOM that could be avoided
Environment
Reproduction Details
Confirmation:
Logs and Screenshots
Browser Console Logs:
[Include relevant browser console logs, if applicable]
Docker Container Logs:
[Include relevant Docker container logs, if applicable]
Screenshots (if applicable):
[Attach any relevant screenshots to help illustrate the issue]
Installation Method
[Describe the method you used to install the project, e.g., manual installation, Docker, package manager, etc.]
Additional Information
Storing an element in a Svelte store offers several advantages over using document.getElementById throughout a codebase:
Note
If the bug report is incomplete or does not follow the provided instructions, it may not be addressed. Please ensure that you have followed the steps outlined in the README.md and troubleshooting.md documents, and provide all necessary information for us to reproduce and address the issue. Thank you!
@Carlos-err406 commented on GitHub (Mar 3, 2024):
i could contribute on this if thats ok
@tjbck commented on GitHub (Mar 3, 2024):
I deliberately choose to use
document.getElementByIdto allow more flexibility and some parts of the code that's the only way to have everything function correctly, but I see how the rest of the code could be replaced withbind:thiswithout causing any issues, you just have to discern and find which ones. I believe this is a marginal improvement to the code and might introduce unintended bugs if not done properly so I'm hesitant to change, but the obvious part I believe we can make the switch, Feel free to make a PR!