Skip to content

Commit

Permalink
fix sticky-polyfill causing crash on destroy (#1118)
Browse files Browse the repository at this point in the history
* fix: add optional chaining to prevent a crash

* test: write test for destroy behaviour
  • Loading branch information
lukasnys authored Aug 1, 2024
1 parent 393d36f commit f2953a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/-private/sticky/table-sticky-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,6 @@ export function setupTableStickyPolyfill(element) {
}

export function teardownTableStickyPolyfill(element) {
TABLE_POLYFILL_MAP.get(element).destroy();
TABLE_POLYFILL_MAP.get(element)?.destroy();
TABLE_POLYFILL_MAP.delete(element);
}
27 changes: 27 additions & 0 deletions tests/integration/components/basic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,32 @@ module('Integration | basic', function() {
document.querySelector('#ember-testing-container').style.height = '600px';
this.set('showComponent', false);
});

test('Destroying table with footerRows after initial render does not trigger error', async function(assert) {
assert.expect(0);

this.set('columns', generateColumns(4));
this.set('rows', generateRows(10));

this.set('showComponent', true);

await render(hbs`
{{#if this.showComponent}}
<div id="container" style="height: 500px;">
<EmberTable as |t|>
<EmberThead @api={{t}} @columns={{this.columns}} />
<EmberTbody @api={{t}} @rows={{this.rows}} @estimateHeigh={{13}} />
{{#if this.footerRows}}
<EmberTfoot @api={{t}} @rows={{this.footerRows}} />
{{/if}}
</EmberTable>
</div>
{{/if}}
`);

this.set('footerRows', generateRows(1));

this.set('showComponent', false);
});
});
});

0 comments on commit f2953a2

Please sign in to comment.