W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2012

Re: [whatwg] <script> features

From: Ian Hickson <ian@hixie.ch>
Date: Thu, 29 Nov 2012 01:09:36 +0000 (UTC)
To: Jonas Sicking <jonas@sicking.cc>, Aryeh Gregor <ayg@aryeh.name>
Message-ID: <Pine.LNX.4.64.1211290109050.1991@ps20323.dreamhostps.com>
Cc: WHAT Working Group <whatwg@whatwg.org>
On Sun, 25 Mar 2012, Jonas Sicking wrote:
> On Fri, Mar 23, 2012 at 9:41 PM, Ian Hickson <ian@hixie.ch> wrote:
> > On Fri, 23 Mar 2012, Jonas Sicking wrote:
> >>
> >> The whole point of this feature is to enable the js-code inside a 
> >> loaded script to use the .currentScript property in order to find the 
> >> <script> element in the DOM which loaded it.
> >
> > Ah, ok. What's the use case for that?
> 
> One use case is to be able to pass parameters to a script library by 
> sticking the information in the markup. data-* attributes would work 
> great for this. I seem to recall jQuery doing something like this, but 
> can't find information about that right now.
> 
> In the case of ReSpec it uses it to get its own url and then use that as 
> a base url to load dependent scripts as needed.

On Sun, 25 Mar 2012, Aryeh Gregor wrote:
> 
> testharness.js also does that, I think -- it loads a CSS file from the 
> same directory as itself.  IIRC, it does so by looking for the first 
> <script> whose src ends in "testharness.js".  It would be more reliable 
> if it could record the actual URL it's being loaded from.
> 
> (For this use-case it would be enough for the script to get its own URL.  
> In fact, this might be slightly more reliable, because there's nothing 
> to stop an earlier part of the script from inadvertently changing the 
> <script> element's src.  That wouldn't satisfy the first use-case Jonas 
> mentioned, though.)

Cool, thanks for the info.

I've added the feature to the spec.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Thursday, 29 November 2012 01:10:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:11 GMT