Bug Tracker

Modify

Ticket #6371 (closed bug: wontfix)

Opened 3 years ago

Last modified 2 years ago

jQuery.noConflict() changes the value of $ even if $ !== jQuery

Reported by: elijahr Owned by:
Priority: low Milestone: 1.next
Component: core Version: 1.5.2
Keywords: noConflict Cc:
Blocking: Blocked by:

Description

Suppose I have the following:

<script src="jquery.js"></script> <script src="mootools.js"></script> <script> alert($) alerts mootools' $ function jQuery.noConflict() alert($) alerts 'undefined' </script>

This seems like a bug; it in fact introduces a conflict and breaks mootools. If $!==jQuery, calling jQuery.noConflict() should return without changing the value of $.

I have attached a patch.

Attachments

jquery.noconflict.patch Download (227 bytes) - added by elijahr 3 years ago.
Patch to prevent jQuery.noConflict() from reverting $ if $ is not jQuery
jquery-1.4.2-noconflict-fix.patch Download (437 bytes) - added by elijahr 3 years ago.
Better patch.

Change History

Changed 3 years ago by elijahr

Patch to prevent jQuery.noConflict() from reverting $ if $ is not jQuery

comment:1 Changed 3 years ago by elijahr

Since my line breaks were stripped, here goes again: <script src="jquery.js"></script> <script src="mootools.js"></script> <script> alert($); /* alerts mootools' $ function */ jQuery.noConflict(); alert($); /* alerts 'undefined' */</script>

Changed 3 years ago by elijahr

Better patch.

comment:2 Changed 3 years ago by snover

  • Milestone 1.4.3 deleted

Resetting milestone to future.

comment:3 Changed 3 years ago by snover

  • Keywords needsreview added
  • Priority set to undecided

Bikeshed/feature creep.

comment:4 Changed 2 years ago by timmywil

  • Status changed from new to closed
  • Priority changed from undecided to low
  • Version changed from 1.4.2 to 1.5.2
  • Milestone set to 1.next
  • Keywords needsreview removed
  • Resolution set to wontfix

Agree with snover. noConflict should be called before loading mootools. Setting the $ to undefined might actually be preferable in other use cases.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.