sagemath / sagecell

The Sage Cell Server---providing a way to embed Sage computations into any web page.
Other
201 stars 70 forks source link

embedded_sagecell.js overwrites an existing copy of jQuery in the page #521

Closed christianp closed 4 years ago

christianp commented 4 years ago

The file embedded_sagecell.js seems to load a copy of jQuery which resets window.jQuery and window.$, regardless of whether they're already defined. This caused me some problems because I've already loaded some jQuery extensions before sage cell loads.

Ideally, sage cell should keep its copy of jQuery in local scope. If that's not possible, it should at least check if jQuery is already defined, and not load the new copy if it is.

novoselt commented 4 years ago

jQuery is loaded via require.js, so theoretically it should not interfere with your own copy. Glancing at the code I can't see why it escapes to global namespace, unless that's just how jQuery behaves.

christianp commented 4 years ago

The require.js docs say that jQuery always sets the globals.

The jQuery docs say you should call $.noConflict( true ).

If I can get sagecell to build, I'll submit a pull request that does this.

novoselt commented 4 years ago

Shouldn't happen anymore after 0b4ed5f014ee15c7624e47f8c82f515cd3733b96

christianp commented 4 years ago

Thanks! Sorry I didn't get round to doing this properly myself.

novoselt commented 4 years ago

Has it actually fixed or at least improved your problem?

christianp commented 4 years ago

I'm on paternity leave so won't be in a position to check for a while, but from the commit I think it would.

novoselt commented 4 years ago

That is awesome, enjoy this time, it does not last long ;-)