Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #10038
Closed
Open
Issue created Aug 22, 2013 by Administrator@rootContributor

Bootstrap JS incompatible with noConflict(true) jQuery

Created by: daguej

Because Bootstrap's JS wrapper anonymous function references jQuery globally...

+function ($) { "use strict";
    ...
}(window.jQuery);

... (the window.jQuery part), an error gets thrown if you use $.noConflict(true) and hang on to the reference internally.

I'm running into this with a module loading system (much like node's) which keeps the application's jQuery reference internal. (My application cannot leak anything into global scope, and must be able to cope with different jQuery versions that might be loaded by a host page.)

Bootstrap's JS files are loaded as modules and wrapped by the module system, so they end up looking like this:

function(window, jQuery, $, undefined) {
    +function($) { "use strict";
        ...
    }(window.jQuery);
}

The outer function is invoked by the module loader with the internal jQuery passed in.

However, the Bootstrap code only sees $ as undefined since window.jQuery does not exist.

This can be resolved by Bootstrap's wrapper simply referencing jQuery (dropping the window.). I can't think of a downside of doing this (it won't break anything), and adds flexibility for situations like mine.

Assignee
Assign to
Time tracking