This week we noticed that the user administration of our time tracking app timr behaved different on Safari.
The variable assignedGroupTable was defined some lines before with
and the condition should be false on the first call of that function, but in Safari it was true. The debugger showed that the value of assignedGroupTable seemed to be a DIV – there was a DIV in the page with an ID assignedGroupTable, but it had never been assigned to that variable. It seemed like Safari automatically assigned the DIV, with the ID, that was equal to the variable name, to the variable.
So why did our code behave different in Safari? I adapted the example the article uses to find the difference in the behaviour of Safari.
On modern browsers (Chrome 29, Safari 6, Firefox 22, IE 10) this logs the button element to the console. But when making a small change the browsers behave different:
In Chrome, Firefox and IE this logs undefined to the console, only Safari still logs the button element!
There were two ways to fix our problem:
- rename the ID of the DIV or the variable so that they differ
Wo decided to do the second because it required fewer changes.