Skip to content

Commit 524331e

Browse files
committed
Merge branch 'master' of https://github.com/6pac/SlickGrid
2 parents 8749bfe + 918efa4 commit 524331e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/models/gridOption.interface.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ export interface GridOption<C extends BaseColumn = BaseColumn> {
108108
/** Default cell Formatter that will be used by the grid */
109109
defaultFormatter?: Formatter;
110110

111+
/** Escape hatch geared towards testing Slickgrid in jsdom based environments to circumvent the lack of stylesheet.ownerNode and clientWidth calculations */
112+
devMode?: false & { ownerNodeIndex?: number; containerClientWidth?: number; };
113+
111114
/** Do we have paging enabled? */
112115
doPaging?: boolean;
113116

src/slick.grid.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2467,6 +2467,11 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
24672467
let i: number;
24682468
if (!this.stylesheet) {
24692469
const sheets: any = (this._options.shadowRoot || document).styleSheets;
2470+
2471+
if (typeof this.options.devMode?.ownerNodeIndex === "number" && this.options.devMode.ownerNodeIndex >= 0) {
2472+
sheets[this.options.devMode.ownerNodeIndex].ownerNode = this._style;
2473+
}
2474+
24702475
for (i = 0; i < sheets.length; i++) {
24712476
if ((sheets[i].ownerNode || sheets[i].owningElement) === this._style) {
24722477
this.stylesheet = sheets[i];
@@ -4285,7 +4290,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
42854290
}
42864291

42874292
getViewportWidth() {
4288-
this.viewportW = parseFloat(Utils.innerSize(this._container, 'width') as unknown as string);
4293+
this.viewportW = parseFloat(Utils.innerSize(this._container, 'width') as unknown as string) || this.options.devMode?.containerClientWidth || 0;
42894294
return this.viewportW;
42904295
}
42914296

0 commit comments

Comments
 (0)