dasmurphy / base2

Automatically exported from code.google.com/p/base2
0 stars 1 forks source link

Safari: forEach has problems with childNodes #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The forEach-function doesn't work nicely with a DOM NodeList, because the
typeof a childNodes collection is reported a function.

Testcase:
typeof document.body.childNodes=="function"

Workaround:
Because of that, the forEach.Function variant of forEach is used. A
workaround is to use the array-variant directly:

forEach.Array(document.body.childNodes...

Is there a solution? Like giving the '''typeof object.length == "number"'''
test a higher priority?

Tested Safari: Version 2.0.4 (419.3)
Webkit revision 24064 (dd2007-07-06) has the same behaviour

Original issue reported on code.google.com by doeke.zanstra@gmail.com on 6 Jul 2007 at 7:07

GoogleCodeExporter commented 9 years ago
Same goes for Safari Version 3.0.2 (522.12)

Original comment by doek...@gmail.com on 6 Jul 2007 at 7:31

GoogleCodeExporter commented 9 years ago
Filed at webkit bugzilla: http://bugs.webkit.org/show_bug.cgi?id=14547

Original comment by doeke.zanstra@gmail.com on 7 Jul 2007 at 11:45

GoogleCodeExporter commented 9 years ago
Promoting the 'typeof object.length == "number"' clause will not will work as
functions also have a length property (as do strings).

Original comment by dean.edw...@gmail.com on 10 Jul 2007 at 2:54

GoogleCodeExporter commented 9 years ago
I amended the instanceOf() function to look for object.call. The global forEach
function now uses instanceOf() to detect functions instead of typeof.

Original comment by dean.edw...@gmail.com on 10 Jul 2007 at 6:40

GoogleCodeExporter commented 9 years ago

Original comment by doek...@gmail.com on 14 Jul 2007 at 7:12