Skip to content

Commit

Permalink
Remove deprecated overflow properties
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainCorlay committed Jan 8, 2020
1 parent 0d98108 commit e6eceeb
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 55 deletions.
10 changes: 4 additions & 6 deletions docs/source/examples/Variable Inspector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
" self.namespace.shell = ipython.kernel.shell\n",
" \n",
" self._box = widgets.Box()\n",
" self._box.layout.overflow_y = 'scroll'\n",
" self._box.layout.overflow = 'visible scroll'\n",
" self._table = widgets.HTML(value = 'Not hooked')\n",
" self._box.children = [self._table]\n",
" \n",
Expand All @@ -80,10 +80,8 @@
" '</td></tr><tr><td>'.join(['{0}</td><td>{1}</td><td>{2}'.format(v, type(eval(v)).__name__, str(eval(v))) for v in values]) + \\\n",
" '</td></tr></table></div>'\n",
"\n",
" def _ipython_display_(self):\n",
" \"\"\"Called when display() or pyout is used to display the Variable \n",
" Inspector.\"\"\"\n",
" self._box._ipython_display_()\n"
" def _repr_mimebundle_(self, **kwargs):\n",
" return self._box._repr_mimebundle_(**kwargs)"
]
},
{
Expand Down Expand Up @@ -181,7 +179,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
2 changes: 0 additions & 2 deletions docs/source/examples/Widget Styling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
"- `visibility`\n",
"- `display`\n",
"- `overflow`\n",
"- `overflow_x` (deprecated) \n",
"- `overflow_y` (deprecated)\n",
"\n",
"#### Box model\n",
"\n",
Expand Down
9 changes: 0 additions & 9 deletions ipywidgets/widgets/widget_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class Layout(Widget):
min_height = Unicode(None, allow_none=True, help="The min-height CSS attribute.").tag(sync=True)
min_width = Unicode(None, allow_none=True, help="The min-width CSS attribute.").tag(sync=True)
overflow = Unicode(None, allow_none=True, help="The overflow CSS attribute.").tag(sync=True)
overflow_x = CaselessStrEnum(['visible', 'hidden', 'scroll', 'auto'] + CSS_PROPERTIES, allow_none=True, help="The overflow-x CSS attribute (deprecated).").tag(sync=True)
overflow_y = CaselessStrEnum(['visible', 'hidden', 'scroll', 'auto'] + CSS_PROPERTIES, allow_none=True, help="The overflow-y CSS attribute (deprecated).").tag(sync=True)
order = Unicode(None, allow_none=True, help="The order CSS attribute.").tag(sync=True)
padding = Unicode(None, allow_none=True, help="The padding CSS attribute.").tag(sync=True)
right = Unicode(None, allow_none=True, help="The right CSS attribute.").tag(sync=True)
Expand All @@ -77,13 +75,6 @@ class Layout(Widget):
grid_column = Unicode(None, allow_none=True, help="The grid-column CSS attribute.").tag(sync=True)
grid_area = Unicode(None, allow_none=True, help="The grid-area CSS attribute.").tag(sync=True)

@validate('overflow_x', 'overflow_y')
def _validate_overflows(self, proposal):
if proposal.value is not None:
import warnings
warnings.warn("Layout properties overflow_x and overflow_y have been deprecated and will be dropped in a future release. Please use the overflow shorthand property instead", DeprecationWarning)
return proposal.value


class LayoutTraitType(Instance):

Expand Down
36 changes: 0 additions & 36 deletions packages/base/src/widget_layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ let css_properties: {[key: string]: string} = {
min_height: null,
min_width: null,
overflow: null,
overflow_x: null, // deprecated
overflow_y: null, // deprecated
order: null,
padding: null,
right: null,
Expand Down Expand Up @@ -91,19 +89,6 @@ class LayoutView extends WidgetView {
registerTrait(trait: string) {
this._traitNames.push(trait);

// Treat overflow_x and overflow_y as a special case since they are deprecated
// and interact in special ways with the overflow attribute.
if (trait === 'overflow_x' || trait === 'overflow_y') {
// Listen to changes, and set the value on change.
this.listenTo(this.model, 'change:' + trait, (model: any, value: any) => {
this.handleOverflowChange(trait, value);
});

// Set the initial value on display.
this.handleOverflowChange(trait, this.model.get(trait));
return;
}

// Listen to changes, and set the value on change.
this.listenTo(this.model, 'change:' + trait, (model: LayoutModel, value: any) => {
this.handleChange(trait, value);
Expand Down Expand Up @@ -139,27 +124,6 @@ class LayoutView extends WidgetView {
}
}

/**
* Handles when the value of overflow_x or overflow_y changes
*/
handleOverflowChange(trait: string, value: any) {
// This differs from the default handleChange method
// in that setting `overflow_x` or `overflow_y` to null
// when `overflow` is null removes the attribute.
let parent = this.options.parent as DOMWidgetView;
if (parent) {
if (value === null) {
if (this.model.get('overflow') === null) {
parent.el.style.removeProperty(this.css_name(trait));
}
} else {
parent.el.style[this.css_name(trait)] = value;
}
} else {
console.warn('Style not applied because a parent view does not exist');
}
}

/**
* Remove the styling from the parent view.
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/schema/jupyterwidgetmodels.latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ Attribute | Type | Default | Help
`object_position` | `null` or string | `null` | The object-position CSS attribute.
`order` | `null` or string | `null` | The order CSS attribute.
`overflow` | `null` or string | `null` | The overflow CSS attribute.
`overflow_x` | `null` or string (one of `'visible'`, `'hidden'`, `'scroll'`, `'auto'`, `'inherit'`, `'initial'`, `'unset'`) | `null` | The overflow-x CSS attribute (deprecated).
`overflow_y` | `null` or string (one of `'visible'`, `'hidden'`, `'scroll'`, `'auto'`, `'inherit'`, `'initial'`, `'unset'`) | `null` | The overflow-y CSS attribute (deprecated).
`padding` | `null` or string | `null` | The padding CSS attribute.
`right` | `null` or string | `null` | The right CSS attribute.
`top` | `null` or string | `null` | The top CSS attribute.
Expand Down

0 comments on commit e6eceeb

Please sign in to comment.