Skip to content

Commit 7e76c8e

Browse files
committed
Add note about keeping get tagName for ipywidgets 7 compatibility
1 parent 2ee91b5 commit 7e76c8e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/source/migration_guides.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Note: If you were relying on setting certain instance attributes via the `extend
168168

169169
#### Custom tag names
170170

171-
If you were changing the base HTML tag by defining the `tagName` property, this can now be done in the `preinitialize` method (see https://github.com/jupyter-widgets/ipywidgets/commit/a342e0dbc7c779bb668e5a21c097d7cec9a6ac44 for example changes in core widgets):
171+
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):
172172

173173
```diff
174174
- get tagName() {
@@ -179,6 +179,15 @@ If you were changing the base HTML tag by defining the `tagName` property, this
179179
+ }
180180
```
181181

182+
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):
183+
184+
```diff
185+
+ // @ts-ignore: 2611
186+
get tagName() {
187+
return 'button';
188+
}
189+
```
190+
182191
Migrating from 6.0 to 7.0
183192
-------------------------
184193

0 commit comments

Comments
 (0)