'How to convert a simple jquery plugin to a regular javascript class?

I'm thinking of converting jquery.hoverIntent to a simple ES class. Mainly because it's a pain to use it on a module context. I'm currently loading it as external dependecy for this reason.

I've already found a couple of similar scripts written in es syntax, but they're not exactly the same, the orgininal still being the best, in particular due to event delegation implementation on mouseenter (which is a thing peculiar of jquery, since that event doesn't have bubbling in native ES).

Now, I'm not an expert of jquery's internals, so currently I cannot figure out to transform something that I can call like $(el).hoverIntent(), in something like hoverIntent(el), but keeping same functionalities. What are the main steps?

Could you please point me to the right direction? I promise I'll share the new code once done! :)

Or, another way to ask: could you explain me what the jquery internals are? How do the core of plugins work? So that I'll know what I have to resamble in pure js?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source