File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change 24
24
#include "zend_enum.h"
25
25
#include "php_dom.h"
26
26
#include "namespace_compat.h"
27
- #include "private_data.h"
28
27
#include "internal_helpers.h"
29
28
#include "dom_properties.h"
30
29
#include "token_list.h"
@@ -2034,7 +2033,12 @@ PHP_METHOD(Dom_Element, rename)
2034
2033
2035
2034
/* If we currently have a template but the new element type won't be a template, then throw away the templated content. */
2036
2035
if (is_currently_html_ns && xmlStrEqual (nodep -> name , BAD_CAST "template" ) && !xmlStrEqual (localname , BAD_CAST "template" )) {
2037
- php_dom_remove_templated_content (php_dom_get_private_data (intern ), nodep );
2036
+ php_dom_throw_error_with_message (
2037
+ INVALID_MODIFICATION_ERR ,
2038
+ "It is not possible to rename the template element because it hosts a document fragment" ,
2039
+ /* strict */ true
2040
+ );
2041
+ goto cleanup ;
2038
2042
}
2039
2043
}
2040
2044
Original file line number Diff line number Diff line change @@ -17,13 +17,19 @@ $dom = Dom\HTMLDocument::createFromString($html);
17
17
$ template = $ dom ->body ->firstElementChild ;
18
18
var_dump ($ template ->innerHTML );
19
19
20
- $ template ->rename ($ template ->namespaceURI , 'screwthis ' );
21
- var_dump ($ template ->innerHTML );
22
- $ template ->rename ($ template ->namespaceURI , 'template ' );
20
+ try {
21
+ $ template ->rename ($ template ->namespaceURI , 'screwthis ' );
22
+ } catch (DOMException $ e ) {
23
+ echo $ e ->getMessage (), "\n" ;
24
+ }
25
+
26
+ // These shouldn't be changed!
27
+ var_dump ($ template ->nodeName );
23
28
var_dump ($ template ->innerHTML );
24
29
25
30
?>
26
31
--EXPECT--
27
32
string(16) "a<div>foo</div>b"
28
- string(0) ""
29
- string(0) ""
33
+ It is not possible to rename the template element because it hosts a document fragment
34
+ string(8) "TEMPLATE"
35
+ string(16) "a<div>foo</div>b"
You can’t perform that action at this time.
0 commit comments