Skip to content

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

Description

@jeffrose

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;
}
...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions