Bug Tracker

Modify

Ticket #7426 (closed bug: duplicate)

Opened 3 years ago

Last modified 14 months ago

Conflict with Prototype.js caused by early exposure of global variables

Reported by: arrix Owned by:
Priority: undecided Milestone: 1.5
Component: selector Version: 1.4.3
Keywords: Cc:
Blocking: Blocked by:

Description

Open  http://prototypejs.org/ in google chrome, copy and paste content from  http://code.jquery.com/jquery-1.4.3.js to the javascript console and run it. An error is thrown: Error: NOT_SUPPORTED_ERR: DOM Exception 9

The error is thrown by a call to div.getElementsByClassName("e") in sizzle.js. HTMLElement.prototype.getElementsByClassName is overwritten by prototype.js and it uses $ which is overwritten by jQuery. The result is that jQuery can't finish initializing and prototype is also left broken.

window.$ and window.jQuery is exposed at the end of core.js before the feature detection code in sizzle.js.

// Expose jQuery to the global object
return (window.jQuery = window.$ = jQuery);

If I move the exposure code to the end of outro.js and call jQuery.noConflict(true) right after the jQuery code, then both prototype and jQuery will be fine.

I know why the exposure is advanced to core.js but maybe there is a better way to avoid the conflict. e.g. Put sizzle.js code to the beginning because it doesn't rely on jQuery anyway.

The discussion about this issue in the dev forum:  https://forum.jquery.com/topic/jquery-conflicts-with-prototype-and-the-fix

Change History

comment:1 Changed 3 years ago by rwaldron

  • Status changed from new to closed
  • Resolution set to duplicate
  • Component changed from unfiled to selector

comment:2 Changed 3 years ago by rwaldron

Duplicate of #4365.

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.