Fixing Jasmine “encountered a declaration exception”

If you ever come upon a Jasmine unit test that ends with “encountered a declaration exception”, it’s likely because you have committed a simple, subtle mistake. Every few weeks, I would get that error, and forgetting how I fixed it the previous time, spend another 30 minutes to fix it. Here’s a screenshot of the […]

How to create static class constants in ES6

ES6 brings classes to JavaScript, but some things are not immediately obvious or entirely supported. For instance, there is no obvious way to create static class constants. Here is the simplest way I have found to create constants: class CurrentLocation { static get GEOLOCATION_ERROR() { return ‘GEOLOCATION_ERROR’; } static get GEOLOCATION_REFUSED() { return ‘GEOLOCATION_REFUSED’; } […] does not work on iOS

The recommended method to give a text field focus and select its contents is the following: document.getElementById(‘myInput’).select(); However, this does not work in iOS. The correct way to do it is to use setSelectionRange on an already focused input. var input = document.getElementById(‘myInput’); input.focus(); input.setSelectionRange(0,99999); setSelectionRange will not work on iOS if the element doesn’t […]