-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: support ie browser #1887
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for making it work, although I had no interest in supporting a long dead and no longer supported browser... ok if it comes free and only IE user need to include polyfill.
babel.config.js
Outdated
@@ -0,0 +1,34 @@ | |||
module.exports = function (api) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't use babel for building this lib (maybe we should ?) so please remove.
demo/web1.html
Outdated
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script> | ||
<script nomodule="" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script> | ||
|
||
<script src="../src/gridstack-poly.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be ../dist as poly should be copies to the build folder as well (or needs to)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
package.json
Outdated
"connect": "^3.7.0", | ||
"core-js": "^3.6.4", | ||
"coveralls": "^3.0.9", | ||
"doctoc": "^1.4.0", | ||
"coveralls": "^2.11.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you use an older one ?
package.json
Outdated
@@ -55,15 +55,20 @@ | |||
}, | |||
"homepage": "http://gridstack.github.io/gridstack.js/", | |||
"devDependencies": { | |||
"@babel/plugin-proposal-class-properties": "^7.16.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove all babel please.
package.json
Outdated
"webpack-cli": "^4.6.0" | ||
}, | ||
"dependencies": { | ||
"yarn": "^1.22.17" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a devDependencies, not dependency (that user need to install)
also yarn.lock should be updated instead... not sure why you had (?) to change the rev of the libs...
src/gridstack.ts
Outdated
@@ -5,7 +5,7 @@ | |||
* Copyright (c) 2021 Alain Dumesny | |||
* see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE | |||
*/ | |||
|
|||
require('@babel/polyfill') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I don't want modern browsers to compile poyfill. Only the few IE users can include our polyfill js file instead...
src/utils.ts
Outdated
@@ -295,7 +295,7 @@ export class Utils { | |||
|
|||
/** @internal returns the passed element if scrollable, else the closest parent that will, up to the entire document scrolling element */ | |||
static getScrollElement(el?: HTMLElement): HTMLElement { | |||
if (!el) return document.scrollingElement as HTMLElement; | |||
if (!el) return document.documentElement as HTMLElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to understand that change as I don't want break other browser for IE, which has been dead for a while really.. so not interested in supporting it unless it's 'free'...
maybe do || if scrollingElement doesn't exist on IE ?
webpack.config.js
Outdated
devtool: 'source-map', | ||
// devtool: 'eval-source-map', // for best (large .js) debugging. see https://survivejs.com/webpack/building/source-maps/ | ||
// devtool: 'source-map', | ||
devtool: 'eval-source-map', // for best (large .js) debugging. see https://survivejs.com/webpack/building/source-maps/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't check that in!
webpack.config.js
Outdated
use: 'ts-loader', | ||
use: [ | ||
{ | ||
loader: 'babel-loader', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no babel please, already have webpack and ts compiler... don't think we need that many packages!
Sorry for your time, Those are my mistakes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, looks much better. couple comments
src/gridstack-poly.js
Outdated
// https://developer.mozilla.org/zh-CN/docs/Web/API/CustomEvent/CustomEvent | ||
(function () { | ||
if (window.navigator.userAgent.indexOf('Chrome') > -1 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you actually get that from core-js polyfill ? checking for specific browser type seems bridle to me...
@@ -146,6 +146,23 @@ if (!Array.prototype.findIndex) { | |||
}); | |||
})([Element.prototype, Document.prototype, DocumentFragment.prototype]); | |||
|
|||
// from: https://github.com/jserz/js_piece/blob/master/DOM/Element/prepend()/prepend().md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't access that URL... looks like a private repo. isn't there a developer.mozilla.org version instead ?
} | ||
|
||
// https://developer.mozilla.org/zh-CN/docs/Web/API/CustomEvent/CustomEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small request, can you use en-US in urls instead ? more people read english doc. thank you.
src/gridstack-poly.js
Outdated
})(); | ||
|
||
//https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, can't access URL
src/gridstack-poly.js
Outdated
// suport IE | ||
(function () { | ||
if (!document.scrollingElement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting way to support field name change... is there a problem caching this though ? I'm ok with caller doing
document.scrollingElement || document.documentElement
instead.
@@ -164,7 +163,7 @@ export class GridStack { | |||
// create the grid element, but check if the passed 'parent' already has grid styling and should be used instead | |||
let el = parent; | |||
if (!parent.classList.contains('grid-stack')) { | |||
let doc = document.implementation.createHTMLDocument(); | |||
let doc = document.implementation.createHTMLDocument(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use '' (2 single quote) instead, also you didn't answer me if IE require a param to be passed (if so add comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument
title Optional (except in IE)
I see that now....
tsconfig.json
Outdated
@@ -15,7 +15,8 @@ | |||
"outDir": "./dist", | |||
"sourceMap": true, | |||
"strict": false, | |||
"target": "ES6" | |||
// "target": "ES6", | |||
"target": "ES5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the size difference between ES5 and 6 (which I believe was smaller) ? is that required for IE. need to trade off all browser vs obsolete IE
webpack.config.js
Outdated
@@ -9,6 +9,7 @@ module.exports = { | |||
mode: 'production', // production vs development | |||
devtool: 'source-map', | |||
// devtool: 'eval-source-map', // for best (large .js) debugging. see https://survivejs.com/webpack/building/source-maps/ | |||
target: ['web', 'es5'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does that do ?
…l for CustomEvent.
you still have not answer my question on the size difference between ES5 and ES6 I had, and what the web target is for... and please add URL to polyfill code you add so we know where it is coming from... |
Size: Web target is for some old system with original browser, they want to use new feature with they system, and there is only IE browser when some customer install system, we shoule support the feature instead of updating customer's browser. And the polyfill code source url I will add it. |
Or we could add new script to build for es5 and relative config add into new filefolder. |
| gridstack-static.js -> 1KB | Or we could add new script to build for es5 and relative config add into new filefolder. Yes, I think that would be better, because 10k for gridstack-h5.js @ 71KB is a big difference and very few if any need IE support, so I don't want to do that. create an es5 sub-folder for it |
re-opening in case someone else wants to continue this effort... |
Done. Add a es5 filefolder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there! thank you.
Check it. |
thank you! I will verify it and update the documentation and publish a new version in the next couple days... |
😊 |
* some cleanup and documendation for gridstack#1887 for IE
Description
Please explain the changes you made here. Include an example of what your changes fix or how to use the changes.
Checklist
yarn test
)