mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Add missing cache invalidation for innerHTML (#16652)
* Add test with wrong output * Add missing cache invalidation for innerHTML
This commit is contained in:
@@ -359,6 +359,9 @@ zend_result dom_element_inner_html_write(dom_object *obj, zval *newval)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZEND_ASSERT(obj->document != NULL);
|
||||||
|
php_libxml_invalidate_node_list_cache(obj->document);
|
||||||
|
|
||||||
dom_remove_all_children(context_node);
|
dom_remove_all_children(context_node);
|
||||||
return php_dom_pre_insert(obj->document, fragment, context_node, NULL) ? SUCCESS : FAILURE;
|
return php_dom_pre_insert(obj->document, fragment, context_node, NULL) ? SUCCESS : FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
--TEST--
|
||||||
|
$innerHTML cache invalidation
|
||||||
|
--EXTENSIONS--
|
||||||
|
dom
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$dom = Dom\XMLDocument::createFromString('<root><a/><a/><a/></root>');
|
||||||
|
$els = $dom->getElementsByTagName('a');
|
||||||
|
var_dump($els[0]->tagName);
|
||||||
|
|
||||||
|
$dom->documentElement->innerHTML = '<b/>';
|
||||||
|
|
||||||
|
echo $dom->saveXML(), "\n";
|
||||||
|
var_dump($els);
|
||||||
|
var_dump($els[0]?->tagName);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
string(1) "a"
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<root><b/></root>
|
||||||
|
object(Dom\HTMLCollection)#2 (1) {
|
||||||
|
["length"]=>
|
||||||
|
int(0)
|
||||||
|
}
|
||||||
|
NULL
|
||||||
Reference in New Issue
Block a user