Hi All

Had some trouble today with Safari on a crApple. Thought I should pass
it on in case anyone else suffers a similar fate and wants to keep
what hair they have (if any) on their heads.

This is a case of one browser being significantly more strict than
several others. So strict it stops loading the script code when it
incurs this error whereas - rightly or wrongly - most other browsers
cope with the problem which is:

duplicate function names

Now come on, confess, what coder doesn't make liberal use of the old
copy/paste? In this case one section of jQuery code was copied and the
function names were not changed so they became unique. A cut down
example:

$(document).ready(

  function () {

     field1.click(

       function somename () {

         // do something

       }

     );

    field2.click(

       function somename () {

         // do something

       }

     );

  }

);

This code will fail on Safari Mac 2.0.4 (419.3) due to the duplicated
"somename" function however **does not fail** on

Safari Win 3.0.3 (522.15.5)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b2pre) Gecko/
2007110805 Minefield/3.0b2pre
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/
20071025 Firefox/2.0.0.9
IE Win 6.0.2900.2180.xpsp_sp2_gdr.070227-2254
IE Win 7.0.5730.11

For the record I understand that this code should probably break every
time, but since the majority of mainstream browsers do not force this
code to break, consistency is better than idealism in cross browser
coding, I think :)

t a g s

safari-only, fatal, function, duplicate, names, namespaces, mac, 2.0.4

Reply via email to