Cleanup comment node cache for multiple inits.

This commit is contained in:
Dylan Piercey 2018-06-13 16:15:40 -07:00
parent 5d3e976fc0
commit b5425a0930
No known key found for this signature in database
GPG Key ID: DA54E25D5BF13DBE
2 changed files with 9 additions and 1 deletions

View File

@ -254,6 +254,7 @@ function initServerRendered(renderedComponents, doc) {
// and we will remove the end comment node
startNode = endNode = startNodeComment;
} else {
delete serverComponentStartNodes[componentId];
startNodeComment.parentNode.removeChild(startNodeComment);
if (startNode.parentNode === document) {
@ -266,6 +267,7 @@ function initServerRendered(renderedComponents, doc) {
}
if (endNodeComment) {
delete serverComponentEndNodes[componentId];
endNodeComment.parentNode.removeChild(endNodeComment);
}
}

View File

@ -9,8 +9,9 @@ describe(path.basename(__dirname), function() {
var components = window.components;
var html = components.html;
var componentIds = components.componentIds;
var testsTarget = document.getElementById("testsTarget");
document.getElementById("testsTarget").innerHTML = html; // Add the HTML to the DOM
testsTarget.innerHTML = html; // Add the HTML to the DOM
// Initialize the components to bind behavior!
markoComponents.init(componentIds);
@ -45,5 +46,10 @@ describe(path.basename(__dirname), function() {
expect(
window.simpleComponents[1].componentConfig.messageCount
).to.equal(20);
testsTarget.innerHTML = html; // Reset html.
markoComponents.init(componentIds); // Re-initialize the components.
expect(window.simpleComponents.length).to.equal(4);
});
});