mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Cleanup comment node cache for multiple inits.
This commit is contained in:
parent
5d3e976fc0
commit
b5425a0930
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user