Side navigation
#1794 closed enhancement (duplicate)
Opened October 11, 2007 06:05AM UTC
Closed September 15, 2009 03:35PM UTC
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: | ||
Blocked by: | Blocking: |
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
windowobject 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
jQueryand
$methods to the
windowobject. This patch changes 4 lines so that instead of augmenting the
windowexplicitly, the library implicitly adds them to the
windowby adding them to
this. In global scope,
thisis the same as
window. However, if someone includes a script with
modules.js,
thisis 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
windowobject.
Attachments (1)
Change History (4)
Changed May 12, 2008 01:28AM UTC by comment:1
Changed May 16, 2008 02:27AM UTC by comment:2
milestone: | 1.2.2 → 1.2.4 |
---|---|
owner: | → flesler |
status: | new → assigned |
Changed April 10, 2009 06:40PM UTC by comment:3
This issue appears to have been addressed by 1.3.2. Thank you!
Changed September 15, 2009 03:35PM UTC by comment:4
resolution: | → duplicate |
---|---|
status: | assigned → closed |
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.