jsface icon indicating copy to clipboard operation
jsface copied to clipboard

noConflict does not solve all conflicts

Open mcasimir opened this issue 9 years ago • 3 comments

Hi buddy, this is not enough:

    oldClass          = context.Class;                                         // save current Class namespace
    context.Class     = Class;                                                 // bind Class and jsface to global scope
    context.jsface    = jsface;
    jsface.noConflict = function() { context.Class = oldClass; };              // no conflict

noConflict "pattern" should allow to preserve global context from pollution completely, you'll need to backup and return jsface too:

    oldClass          = context.Class;                                       // save current Class namespace
    context.Class     = Class;                                                 // bind Class and jsface to global scope
    var oldJsface     = context.jsface;
    context.jsface    = jsface;
    jsface.noConflict = function() { 
       context.Class = oldClass;
       context.jsface = oldJsface;  
       return jsface; 
    };              // no conflict

Now people can use noConflict like this:

var Class = jsface.noConflict().Class;

If you review this comment I can make a PR for you.

mcasimir avatar Aug 21 '15 17:08 mcasimir

Actually was too easy to submit a PR: #34

mcasimir avatar Aug 21 '15 17:08 mcasimir

Is this project dead?

n9986 avatar Mar 30 '16 09:03 n9986

@mcasimir, I think it's overdone to save and restore jsface. Given development of tooling like webpack and browsersify, commonjs is now supported when you develop javascript for front-end, noConflict becomes less and less useful.

tnhu avatar Apr 08 '16 05:04 tnhu