Message from discussion
jQuery alias (ticket #1032)
Received: by 10.204.31.100 with SMTP id x36mr176170bkc.9.1240313221796;
Tue, 21 Apr 2009 04:27:01 -0700 (PDT)
Return-Path: <F...@gmx.net>
Received: from mail.gmx.net (mail.gmx.net [213.165.64.20])
by gmr-mx.google.com with SMTP id 13si658772bwz.7.2009.04.21.04.27.01;
Tue, 21 Apr 2009 04:27:01 -0700 (PDT)
Received-SPF: pass (google.com: domain of F...@gmx.net designates 213.165.64.20 as permitted sender) client-ip=213.165.64.20;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of F...@gmx.net designates 213.165.64.20 as permitted sender) smtp.mail=F...@gmx.net
Received: (qmail invoked by alias); 21 Apr 2009 11:27:00 -0000
Received: from p57B3DE66.dip.t-dialin.net (EHLO [192.168.178.21]) [87.179.222.102]
by mail.gmx.net (mp058) with SMTP; 21 Apr 2009 13:27:00 +0200
X-Authenticated: #12865021
X-Provags-ID: V01U2FsdGVkX1/wBJlSM8bwMBPoWLq4uopJCyg2MhGNO+MMS95+8T
0h+1+1AYHjRk/b
Message-ID: <49EDAD83.9010608@gmx.net>
Date: Tue, 21 Apr 2009 12:26:59 +0100
From: FND <F...@gmx.net>
User-Agent: Thunderbird 2.0.0.21 (X11/20090318)
MIME-Version: 1.0
To: TiddlyWikiDev@googlegroups.com
Subject: Re: [twdev] Re: jQuery alias (ticket #1032)
References: <49EC98C2.8080601@gmx.net> <e5232b2c-d6bf-478d-b417-e5794ea15ddc@s38g2000prg.googlegroups.com> <49ED8C80.7030006@gmx.net> <6622f01b-65f9-40d7-8ad0-226c6a689611@q33g2000pra.googlegroups.com>
In-Reply-To: <6622f01b-65f9-40d7-8ad0-226c6a689611@q33g2000pra.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Y-GMX-Trusted: 0
X-FuHaFi: 0.67
> not just 'eval'... custom macro handlers, toolbar handlers, hijacks,
> etc... can also get invoked within the scope of a locally-declared $
> (...) alias
I don't believe this is correct - please take a look at this test case:
http://fnd.lewcid.org/tmp/alias_scope.html
It boils down to the following:
---------------
var $ = "lorem ipsum";
var foo;
(function($) {
foo = function() {
console.log(typeof $); // prints "function", referencing jQuery
};
// hijack
foo_orig = foo;
foo = function() {
foo_orig.apply(this, arguments);
console.log(typeof $); // prints "string", referencing custom $
};
foo(); // prints both "function" and "string"
---------------
Am I missing something?
-- F.