Skip to content

Commit ace8dca

Browse files
committed
more IE support
* some cleanup and documendation for #1887 for IE
1 parent e7a0ade commit ace8dca

File tree

9 files changed

+32
-16
lines changed

9 files changed

+32
-16
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = function(grunt) {
3939
copy: {
4040
dist: {
4141
files: {
42-
'dist/gridstack-poly.js': ['src/gridstack-poly.js'],
42+
'dist/es5/gridstack-poly.js': ['src/gridstack-poly.js'],
4343
'dist/src/gridstack.scss': ['src/gridstack.scss'],
4444
'dist/src/gridstack-extra.scss': ['src/gridstack-extra.scss'],
4545
}

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,28 @@ which means you can possibly bring your own version
9292
},
9393
```
9494

95-
Alternatively in html
95+
Alternatively (single combined file) in html
9696

9797
```html
9898
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
99-
<!-- HTML5 drag&drop (68k) -->
99+
<!-- HTML5 drag&drop (70k) -->
100100
<script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
101-
<!-- OR jquery-ui drag&drop (193k) -->
101+
<!-- OR jquery-ui drag&drop (195k) -->
102102
<script src="node_modules/gridstack/dist/gridstack-jq.js"></script>
103-
<!-- OR static grid (38k) -->
103+
<!-- OR static grid (40k) -->
104104
<script src="node_modules/gridstack/dist/gridstack-static.js"></script>
105105
```
106106

107-
Note: the API is the same, regardless of the plugin (or lack thereof) so you can switch at any time. The Jquery version will export $ that it bundles and currently the only one to support mobile/touch devices through `jquery.ui.touch-punch` (h5 version is planned). Read more at [migrating to v3](#migrating-to-v3)
107+
**Note**: the API is the same, regardless of the plugin (or lack thereof) so you can switch at any time. The Jquery version will export $ that it bundles and currently the only one to support mobile/touch devices through `jquery.ui.touch-punch` (h5 version is planned). Read more at [migrating to v3](#migrating-to-v3)
108+
109+
**Note2**: IE support was dropped in v2, but restored in v4.4 by an external contributor (I have no interest in testing+supporting obsolete browser so this might break in the future).
110+
You can use the es5 files and polyfill (larger) for older browser instead. For example:
111+
```html
112+
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
113+
<script src="node_modules/gridstack/dist/es5/gridstack-poly.js"></script>
114+
<script src="node_modules/gridstack/dist/es5/gridstack-jq.js"></script>
115+
```
116+
108117

109118
## Basic usage
110119

demo/web1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<script type="module" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js"></script>
1414
<script nomodule="" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.js"></script>
1515

16-
<!-- support for ie -->
16+
<!-- support for IE -->
1717
<script src="../dist/es5/gridstack-poly.js"></script>
1818
<script src="../dist/es5/gridstack-jq.js"></script>
1919
</head>

demo/web2.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
<script type="module" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js"></script>
1414
<script nomodule="" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.js"></script>
1515

16-
<script src="../dist/gridstack-jq.js"></script>
16+
<!-- support for IE -->
17+
<script src="../dist/es5/gridstack-poly.js"></script>
18+
<script src="../dist/es5/gridstack-jq.js"></script>
1719

1820
<style type="text/css">
1921
.grid-stack-item-removing {

doc/CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Change log
6363

6464
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
6565

66+
## 4.3.1-dev TBD
67+
* add [#1887](https://github.com/gridstack/gridstack.js/pull/1887) support for IE (new es5 folder) by [@SmileLifeIven](https://github.com/SmileLifeIven)
68+
6669
## 4.3.1 (2021-10-18)
6770
* fix [#1868](https://github.com/gridstack/gridstack.js/issues/1868) prevent swap during resize
6871
* fix [#1849](https://github.com/gridstack/gridstack.js/issues/1849) [#1816](https://github.com/gridstack/gridstack.js/issues/1816) save highest resolution in 1 column mode

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
}
2020
],
2121
"scripts": {
22-
"build": "yarn --no-progress && rm -rf dist/* && grunt && webpack && tsc --stripInternal && webpack --config es5/webpack.config.js && tsc --stripInternal --project es5/tsconfig.json && yarn doc",
22+
"build": "yarn --no-progress && rm -rf dist/* && grunt && yarn build:es6 && yarn build:es5 && yarn doc",
23+
"build:es6": "webpack && tsc --stripInternal",
24+
"build:es5": "webpack --config es5/webpack.config.js && tsc --stripInternal --project es5/tsconfig.json",
2325
"w": "rm -rf dist/* && grunt && webpack",
2426
"t": "rm -rf dist/* && grunt && tsc --stripInternal",
2527
"doc": "doctoc ./README.md && doctoc ./doc/README.md && doctoc ./doc/CHANGES.md",

src/gridstack-poly.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* gridstack-poly.ts 4.3.1-dev - used for older browser support (not currently supported in v2+)
2+
* gridstack-poly.ts 4.3.1-dev used for IE and older browser support (not supported in v2-v4.3.1, but again in v4.4)
33
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
44
*/
55

@@ -221,7 +221,7 @@ if (!Array.prototype['forEach']) {
221221
};
222222
}
223223

224-
// https://developer.mozilla.org/zh-CN/docs/Web/API/CustomEvent/CustomEvent
224+
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
225225
(function(){
226226
try{
227227
new window.CustomEvent('T');
@@ -259,7 +259,7 @@ if (!Array.prototype['forEach']) {
259259
});
260260
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
261261

262-
// https://developer.mozilla.org/zh-CN/docs/Web/API/Element/matches
262+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
263263
if (!Element.prototype.matches) {
264264
Element.prototype.matches =
265265
Element.prototype.matchesSelector ||

src/gridstack.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class GridStack {
163163
// create the grid element, but check if the passed 'parent' already has grid styling and should be used instead
164164
let el = parent;
165165
if (!parent.classList.contains('grid-stack')) {
166-
let doc = document.implementation.createHTMLDocument("");
166+
let doc = document.implementation.createHTMLDocument(''); // IE needs a param
167167
doc.body.innerHTML = `<div class="grid-stack ${opt.class || ''}"></div>`;
168168
el = doc.body.children[0] as HTMLElement;
169169
parent.appendChild(el);
@@ -399,13 +399,13 @@ export class GridStack {
399399

400400
let el: HTMLElement;
401401
if (typeof els === 'string') {
402-
let doc = document.implementation.createHTMLDocument("");
402+
let doc = document.implementation.createHTMLDocument(''); // IE needs a param
403403
doc.body.innerHTML = els;
404404
el = doc.body.children[0] as HTMLElement;
405405
} else if (arguments.length === 0 || arguments.length === 1 && isGridStackWidget(els)) {
406406
let content = els ? (els as GridStackWidget).content || '' : '';
407407
options = els;
408-
let doc = document.implementation.createHTMLDocument("");
408+
let doc = document.implementation.createHTMLDocument(''); // IE needs a param
409409
doc.body.innerHTML = `<div class="grid-stack-item ${this.opts.itemClass || ''}"><div class="grid-stack-item-content">${content}</div></div>`;
410410
el = doc.body.children[0] as HTMLElement;
411411
} else {

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export class Utils {
295295

296296
/** @internal returns the passed element if scrollable, else the closest parent that will, up to the entire document scrolling element */
297297
static getScrollElement(el?: HTMLElement): HTMLElement {
298-
if (!el) return document.scrollingElement as HTMLElement || document.documentElement;
298+
if (!el) return document.scrollingElement as HTMLElement || document.documentElement; // IE support
299299
const style = getComputedStyle(el);
300300
const overflowRegex = /(auto|scroll)/;
301301

0 commit comments

Comments
 (0)