Skip to content
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

Merged
merged 7 commits into from
Dec 7, 2021
Merged

Conversation

SmileLifeIven
Copy link
Contributor

Description

Please explain the changes you made here. Include an example of what your changes fix or how to use the changes.

Checklist

  • Created tests which fail without the change (if possible)
  • All tests passing (yarn test)
  • Extended the README / documentation, if necessary

Copy link
Member

@adumesny adumesny left a 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) {
Copy link
Member

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/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule="" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.js"></script>

<script src="../src/gridstack-poly.js"></script>
Copy link
Member

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)

Copy link
Contributor Author

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",
Copy link
Member

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",
Copy link
Member

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"
Copy link
Member

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')
Copy link
Member

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;
Copy link
Member

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 ?

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/
Copy link
Member

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!

use: 'ts-loader',
use: [
{
loader: 'babel-loader',
Copy link
Member

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!

@SmileLifeIven
Copy link
Contributor Author

Sorry for your time, Those are my mistakes.

Copy link
Member

@adumesny adumesny left a 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

// https://developer.mozilla.org/zh-CN/docs/Web/API/CustomEvent/CustomEvent
(function () {
if (window.navigator.userAgent.indexOf('Chrome') > -1 ) {
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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.

})();

//https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
Copy link
Member

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

// suport IE
(function () {
if (!document.scrollingElement) {
Copy link
Member

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("");
Copy link
Member

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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsconfig.json Outdated
@@ -15,7 +15,8 @@
"outDir": "./dist",
"sourceMap": true,
"strict": false,
"target": "ES6"
// "target": "ES6",
"target": "ES5"
Copy link
Member

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

@@ -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'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does that do ?

@adumesny
Copy link
Member

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...
looks good otherwise.

@SmileLifeIven
Copy link
Contributor Author

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... looks good otherwise.

Size:
ES5: gridstack-jq.js -> 202KB gridstack-h5.js -> 81KB gridstack-static.js -> 1KB
ES6: gridstack-jq.js -> 196KB gridstack-h5.js -> 71KB gridstack-static.js -> 40KB

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.

@SmileLifeIven
Copy link
Contributor Author

Or we could add new script to build for es5 and relative config add into new filefolder.

@adumesny
Copy link
Member

adumesny commented Dec 1, 2021

| gridstack-static.js -> 1KB
typo...

| 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

@adumesny
Copy link
Member

adumesny commented Dec 3, 2021

re-opening in case someone else wants to continue this effort...

@adumesny adumesny reopened this Dec 3, 2021
@SmileLifeIven
Copy link
Contributor Author

Done. Add a es5 filefolder.

Copy link
Member

@adumesny adumesny left a 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.

es5/tsconfig.json Outdated Show resolved Hide resolved
es5/webpack.config.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@SmileLifeIven
Copy link
Contributor Author

Check it.

@adumesny adumesny merged commit e7a0ade into gridstack:master Dec 7, 2021
@adumesny
Copy link
Member

adumesny commented Dec 7, 2021

thank you! I will verify it and update the documentation and publish a new version in the next couple days...

@SmileLifeIven
Copy link
Contributor Author

😊

adumesny added a commit to adumesny/gridstack.js that referenced this pull request Dec 10, 2021
* some cleanup and documendation for gridstack#1887 for IE
@adumesny adumesny mentioned this pull request Dec 10, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants