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

Drop jQuery #59

Merged
merged 22 commits into from
Sep 19, 2018
Merged

Drop jQuery #59

merged 22 commits into from
Sep 19, 2018

Conversation

backflip
Copy link
Collaborator

@backflip backflip commented Sep 16, 2018

Notes:

  • This PR points to [Chore] estatico-boilerplate: Optimized global client-side namespace #61 since I was lazy 😱
  • In my defense: It was created while sitting at a catalonian beach. 🏖
  • I tried to change as few lines as possible and went for dom-delegate to replace the previous event system (after checking out about every DOM event abstraction I could find). The main difference is probably that there is no .add.some.namespaces thingie no more. So instead of unbinding events via namespaces we rather keep track of all listeners belonging to a module. The events and mediaqueries helpers don‘t use the delegate library in a very smart way, but I guess this code will be replaced soon anyway.
  • Some polyfills for older browsers were added (small ones loaded by default, larger ones like fetch on demand)
  • The failing QUnit are replaced with a separate PR: Replace QUnit with Jest #62
  • After this, we’ll have a good base to refactor the whole approach (using more reasonable init triggers like Mutation|IntersectionObserver, lazy-load complete modules etc.). @christiansany has some great ideas.

Thoughts?

@backflip backflip changed the base branch from develop to feature/namespace September 16, 2018 17:17
Copy link

@christiansany christiansany left a comment

Choose a reason for hiding this comment

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

Look cool :)
Generally, I'd also focus on new implementations of MediaQuery and WindowEventResizer (https://www.npmjs.com/package/@unic/factory-breakpoint-manager) (windowEventResizer not yet implemented)

@@ -75,25 +75,24 @@ class App {
return window[namespace].modules[moduleName];
}

isInitialised($element, moduleName) {
isInitialised(element, moduleName) {
// jQuery 3 does not allow kebab-case in data() when retrieving whole data object https://jquery.com/upgrade-guide/3.0/#breaking-change-data-names-containing-dashes

Choose a reason for hiding this comment

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

This line is unnecessary when removing jQuery :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very good point, removed

packages/estatico-boilerplate/src/assets/js/helpers/app.js Outdated Show resolved Hide resolved
packages/estatico-boilerplate/src/assets/js/helpers/app.js Outdated Show resolved Hide resolved
@backflip
Copy link
Collaborator Author

Generally, I'd also focus on new implementations of MediaQuery and WindowEventResizer (https://www.npmjs.com/package/@unic/factory-breakpoint-manager) (windowEventResizer not yet implemented)

@christiansany, absolutely, but as stated above, I wanted to keep the changes as minimal as possible so we can discuss new architectural approaches separately of dropping jQuery.

@backflip
Copy link
Collaborator Author

@christiansany, I have added two basic polyfills: NodeList.forEach and CustomEvent. Additionally, a fetch polyfill is loaded asynchronously if needed.

@backflip backflip changed the title [WIP] Drop jQuery Drop jQuery Sep 18, 2018
@backflip backflip changed the base branch from feature/namespace to develop September 19, 2018 11:34
@backflip backflip dismissed christiansany’s stale review September 19, 2018 13:34

Very valid point, but let's tackle this separately

@backflip backflip merged commit 6ac97b9 into develop Sep 19, 2018
"dom-delegate": "^2.2.0",
"highlight.js": "^9.12.0",
"jquery": "^3.3.1",
"lodash": "^4.17.10",
"merge-stream": "^1.0.1",
"nodelist-foreach-polyfill": "^1.2.0",
Copy link

Choose a reason for hiding this comment

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

You can think about using https://github.com/WebReflection/dom4. It includes these polyfills and some more. We normally load this in a separate entry file either in a sync way using document.write or in a ordered way async.

@@ -174,10 +174,13 @@ class SlideShow extends EstaticoModule {
MediaQuery.addMQChangeListener(this.resize.bind(this), this.uuid);
}

fetchSlides() {
async fetchSlides() {
Copy link

Choose a reason for hiding this comment

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

Why not write a module so developers don't have to this evrytime something like this:

export default async function estaticoFetch(){
    if(!window.fetch){
        await import('whatwg-fetch');
    }
    return window.fetch(...arguments);
}

Copy link
Member

Choose a reason for hiding this comment

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

We needed this merged, so would you be keen on opening another PR with this feature?

@robinloeffel robinloeffel deleted the feature/drop-jquery branch January 20, 2021 13:21
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.

4 participants