Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

jQueryMX breaks when jQuery is in not in global scope #140

Open
jeffrose opened this issue Sep 13, 2012 · 1 comment
Open

jQueryMX breaks when jQuery is in not in global scope #140

jeffrose opened this issue Sep 13, 2012 · 1 comment

Comments

@jeffrose
Copy link

While this sounds similar to #134, the cause is different.

jQueryMX has access to jQuery but jQuery has been removed from global scope using jQuery.noConflict( true );

The result is whenever $.String.getObject() is called for a jQueryMX object, like $.Class, it starts at window, tries to walk to $, and fails.

This could be solved 1 of 2 ways:

  1. Add logic to getObject() to use the $ it has instead of searching window.

string.js:

...
// make sure roots is an array
roots = $.isArray(roots) ? roots : [roots || window];

if( /\$|jQuery/.test( parts[ 0 ] ) ){
    parts.shift();
    roots = [ $ ];
    length = parts.length;
}

if(length == 0){
    return roots[0];
}
...
  1. Change the usage of getObject() in jQueryMX to start at jQuery instead of window where appropriate.

class.js:

...
// do namespace stuff
if ( fullName ) {

    var parts = fullName.split(/\./),
        shortName = parts.pop(),
        root =  /\$|jQuery/.test( parts[ 0 ] ) ?
            parts.shift() && $ :
            window,
        current = getObject(parts.join('.'), root, true),
        namespace = current;


    current[shortName] = Class;
}
...
@justinbmeyer
Copy link
Member

For CanJS, we are thinking of adding module ids to the lookup path. So, you could write it like:

$.String.getObject("jquery")

We might be able to add aliases so "$" works.

For 3.3, you'll probably want:

$.String.getObject("can")

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants