mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-13 11:57:29 +08:00
Fix the Lite custom element parser so it doesn't add the .code option when the entrypoint file is already specified (#8067)
* Fix the Lite custom element parser so it doesn't add the .code option when the entrypoint file is already specified * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
176a8a4d71
commit
0fb058ec23
6
.changeset/cuddly-snakes-swim.md
Normal file
6
.changeset/cuddly-snakes-swim.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/app": minor
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Fix the Lite custom element parser so it doesn't add the .code option when the entrypoint file is already specified
|
@ -151,24 +151,29 @@ export function bootstrap_custom_element(
|
||||
}
|
||||
}
|
||||
|
||||
const codeElements = this.getElementsByTagName("gradio-code");
|
||||
if (codeElements.length === 0) {
|
||||
// If there is no <gradio-code> element, try to parse the content of the custom element as code.
|
||||
let code = "";
|
||||
this.childNodes.forEach((node) => {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
code += node.textContent;
|
||||
if (options.entrypoint == null) {
|
||||
// If no entrypoint file is specified,
|
||||
// try to find the source code to be passed to the .code option instead.
|
||||
|
||||
const codeElements = this.getElementsByTagName("gradio-code");
|
||||
if (codeElements.length === 0) {
|
||||
// If there is no <gradio-code> element, try to parse the content of the custom element as code.
|
||||
let code = "";
|
||||
this.childNodes.forEach((node) => {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
code += node.textContent;
|
||||
}
|
||||
});
|
||||
options.code = code || undefined;
|
||||
} else {
|
||||
if (codeElements.length > 1) {
|
||||
console.warn(
|
||||
"Multiple <gradio-code> elements are found. Only the first one will be used."
|
||||
);
|
||||
}
|
||||
});
|
||||
options.code = code || undefined;
|
||||
} else {
|
||||
if (codeElements.length > 1) {
|
||||
console.warn(
|
||||
"Multiple <gradio-code> elements are found. Only the first one will be used."
|
||||
);
|
||||
const firstCodeElement = codeElements[0];
|
||||
options.code = firstCodeElement?.textContent ?? undefined;
|
||||
}
|
||||
const firstCodeElement = codeElements[0];
|
||||
options.code = firstCodeElement?.textContent ?? undefined;
|
||||
}
|
||||
|
||||
const requirementsElements = this.getElementsByTagName(
|
||||
|
Loading…
x
Reference in New Issue
Block a user