Bug Tracker

Opened 10 years ago

Closed 9 years ago

#6371 closed bug (wontfix)

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:
Blocked by: Blocking:

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 (2)

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

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by elijahr

Attachment: jquery.noconflict.patch added

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

comment:1 Changed 10 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 10 years ago by elijahr

Better patch.

comment:2 Changed 9 years ago by snover

Milestone: 1.4.3

Resetting milestone to future.

comment:3 Changed 9 years ago by snover

Keywords: needsreview added
Priority: undecided

Bikeshed/feature creep.

comment:4 Changed 9 years ago by timmywil

Keywords: needsreview removed
Milestone: 1.next
Priority: undecidedlow
Resolution: wontfix
Status: newclosed
Version: 1.4.21.5.2

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

Note: See TracTickets for help on using tickets.