|
1 | | -from traitlets import Unicode, Instance, Union, List, Any, Dict |
2 | 1 | from ipywidgets import DOMWidget |
3 | | -from ipywidgets.widgets.widget_layout import Layout |
4 | | -from ipywidgets.widgets.widget import widget_serialization, CallbackDispatcher |
5 | 2 | from ipywidgets.widgets.trait_types import InstanceDict |
| 3 | +from ipywidgets.widgets.widget import CallbackDispatcher, widget_serialization |
| 4 | +from ipywidgets.widgets.widget_layout import Layout |
| 5 | +from traitlets import Any, Dict, Instance, List, Unicode, Union, default |
6 | 6 |
|
7 | 7 | from ._version import semver |
8 | | -from .ForceLoad import force_load_instance |
| 8 | +from .ForceLoad import ForceLoad |
| 9 | +from .util import singleton |
9 | 10 |
|
10 | 11 |
|
11 | 12 | class ClassList: |
@@ -138,10 +139,18 @@ class VueWidget(DOMWidget, Events): |
138 | 139 |
|
139 | 140 | # Force the loading of jupyter-vue before dependent extensions when in a static |
140 | 141 | # context (embed, voila) |
141 | | - _jupyter_vue = Any(force_load_instance, read_only=True).tag( |
| 142 | + # this happens when e.g. jupyter-vuedraggable requires jupyter-vue, but it is not |
| 143 | + # loaded yet (via a widget creation). This does not trigger the library loading |
| 144 | + # via the widget manager, but straight through requirejs |
| 145 | + |
| 146 | + _jupyter_vue = Instance(ForceLoad, read_only=True).tag( |
142 | 147 | sync=True, **widget_serialization |
143 | 148 | ) |
144 | 149 |
|
| 150 | + @default("_jupyter_vue") |
| 151 | + def _default_jupyter_vue(self): |
| 152 | + return singleton(ForceLoad) |
| 153 | + |
145 | 154 | _model_name = Unicode("VueModel").tag(sync=True) |
146 | 155 |
|
147 | 156 | _view_name = Unicode("VueView").tag(sync=True) |
|
0 commit comments