<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - JavaScript for-of on HTML Collection in Safari"
href="https://bugs.webkit.org/show_bug.cgi?id=167091">167091</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>JavaScript for-of on HTML Collection in Safari
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>Safari 10
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>macOS 10.12
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>WebKit API
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>email.james.macdonald@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Consider the following code:
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div class="cell">div 1 text</div>
<div class="cell">div 2 text</div>
<div class="cell">div 3 text</div>
<script type="text/javascript">
let list = document.getElementsByClassName("cell")
for(let y of list){
console.log("y:", y)
}
</script>
</body>
</html>
When run in Chrome V55.0, it produces the following console output:
y: <div class="cell">div 1 text</div>
y: <div class="cell">div 2 text</div>
y: <div class="cell">div 3 text</div>
Firefox V50.1 returns similar results as well.
However when run in Safari, this same file generates an error stating
TypeError: y of list is not a function. (In 'y of list', 'y of list' is >undefined).
This appears to be because the value returned to the list variable is not an array, but an HTML collection as described in the following link:
<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=538558">https://bugs.chromium.org/p/chromium/issues/detail?id=538558</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>