Bug Tracker

Modify

Ticket #1794 (closed enhancement: duplicate)

Opened 6 years ago

Last modified 4 years ago

ER: Generalize for Alternate "Global" Context Object

Reported by: kris.kowal Owned by: flesler
Priority: trivial Milestone: 1.2.4
Component: core Version: 1.2.1
Keywords: Cc:
Blocking: Blocked by:

Description

I've been working on an XHR module loader and have been looking into integrating jQuery. I'm hoping to be able to use jQuery without modification. However, since jQuery explicitly augments the window object instead of implicitly through the global context object, a small change would be necessary to make this possible.

I've attached a patch which should have no impact on the functionality of the library core as it stands, but would permit jQuery to be used as a "Chiron" module with no modification hereafter.

In its current form, jQuery adds the jQuery and $ methods to the window object. This patch changes 4 lines so that instead of augmenting the window explicitly, the library implicitly adds them to the window by adding them to this. In global scope, this is the same as window. However, if someone includes a script with modules.js, this is the module object. I've taken care to assure that the enclosure gets the global context object in outro.js.

This change should have no impact on current deployments. I did a spot check on the patched version of jquery.js and it appears to work fine for trivial cases in as both a global script and a module script. The only difference is that, as a module, the script has no impact on the window object.

Attachments

patch Download (1.1 KB) - added by kris.kowal 6 years ago.
A recommended patch.

Change History

Changed 6 years ago by kris.kowal

A recommended patch.

comment:1 Changed 5 years ago by flesler

I like it, but it fails inside $.noConflict, as the this will be jQuery. Also the call(this) seems unnecessary.

The global scope could be saved in a variable.

comment:2 Changed 5 years ago by flesler

  • Owner set to flesler
  • Status changed from new to assigned
  • Milestone changed from 1.2.2 to 1.2.4

comment:3 Changed 4 years ago by kris.kowal

This issue appears to have been addressed by 1.3.2. Thank you!

comment:4 Changed 4 years ago by flesler

  • Status changed from assigned to closed
  • Resolution set to duplicate

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.