Merge pull request #1141 from jpetto/bug-902697-mozilla-modal-js-error

Fix bug when focusing outside of modal (Fx only). Bug 902697.
Improve performance & fix .contains bug. Bug 902697.