diff --git a/README.md b/README.md index 928ba2e24..7bc000569 100644 --- a/README.md +++ b/README.md @@ -382,6 +382,8 @@ v2.x is a Typescript rewrite of 1.x, removing all jquery events, using classes a 3. `oneColumnMode` would trigger when `window.width` < 768px by default. We now check for grid width instead (more correct and supports nesting). You might need to adjust grid `minWidth` or `disableOneColumnMode`. +**Note:** 2.x no longer support legacy IE11 and older due to using more compact ES6 output and typecsript native code. You will need to stay at 1.x + Changes ===== diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 041b75bee..f8feec768 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -63,6 +63,7 @@ You can now have perfect square cells (default) [723](https://github.com/gridsta - fix [1299](https://github.com/gridstack/gridstack.js/pull/1299) many columns round-off error - fix [1102](https://github.com/gridstack/gridstack.js/issues/1102) loose functionality when they are moved to a new grid - add optional params to `removeWidget()` to have quiet mode (no callbacks) +- drop support for IE11 due to more compact ES6 output and newer TS code ## 1.2.1 (2020-09-04) diff --git a/src/gridstack-poly.js b/src/gridstack-poly.js index bce8a772b..dafcaae2e 100644 --- a/src/gridstack-poly.js +++ b/src/gridstack-poly.js @@ -122,4 +122,87 @@ if (!Array.prototype.findIndex) { configurable: true, writable: true }); +} + +// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md +(function (arr) { + arr.forEach(function (item) { + if (item.hasOwnProperty('append')) { + return; + } + Object.defineProperty(item, 'append', { + configurable: true, + enumerable: true, + writable: true, + value: function append() { + var argArr = Array.prototype.slice.call(arguments), + docFrag = document.createDocumentFragment(); + + argArr.forEach(function (argItem) { + var isNode = argItem instanceof Node; + docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); + }); + + this.appendChild(docFrag); + } + }); + }); +})([Element.prototype, Document.prototype, DocumentFragment.prototype]); + +// Production steps of ECMA-262, Edition 5, 15.4.4.18 +// Reference: http://es5.github.io/#x15.4.4.18 + +if (!Array.prototype['forEach']) { + + Array.prototype.forEach = function(callback, thisArg) { + + if (this == null) { throw new TypeError('Array.prototype.forEach called on null or undefined'); } + + var T, k; + // 1. Let O be the result of calling toObject() passing the + // |this| value as the argument. + var O = Object(this); + + // 2. Let lenValue be the result of calling the Get() internal + // method of O with the argument "length". + // 3. Let len be toUint32(lenValue). + var len = O.length >>> 0; + + // 4. If isCallable(callback) is false, throw a TypeError exception. + // See: http://es5.github.com/#x9.11 + if (typeof callback !== "function") { throw new TypeError(callback + ' is not a function'); } + + // 5. If thisArg was supplied, let T be thisArg; else let + // T be undefined. + if (arguments.length > 1) { T = thisArg; } + + // 6. Let k be 0 + k = 0; + + // 7. Repeat, while k < len + while (k < len) { + + var kValue; + + // a. Let Pk be ToString(k). + // This is implicit for LHS operands of the in operator + // b. Let kPresent be the result of calling the HasProperty + // internal method of O with argument Pk. + // This step can be combined with c + // c. If kPresent is true, then + if (k in O) { + + // i. Let kValue be the result of calling the Get internal + // method of O with argument Pk. + kValue = O[k]; + + // ii. Call the Call internal method of callback with T as + // the this value and argument list containing kValue, k, and O. + callback.call(T, kValue, k, O); + } + // d. Increase k by 1. + k++; + } + // 8. return undefined + }; } \ No newline at end of file diff --git a/src/gridstack.ts b/src/gridstack.ts index af196f96d..2e83b996a 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -5,8 +5,6 @@ * (c) 2014-2020 Alain Dumesny, Dylan Weiss, Pavel Reznikov * gridstack.js may be freely distributed under the MIT license. */ -import './gridstack-poly.js'; - import { GridStackEngine } from './gridstack-engine'; import { obsoleteOpts, obsoleteOptsDel, obsoleteAttr, obsolete, Utils } from './utils'; import { GridItemHTMLElement, GridStackWidget, GridStackNode, GridStackOptions, numberOrString } from './types';