Skip to content

Improve morph support for <template> elements#49

Merged
1cg merged 1 commit into
bigskysoftware:mainfrom
seanpdoyle:morph-template-elements
Oct 12, 2024
Merged

Improve morph support for <template> elements#49
1cg merged 1 commit into
bigskysoftware:mainfrom
seanpdoyle:morph-template-elements

Conversation

@seanpdoyle

@seanpdoyle seanpdoyle commented Apr 12, 2024

Copy link
Copy Markdown
Contributor

Closes #15

When morphing <template> elements, treat the DocumentFragment
instances returned from the HTMLTemplateElement.content properties
as morphChildren methods' newParent and oldParent variables.

That way, descendant nodes can be iterated across the
connected-disconnected boundary.

Comment thread dist/idiomorph.js
*/
function ignoreValueOfActiveElement(possibleActiveElement, ctx) {
return ctx.ignoreActiveValue && possibleActiveElement === document.activeElement;
return ctx.ignoreActiveValue && possibleActiveElement === document.activeElement && possibleActiveElement !== document.body;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1cg this line (along with the rest of the generated portion of the diff) might be best merged as part of #47 (ahead of this PR).

@caleb

caleb commented Aug 21, 2024

Copy link
Copy Markdown

This would be very helpful to me. Right now I need to use a stimulus controller to copy the template contents on turbo:morph-element.

@seanpdoyle

Copy link
Copy Markdown
Contributor Author

@1cg are you able to review these changes? The crucial part of this diff is in the src/ and test/ directories. The rest of the diff includes changes in services of providing passing test coverage. They're proposed by individual related pull requests:

According to #25 (comment), I believe those changes would be covered by your process prior to cutting a new release:

Can you undo the changes to /dist? I'll generate those when we do the next release

If that's a requirement for this diff, I'm happy to exclude dist/ changes and only include src/ and test/.

@1cg

1cg commented Oct 12, 2024

Copy link
Copy Markdown
Contributor

hi @seanpdoyle this looks good to me, happy to merge

can I ask you to revert the changes to /dist for me and I'll pull it in? thank you!

Closes [bigskysoftware#15][]

When morphing `<template>` elements, treat the [DocumentFragment][]
instances returned from the [HTMLTemplateElement.content][] properties
as `morphChildren` methods' `newParent` and `oldParent` variables.

That way, descendant nodes can be iterated across the
connected-disconnected boundary.

[bigskysoftware#15]: bigskysoftware#15
[DocumentFragment]: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
[HTMLTemplateElement.content]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content
@seanpdoyle
seanpdoyle force-pushed the morph-template-elements branch from dc8816e to a530659 Compare October 12, 2024 19:30
@seanpdoyle

Copy link
Copy Markdown
Contributor Author

@1cg thank you for the review. I've reverted the changes to dist/.

@1cg
1cg merged commit 831420e into bigskysoftware:main Oct 12, 2024
@seanpdoyle
seanpdoyle deleted the morph-template-elements branch October 12, 2024 23:51
@scuml scuml mentioned this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Template contents are not replaced on merge

3 participants