Sparnatural icon indicating copy to clipboard operation
Sparnatural copied to clipboard

Analyse the feasibility to remove the dependency to JQuery

Open tfrancart opened this issue 3 years ago • 4 comments

tfrancart avatar Aug 23 '21 20:08 tfrancart

document.getElementsByClassName + Array.prototype.forEach.call(..., function(el) { ... } should give good replacement for most of JQuery usages

tfrancart avatar Aug 30 '21 14:08 tfrancart

FYI @SteinerPascal - a few months ago I had a discussion with folks at https://semapps.org/fr/ that also wanted to integrate Sparnatural in React, but were reluctant to do so because Sparnatural is using JQuery and - as they explained to me - JQuery does not live well with React.

If you have any insights about this or if you have some conclusions on how well Sparnatural can be integrated with React, please don't hesitate to share them here. Thanks.

tfrancart avatar Apr 19 '22 21:04 tfrancart

Hey thanks for the input. I just did a quick research. I can see that it is dangerous to use JQuery and React together. If they both manipulate the same HTMLElements, then they will override each other and leave the application state inconsistent. The only "real" way would be to rewrite the whole thing into react i guess. But I think it will be possible to use it in a React App if you just put the Sparnatural into a "Box" and let it run by itself. You just have to make sure React doesn't rerender Sparnatural. I will definitely test it =)

SteinerPascal avatar Apr 21 '22 20:04 SteinerPascal

@tfrancart : Idée, pour peu à peu remplacer jQuery et ne pas continuer à l'utiliser dans nos développements.

Ici exemple de code portable pour créer à la volée un objet node HTML (très utilisé dans nos scripts):

const placeholder = document.createElement("div");
placeholder.innerHTML = html;
const node = placeholder.firstElementChild;

Pourrions nous commencer par créer des fonctions globales "helpers" facilement accessibles dans les scripts ?

antoine37120 avatar Apr 05 '24 11:04 antoine37120