Skip to content

Commit 2bf9da6

Browse files
committed
Fix key data for NodeList iterations
1 parent 51ff37b commit 2bf9da6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext/dom/dom_iterators.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ static void php_dom_iterator_current_key(zend_object_iterator *iter, zval *key)
123123
{
124124
php_dom_iterator *iterator = (php_dom_iterator *)iter;
125125
zval *object = &iterator->intern.data;
126+
zend_class_entry *ce = Z_OBJCE_P(object);
126127

127-
if (instanceof_function(Z_OBJCE_P(object), dom_nodelist_class_entry)) {
128+
/* Nodelists have the index as a key while named node maps have the name as a key. */
129+
if (instanceof_function(ce, dom_nodelist_class_entry) || instanceof_function(ce, dom_modern_nodelist_class_entry)) {
128130
ZVAL_LONG(key, iter->index);
129131
} else {
130132
dom_object *intern = Z_DOMOBJ_P(&iterator->curobj);

0 commit comments

Comments
 (0)