W3C home > Mailing lists > Public > public-nextweb@w3.org > July 2013

Re: Prollyfills and the global namespace / multi-fills

From: Marcos Caceres <w3c@marcosc.com>
Date: Wed, 3 Jul 2013 19:07:04 +0100
To: François REMY <francois.remy.dev@outlook.com>
Cc: Brian Kardell <bkardell@gmail.com>, public-nextweb@w3.org
Message-ID: <55C8F9561C7B43A28A243A9E56C5E32D@marcosc.com>

On Wednesday, July 3, 2013 at 6:58 PM, François REMY wrote:

> > What does "module" mean here? AMD? NPM? CommonJS?
> An object that is self-contained. That includes any kind of module, even  
> just:
> window.myProllyfill = {
> Abc: function() {
> ...
> },
> Def: function() {
> ...
> }
> }

Oh, then no. That's not the way to do it. It depends on the definition of the interface.  

IMO, the right (™) way to do it is like Promises are done here (wrap in anonymous function):


And if you want to go a little more extreme (i.e., closer to what you need to do to make a WebIDL conforming implementation) you need to create both an "interface object" and an "interface prototype object".  

See for example:
> > - when you use some global namespace, use a prefix (no code should use  
> > your
> > function by mistaking it for a native implementation)
> Redefining an existing prollyfill that (you think) sucks by another one is  
> the best way to have problems because some code most probably rely on the  
> "sucking" implementation. That's why you simply do not want prollyfill to  
> clash with anything hence special names and prefixes.

Depends on who you are building it for. If you are building it for a standards org, then you want it to be as close to the metal as it can be (See Promises prollyfill… I rely on that in my projects, and would be quite annoyed if Alex suddenly prefixed it).    
> You don't have to prefix everything, just enough to make sure people can use  
> the polyfill and still be sure no code that never "met" the prollyfill will  
> use it by mistake.  

From my own experience, this sounds good on paper, but it doesn't work in practice. It requires too much decline for too little return.   
Received on Wednesday, 3 July 2013 18:07:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:05:54 UTC