DOMDocumentFragment ignoring class attribute [CLOSED]


#1

The element ‘my_grid_layout’ shows up properly when defined as below. When instead of explicitly declaring it, I add it via startup.js, the css styling based on class fails, while styling on tag/element succeeds. In the debugger if I “edit HTML” on my_grid_layout and make a trivial whitespace change, it gets fixed. It looks like Electron or Chrome may not be recomputing styles when it should?

To give a little more info - I am loading text files into document fragments and then including those in the DOM. This fails as described. When I instead include the templates directly in the HTML and clone from there, the styles show up properly. Shouldn’t the style be recomputed on children being added to a node with CSS from a document fragment without CSS?

<!DOCTYPE html>
<html>
	<head>		
		<link rel='stylesheet' type='text/css' href='mine.css'>
		<style type='text/css'>
		</style>
	</head>
	<body id='body'>
		<div id='my_grid_layout' class='width100 height100 topview' >
			<div class='A'>A</div>
			<div class='B'>B</div>
		</div>
	</body>
</html>
<script type='text/javascript' src='./startup.js'></script>

#2

I would delete this post because it’s not an issue with Electron, but I can’t seem to find the option to do so.

Anyway, when switching to read templates from external files, I used DOMParser.parseFromString(templateText,“text/xml”). I should have used “text/html” instead. Either option gives results that look very similar in terms of node hierachy, but with the xml option, event handlers and styling aren’t handled as far as I can tell.