-
Notifications
You must be signed in to change notification settings - Fork 266
Description
I was attempting to deserialize an HTML5 document, make some slight modifications, and then reserialize and output it. This document contained <template /> tags (specifically declarative shadow DOM, but I don't think that matters). I noticed that these <template /> tags have their content dropped in the output. I made a minimal reproduction here. It attempts to deserialize:
<!DOCTYPE html>
<html>
<head>
<title>Template Element Test</title>
<meta charset="utf8">
</head>
<body>
<template>
<div>Hello, World!</div>
</template>
</body>
</html>And then reserialize it back out without modification, but instead I get:
<!DOCTYPE html>
<html>
<head>
<title>Template Element Test</title>
<meta charset="utf8">
</head>
<body>
<template></template>
</body>
</html>Note the missing <div>Hello, World!</div> from the <template /> content.
I took a quick look at the source, and I suspect that the serializer is not aware of <template /> elements as a special case which don't contain children, but have a special field holding their contents. I'm guessing it will need some if element.is_template() { write(element.get_template_contents()); }. I'm not entirely sure where that would go though.