diff --git a/spec/gridstack-spec.ts b/spec/gridstack-spec.ts index ebcb35bc..faf3e4bc 100644 --- a/spec/gridstack-spec.ts +++ b/spec/gridstack-spec.ts @@ -1435,7 +1435,7 @@ describe('gridstack >', function() { float: false, }; var grid = GridStack.init(options); - expect((grid as any)._styles.ownerNode.parentNode.tagName).toBe('DIV'); // any to access private _styles + expect((grid as any)._styles.parentElement.tagName).toBe('DIV'); // any to access private _styles }); it('should add STYLE to HEAD if styleInHead === true >', function() { var options = { @@ -1445,7 +1445,7 @@ describe('gridstack >', function() { styleInHead: true }; var grid = GridStack.init(options); - expect((grid as any)._styles.ownerNode.parentNode.tagName).toBe('HEAD'); // any to access private _styles + expect((grid as any)._styles.parentElement.tagName).toBe('HEAD'); // any to access private _styles }); }); @@ -1458,11 +1458,11 @@ describe('gridstack >', function() { }); it('should add STYLE to parent node as a default >', function() { var grid = GridStack.init(); - expect((grid as any)._styles.ownerNode.parentNode.tagName).toBe('DIV'); + expect((grid as any)._styles.parentElement.tagName).toBe('DIV'); }); it('should add STYLE to HEAD if styleInHead === true >', function() { var grid = GridStack.init({styleInHead: true}); - expect((grid as any)._styles.ownerNode.parentNode.tagName).toBe('HEAD'); + expect((grid as any)._styles.parentElement.tagName).toBe('HEAD'); }); }); diff --git a/src/gridstack.ts b/src/gridstack.ts index a47fb417..c6391469 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -992,10 +992,10 @@ export class GridStack { this.el.parentNode.removeChild(this.el); } this._removeStylesheet(); - if (this.parentGridNode) delete this.parentGridNode.subGrid; + delete this.parentGridNode?.subGrid; delete this.parentGridNode; delete this.opts; - delete this._placeholder.gridstackNode; + delete this._placeholder?.gridstackNode; delete this._placeholder; delete this.engine; delete this.el.gridstack; // remove circular dependency that would prevent a freeing