Skip to content

Commit 5b7f023

Browse files
committed
TS: clone grid option
fix #1261 * also fixed karma-typescript to get line number again
1 parent ab27114 commit 5b7f023

File tree

4 files changed

+374
-364
lines changed

4 files changed

+374
-364
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Change log
4343
- fix [1229](https://github.com/gridstack/gridstack.js/issues/1229) `staticGrid` no longer disable oneColumnMode
4444
- fix [1195](https://github.com/gridstack/gridstack.js/issues/1195) options broken with ember hash helper - thanks [@btecu](https://github.com/btecu)
4545
- fix [1250](https://github.com/gridstack/gridstack.js/issues/1250) don't remove item from another grid
46+
- fix [1261](https://github.com/gridstack/gridstack.js/issues/1261) `init()` clones passed options so second doesn't affect first one
4647

4748
## 1.1.1 (2020-03-17)
4849

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"karma-chrome-launcher": "^3.1.0",
7070
"karma-cli": "^2.0.0",
7171
"karma-jasmine": "^3.1.1",
72-
"karma-typescript": "^5.0.1",
72+
"karma-typescript": "4.1.1",
7373
"node-sass": "^4.13.1",
7474
"puppeteer": "^2.1.1",
7575
"serve-static": "^1.14.1",

src/gridstack.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class GridStack {
7272
return null;
7373
}
7474
if (!el.gridstack) {
75-
el.gridstack = new GridStack(el, options);
75+
el.gridstack = new GridStack(el, Utils.clone(options));
7676
}
7777
return el.gridstack
7878
}
@@ -152,14 +152,11 @@ export class GridStack {
152152
obsoleteAttr(this.el, 'data-gs-height', 'data-gs-max-row', 'v0.5.3');
153153
obsoleteAttr(this.el, 'data-gs-current-height', 'data-gs-current-row', 'v1.0.0');
154154

155-
opts.itemClass = opts.itemClass || 'grid-stack-item';
156-
157155
// if row property exists, replace minRow and maxRow instead
158156
if (opts.row) {
159157
opts.minRow = opts.maxRow = opts.row;
160158
delete opts.row;
161159
}
162-
163160
let rowAttr = Utils.toNumber(el.getAttribute('data-gs-row'));
164161

165162
// elements attributes override any passed options (like CSS style) - merge the two together
@@ -180,29 +177,28 @@ export class GridStack {
180177
staticGrid: false,
181178
_class: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0),
182179
animate: Utils.toBool(el.getAttribute('data-gs-animate')) || false,
183-
alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false,
184-
resizable: Utils.defaults(opts.resizable || {}, {
180+
alwaysShowResizeHandle: false,
181+
resizable: {
185182
autoHide: !(opts.alwaysShowResizeHandle || false),
186183
handles: 'se'
187-
}),
188-
draggable: Utils.defaults(opts.draggable || {}, {
189-
handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) ||
190-
'.grid-stack-item-content',
184+
},
185+
draggable: {
186+
handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content',
191187
scroll: false,
192188
appendTo: 'body'
193-
}),
194-
disableDrag: opts.disableDrag || false,
195-
disableResize: opts.disableResize || false,
189+
},
190+
disableDrag: false,
191+
disableResize: false,
196192
rtl: 'auto',
197193
removable: false,
198-
removableOptions: Utils.defaults(opts.removableOptions || {}, {
194+
removableOptions: {
199195
accept: '.' + opts.itemClass
200-
}),
196+
},
201197
removeTimeout: 2000,
202198
verticalMarginUnit: 'px',
203199
cellHeightUnit: 'px',
204-
disableOneColumnMode: opts.disableOneColumnMode || false,
205-
oneColumnModeDomSort: opts.oneColumnModeDomSort
200+
disableOneColumnMode: false,
201+
oneColumnModeDomSort: false
206202
};
207203

208204
this.opts = Utils.defaults(opts, defaults);

0 commit comments

Comments
 (0)