Leaflet/Leaflet — pull request #1430 by jfirebaugh (2013-02-19 23:38:30+00:00)
Title: Allow classes to be constructed without `new`

This uses the "instanceof trick" from John Resig to ensure that
`new Foo(…)` and `Foo(…)` both return a newly constructed instance.

This eliminates the need for separate camel-case functions that wrap the
constructor (e.g. `L.map`). The subtleties of that approach are a source
of confusion and frustration for new users.

I suggest that the documentation be changed to exclusively reference a
`new L.Map()`/`L.Map()` style. Obviously we'll have to keep the camel-case
variants around for backward compatibility at least until a major version
release.

This is not quite ready to merge: several specs are failing. The issue
is that there's no way to make e.g. `new L.LatLng(undefined)` behave like
`L.latLng(undefined)` (returning undefined). Is this an important behavior?
For example, what's the rationale for 84d537b8046fd6ee397d20d8f5154d9812b63502?