Skip to content

Commit

Permalink
refactor!: drop render() method support (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen authored Oct 11, 2021
1 parent a9f301b commit ce0521a
Show file tree
Hide file tree
Showing 26 changed files with 12 additions and 314 deletions.
11 changes: 0 additions & 11 deletions packages/combo-box/src/vaadin-combo-box-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,6 @@ export const ComboBoxMixin = (subclass) =>
});
}

/**
* Manually invoke existing renderer.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render() {
console.warn('WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.');

this.requestContentUpdate();
}

/**
* Opens the dropdown list.
*/
Expand Down
21 changes: 0 additions & 21 deletions packages/combo-box/test/item-renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,6 @@ describe('item renderer', () => {
expect(comboBox.renderer.callCount).to.be.equal(comboBox.items.length * 2);
});

it('should request content update when calling deprecated render()', () => {
const stub = sinon.stub(comboBox, 'requestContentUpdate');
comboBox.opened = true;
comboBox.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
});

it('should warn when calling deprecated render()', () => {
const stub = sinon.stub(console, 'warn');
comboBox.opened = true;
comboBox.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
expect(stub.args[0][0]).to.equal(
'WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.'
);
});

it('should not throw if requestContentUpdate() called before opening', () => {
expect(() => comboBox.requestContentUpdate()).not.to.throw(Error);
});
Expand Down
7 changes: 0 additions & 7 deletions packages/context-menu/src/vaadin-context-menu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,6 @@ declare class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(Ges
*/
requestContentUpdate(): void;

/**
* Manually invoke existing renderer.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render(): void;

/**
* Closes the overlay.
*/
Expand Down
11 changes: 0 additions & 11 deletions packages/context-menu/src/vaadin-context-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,6 @@ class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(GestureEven
this.$.overlay.requestContentUpdate();
}

/**
* Manually invoke existing renderer.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render() {
console.warn('WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.');

this.requestContentUpdate();
}

/** @private */
_rendererChanged(renderer, items) {
if (items) {
Expand Down
21 changes: 0 additions & 21 deletions packages/context-menu/test/renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,6 @@ describe('renderer', () => {
expect(menu.renderer.calledTwice).to.be.true;
});

it('should request content update when calling deprecated render()', () => {
const stub = sinon.stub(menu, 'requestContentUpdate');
fire(target, 'vaadin-contextmenu');
menu.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
});

it('should warn when calling deprecated render()', () => {
const stub = sinon.stub(console, 'warn');
fire(target, 'vaadin-contextmenu');
menu.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
expect(stub.args[0][0]).to.equal(
'WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.'
);
});

it('should clear the content when removing the renderer', () => {
menu.renderer = (root) => {
root.innerHTML = 'foo';
Expand Down
7 changes: 0 additions & 7 deletions packages/dialog/src/vaadin-dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@ declare class Dialog extends ThemePropertyMixin(ElementMixin(DialogDraggableMixi
*/
requestContentUpdate(): void;

/**
* Manually invoke existing renderer.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render(): void;

addEventListener<K extends keyof DialogEventMap>(
type: K,
listener: (this: Dialog, ev: DialogEventMap[K]) => void,
Expand Down
11 changes: 0 additions & 11 deletions packages/dialog/src/vaadin-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,6 @@ class Dialog extends ThemePropertyMixin(ElementMixin(DialogDraggableMixin(Dialog
this.$.overlay.requestContentUpdate();
}

/**
* Manually invoke existing renderer.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render() {
console.warn('WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.');

this.requestContentUpdate();
}

/** @private */
_rendererChanged(renderer) {
this.$.overlay.setProperties({ owner: this, renderer });
Expand Down
19 changes: 0 additions & 19 deletions packages/dialog/test/renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,6 @@ describe('vaadin-dialog renderer', () => {
expect(dialog.renderer.calledTwice).to.be.true;
});

it('should request content update when calling deprecated render()', () => {
const stub = sinon.stub(dialog, 'requestContentUpdate');
dialog.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
});

it('should warn when calling deprecated render()', () => {
const stub = sinon.stub(console, 'warn');
dialog.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
expect(stub.args[0][0]).to.equal(
'WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.'
);
});

it('should clear the content when removing the renderer', () => {
dialog.renderer = (root) => {
root.innerHTML = 'foo';
Expand Down
8 changes: 0 additions & 8 deletions packages/grid/src/vaadin-grid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,6 @@ declare class Grid<TItem = GridDefaultItem> extends HTMLElement {
*/
requestContentUpdate(): void;

/**
* Manually invoke existing renderers for all the columns
* (header, footer and body cells) and opened row details.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render(): void;

/**
* Updates the computed metrics and positioning of internal grid parts
* (row/details cell positioning etc). Needs to be invoked whenever the sizing of grid
Expand Down
12 changes: 0 additions & 12 deletions packages/grid/src/vaadin-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,18 +966,6 @@ class Grid extends ElementMixin(
}
}

/**
* Manually invoke existing renderers for all the columns
* (header, footer and body cells) and opened row details.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render() {
console.warn('WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.');

this.requestContentUpdate();
}

/** @protected */
__updateVisibleRows(start, end) {
this.__virtualizer && this.__virtualizer.update(start, end);
Expand Down
19 changes: 0 additions & 19 deletions packages/grid/test/renderers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,4 @@ describe('renderers', () => {
expect(renderer.called).to.be.true;
});
});

it('should request content update when calling deprecated render()', () => {
const stub = sinon.stub(grid, 'requestContentUpdate');
grid.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
});

it('should warn when calling deprecated render()', () => {
const stub = sinon.stub(console, 'warn');
grid.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
expect(stub.args[0][0]).to.equal(
'WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.'
);
});
});
1 change: 0 additions & 1 deletion packages/grid/test/typings/grid.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ assertType<() => void>(narrowedGrid.generateCellClassNames);
assertType<boolean>(narrowedGrid.allRowsVisible);
assertType<() => void>(narrowedGrid.recalculateColumnWidths);
assertType<() => void>(narrowedGrid.requestContentUpdate);
assertType<() => void>(narrowedGrid.render);

/* GridColumn */
const genericColumn = document.createElement('vaadin-grid-column');
Expand Down
6 changes: 0 additions & 6 deletions packages/menu-bar/src/vaadin-menu-bar-buttons-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ interface ButtonsMixin {
readonly _overflow: HTMLElement;

_hasOverflow: boolean;

/**
* Call this method after updating menu bar `items` dynamically, including changing
* any property on the item object corresponding to one of the menu bar buttons.
*/
render(): void;
}

export { ButtonsMixin, ButtonsMixinConstructor };
18 changes: 0 additions & 18 deletions packages/menu-bar/src/vaadin-menu-bar-buttons-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,6 @@ export const ButtonsMixin = (superClass) =>
}
}

/**
* Call this method after updating menu bar `items` dynamically, including changing
* any property on the item object corresponding to one of the menu bar buttons.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. The `items` value is immutable. Please replace it with a new value instead of mutating in place.
*/
render() {
console.warn(
'WARNING: Since Vaadin 21, render() is deprecated. The items value is immutable. Please replace it with a new value instead of mutating in place.'
);

if (!this.shadowRoot) {
return;
}

this.__renderButtons(this.items);
}

/** @protected */
_removeButtons() {
const container = this._container;
Expand Down
30 changes: 7 additions & 23 deletions packages/menu-bar/test/menu-bar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,11 @@ describe('root menu layout', () => {
});
});

it('should not throw when render() is called before menu bar is attached', () => {
expect(() => document.createElement('vaadin-menu-bar').render()).to.not.throw(Error);
});

it('should render buttons when calling deprecated render()', () => {
const stub = sinon.stub(menu, '__renderButtons');
menu.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
});

it('should warn when calling deprecated render()', () => {
const stub = sinon.stub(console, 'warn');
menu.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
expect(stub.args[0][0]).to.equal(
'WARNING: Since Vaadin 21, render() is deprecated. The items value is immutable. Please replace it with a new value instead of mutating in place.'
);
it('should not throw when changing items before the menu bar is attached', () => {
expect(() => {
const menuBar = document.createElement('vaadin-menu-bar');
menuBar.items = [{ text: 'Item 1' }];
}).to.not.throw(Error);
});

describe('keyboard navigation', () => {
Expand Down Expand Up @@ -341,8 +325,8 @@ describe('overflow button', () => {
expect(overflow.item.children[2]).to.deep.equal(menu.items[4]);
});

it('should show overflow button after calling render() with same items', () => {
menu.render();
it('should show overflow button after assigning the same items', () => {
menu.items = [...menu.items];
expect(overflow.hasAttribute('hidden')).to.be.false;
});

Expand Down
7 changes: 5 additions & 2 deletions packages/menu-bar/test/sub-menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ describe('sub-menu', () => {
});

(isIOS ? it.skip : it)('should switch submenu again on subsequent arrow left', async () => {
menu.items[1] = { text: 'Menu Item 2', children: [{ text: 'Menu Item 2 1' }] };
menu.render();
menu.items = [
...menu.items.slice(0, 1),
{ text: 'Menu Item 2', children: [{ text: 'Menu Item 2 1' }] },
...menu.items.slice(2)
];
buttons = menu._buttons;
await nextRender(menu);
arrowDown(buttons[0]);
Expand Down
7 changes: 0 additions & 7 deletions packages/notification/src/vaadin-notification.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,6 @@ declare class Notification extends ThemePropertyMixin(ElementMixin(HTMLElement))
*/
requestContentUpdate(): void;

/**
* Manually invoke existing renderer.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render(): void;

/**
* Opens the notification.
*/
Expand Down
11 changes: 0 additions & 11 deletions packages/notification/src/vaadin-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,6 @@ class Notification extends ThemePropertyMixin(ElementMixin(PolymerElement)) {
this.renderer(this._card, this);
}

/**
* Manually invoke existing renderer.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render() {
console.warn('WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.');

this.requestContentUpdate();
}

/** @private */
_rendererChanged(renderer, opened, card) {
if (!card) {
Expand Down
21 changes: 0 additions & 21 deletions packages/notification/test/renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,6 @@ describe('renderer', () => {
expect(notification.renderer.calledTwice).to.be.true;
});

it('should request content update when calling deprecated render()', () => {
const stub = sinon.stub(notification, 'requestContentUpdate');
notification.opened = true;
notification.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
});

it('should warn when calling deprecated render()', () => {
const stub = sinon.stub(console, 'warn');
notification.opened = true;
notification.render();
stub.restore();

expect(stub.calledOnce).to.be.true;
expect(stub.args[0][0]).to.equal(
'WARNING: Since Vaadin 21, render() is deprecated. Please use requestContentUpdate() instead.'
);
});

it('should provide root from the previous renderer call', () => {
notification.renderer = (root) => {
const generatedContent = document.createTextNode('rendered');
Expand Down
7 changes: 0 additions & 7 deletions packages/select/src/vaadin-select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,6 @@ declare class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixi
*/
requestContentUpdate(): void;

/**
* Manually invoke existing renderer.
*
* @deprecated Since Vaadin 21, `render()` is deprecated. Please use `requestContentUpdate()` instead.
*/
render(): void;

/**
* Returns true if `value` is valid, and sets the `invalid` flag appropriately.
*
Expand Down
Loading

0 comments on commit ce0521a

Please sign in to comment.