chaplinjs/chaplin — pull request #785 by jeffmicklos (2014-04-11 20:00:10+00:00)
Title: use widely supported `compareDocumentPosition` instead of `contains`

...when attaching views.

`View.prototype.attach` was using the new-ish DOM api, `contains`, which caused Chaplin to completely not work in Firefox 9 and below (to see bug manifest, https://everlane.com in the aforementioned browsers).

I switched that call for the more widely supported `compareDocumentPosition`, which has been written about a number of times (http://ejohn.org/blog/comparing-document-position/, http://www.quirksmode.org/blog/archives/2006/01/contains_for_mo.html) as a superior and more backward compatible way to check containment. Cool!

Yeah, the code is a bit less pretty now (yep, that is a bitwise operator) but I think it is a fair trade off here. I am not opposed to adding a mega comment block explaining what exactly is happening in detail, if need be.