DEV: Add missing decorateCookedElement id (#20330)

Fixes "`decorateCooked` should be supplied with an `id` option to avoid memory leaks in test mode. The id will be used to ensure the decorator is only applied once." warnings
This commit is contained in:
Jarek Radosz 2023-02-16 13:58:23 +01:00 committed by GitHub
parent 7cc0c59469
commit c541bd05a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,30 +23,34 @@ acceptance("Acceptance | decorateCookedElement", function () {
DemoComponent
);
withPluginApi(0, (api) => {
api.decorateCookedElement((cooked, helper) => {
if (helper.getModel().post_number !== 1) {
return;
}
cooked.innerHTML =
"<div class='existing-wrapper'>Some existing content</div>";
withPluginApi(
0,
(api) => {
api.decorateCookedElement((cooked, helper) => {
if (helper.getModel().post_number !== 1) {
return;
}
cooked.innerHTML =
"<div class='existing-wrapper'>Some existing content</div>";
// Create new wrapper element and append
cooked.appendChild(
// Create new wrapper element and append
cooked.appendChild(
helper.renderGlimmer(
"div.glimmer-wrapper",
hbs`<@data.component />`,
{ component: DemoComponent }
)
);
// Append to existing element
helper.renderGlimmer(
"div.glimmer-wrapper",
hbs`<@data.component />`,
{ component: DemoComponent }
)
);
// Append to existing element
helper.renderGlimmer(
cooked.querySelector(".existing-wrapper"),
hbs` with more content from glimmer`
);
});
});
cooked.querySelector(".existing-wrapper"),
hbs` with more content from glimmer`
);
});
},
{ id: "render-glimmer-test" }
);
await visit("/t/internationalization-localization/280");