Closed
Description
Description
In previous versions 5.0.3
, when rendering a Label widget, the text would be renderer.
However in the latest version it is not renderer.
Reproduce
- You need to install VS Code
- Run the following cell in a notebook
import ipywidgets as widgets
widgets.Label(value='Label Widget')
Expected behavior
The label should be rendered
Context
Sorry, but I do not think the rest is necessary, hence skipping that.
Its pretty easy to see whats going on here, see below
- In VS Code,
window.MathJax
isundefined
- In VS Code
latexTypesetter
is alsoundefined
- As a result, the element content is never set.
typeset(element: HTMLElement, text?: string): void {
this.displayed.then(() => {
if ((window as any).MathJax?.Hub?.Queue) {
return typeset(element, text);
}
const widget_manager: any = this.model.widget_manager;
const latexTypesetter = widget_manager._rendermime?.latexTypesetter;
if (latexTypesetter) {
if (text !== void 0) {
element.textContent = text;
}
latexTypesetter.typeset(element);
}
});
}
Note:
The typeset
function in utils.ts
will already check whether MathJax is available.
Hence there's no need to test the availability.
export function typeset(element: HTMLElement, text?: string): void {
if (text !== void 0) {
element.textContent = text;
}
if ((window as any).MathJax !== void 0) {
MathJax!.Hub!.Queue(['Typeset', MathJax.Hub, element]);
}
}
I think the right fix is
typeset(element: HTMLElement, text?: string): void {
this.displayed.then(() => {
const widget_manager: any = this.model.widget_manager;
const latexTypesetter = widget_manager._rendermime?.latexTypesetter;
if (latexTypesetter) {
if (text !== void 0) {
element.textContent = text;
}
latexTypesetter.typeset(element);
} else {
return typeset(element, text);
}
});
}
Previously it used to be this.displayed.then(() => typeset(element, text));
The change was introduced in this commit (basically there's never a fallback if either one is not present)
388c782#diff-5cc2749aa43c522b3c6b9485d1c9f7b93df1536d43c18ca94553f3a55f70b03fL69
Metadata
Metadata
Assignees
Labels
No labels