Skip to content

Commit ad14ad1

Browse files
authored
Merge pull request #3521 from jasongrout/updatedocs
Fixes for migration docs
2 parents e80edd7 + 5eff00d commit ad14ad1

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

docs/source/migration_guides.md

+26-7
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The ``DOMWidgetView.pWidget`` property has been renamed ``DOMWidgetView.luminoWi
8888
+ this.luminoWidget
8989
```
9090

91-
The ``DOMWidgetView.processPhosphorMessage`` method has been renamed ``DOMWidgetView.processLuminoMessage``. If you want to support both ipywidgets 7.x and 8.x, you should implement both methods:
91+
The ``DOMWidgetView.processPhosphorMessage`` method has been renamed ``DOMWidgetView.processLuminoMessage``. If you want to support both ipywidgets 7.x and 8.x, you should implement both methods and call the correct super method:
9292

9393
```diff
9494
- processPhosphorMessage(msg: Message): void {
@@ -109,15 +109,15 @@ The ``DOMWidgetView.processPhosphorMessage`` method has been renamed ``DOMWidget
109109
+ }
110110
+
111111
+ processPhosphorMessage(msg: Message): void {
112-
+ this._processLuminoMessage(msg, (DOMWidgetView as any).processPhosphorMessage);
112+
+ this._processLuminoMessage(msg, super.processPhosphorMessage);
113113
+ }
114114
+
115115
+ processLuminoMessage(msg: Message): void {
116-
+ this._processLuminoMessage(msg, (DOMWidgetView as any).processLuminoMessage);
116+
+ this._processLuminoMessage(msg, super.processLuminoMessage);
117117
+ }
118118
```
119119

120-
I you're dropping ipywidgets 7.x support, you can simply rename the `processPhosphorMessage` method into `processLuminoMessage`.
120+
If you're dropping ipywidgets 7.x support, you can simply rename the `processPhosphorMessage` method to `processLuminoMessage`.
121121

122122
#### Widget manager import
123123

@@ -128,7 +128,7 @@ As mentioned before, if you depend on the ``ManagerBase`` class, you will **eith
128128
+ import { ManagerBase } from '@jupyter-widgets/base-manager';
129129
```
130130

131-
**or**, siwtch to using the new `IWidgetManager` interface in the `base` package:
131+
**or**, switch to using the new `IWidgetManager` interface in the `base` package:
132132

133133
```diff
134134
- import { ManagerBase } from '@jupyter-widgets/base';
@@ -153,7 +153,7 @@ export async function myDeserializer(
153153

154154
#### Backbone extend
155155

156-
The version of backbone that ipywidgets depend on has changed from 1.2.3 to 1.4.0. If you were extending the base widget model with `var CustomWidgetModel = Widget.extend({ ... });` you will need to update the class definition using the ES6 notation:
156+
The version of [Backbone.js](https://backbonejs.org/) that ipywidgets depends on has changed from 1.2.3 to 1.4.0. If you were extending the base widget model with `var CustomWidgetModel = Widget.extend({ ... });` you will need to update the class definition using the ES6 notation:
157157

158158
```diff
159159
- var CustomWidgetModel = Widget.extend({
@@ -164,8 +164,27 @@ The version of backbone that ipywidgets depend on has changed from 1.2.3 to 1.4.
164164
+ }
165165
```
166166

167-
Note: If you were relying on setting certain instance attributes via the `extend` method, you might now need override the `preinitialize` method in order for their values to be set in time.
167+
#### Custom tag names
168168

169+
If you were changing the base HTML tag for your widget by defining the `tagName` property, this can now be done in ipywidgets 8 in the `preinitialize` method (see https://github.com/jupyter-widgets/ipywidgets/commit/a342e0dbc7c779bb668e5a21c097d7cec9a6ac44 for example changes in core widgets):
170+
171+
```diff
172+
- get tagName() {
173+
- return 'button';
174+
- }
175+
+ preinitialize() {
176+
+ this.tagName = 'button';
177+
+ }
178+
```
179+
180+
If you need compatibility with ipywidgets 7, continue using the `get tagName` accessor instead of `preinitialize`. However, newer versions of Typescript will complain that you are overriding a property with a function. If you want to maintain compatibility with both ipywidgets 7 and ipywidgets 8, and you are using Typescript, you can add a `ts-ignore` directive to mollify Typescript, like is done in [ipydatawidgets](https://github.com/vidartf/ipydatawidgets/blob/489586982c375c03d5ffd3089dd4f427c8266443/packages/jupyter-datawidgets/src/media.ts#L131):
181+
182+
```diff
183+
+ // @ts-ignore: 2611
184+
get tagName() {
185+
return 'button';
186+
}
187+
```
169188

170189
Migrating from 6.0 to 7.0
171190
-------------------------

docs/source/user_migration_guides.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ As part of an effort to make it possible to
3333
the old `description_tooltip` attribute for certain widgets was deprecated. Now all widgets
3434
that inherit `DOMWidget` have the attribute `tooltip` instead.
3535

36-
Suggested migration: Search and replace `description_tooltip` to `tooltip`.
36+
Suggested migration: Search and replace `description_tooltip` to `tooltip` when you no longer
37+
need to support ipywidgets 7.
3738

3839
#### Selection Widgets
3940

0 commit comments

Comments
 (0)