-
Notifications
You must be signed in to change notification settings - Fork 15
Comparing changes
Open a pull request
base repository: github/template-parts
base: v0.6.0
head repository: github/template-parts
compare: main
- 13 commits
- 10 files changed
- 3 contributors
Commits on Dec 3, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 38c304a - Browse repository at this point
Copy the full SHA 38c304aView commit details
Commits on Dec 9, 2024
-
Accept
Node
values as Template PartsRelated to [#62][] (see [3.2. Template Parts and Custom Template Process Callback][]) Follow-up to [#65][] While the changes made in [#65][] improved support for `Element` parts, the expansion from `string` to `Element | string` was not broadened enough. While all `Element` instances are DOM Nodes, not all DOM Nodes are `Element` instances. For example, this change enables support for [DocumentFragment][] instances (generated from classes like [Range][] or properties like [HTMLTemplateElement.content][]), where prior support resulted in templating the `[object DocumentFragment]` text string instead of the fragment's `Node` instances. [#62]: #62 [3.2. Template Parts and Custom Template Process Callback]: https://github.com/WICG/webcomponents/blob/159b1600bab02fe9cd794825440a98537d53b389/proposals/Template-Instantiation.md#32-template-parts-and-custom-template-process-callback [#65]: #65 [DocumentFragment]: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment [HTMLTemplateElement.content]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content
Configuration menu - View commit details
-
Copy full SHA for 28f61c6 - Browse repository at this point
Copy the full SHA 28f61c6View commit details -
Merge pull request #73 from seanpdoyle/accept-node-template-parts
Accept `Node` values as Template Parts
Configuration menu - View commit details
-
Copy full SHA for 0678eb7 - Browse repository at this point
Copy the full SHA 0678eb7View commit details
Commits on Dec 13, 2024
-
Change
NodeTemplatePart.replace
type signatureReplace `ChildNode` with `Node` in `NodeTemplatePart.replace(...nodes)` signature. According to the [3.2. Template Parts and Custom Template Process Callback][] section of the specification, the `NodeTemplatePart` interface declares `replace(...nodes: Array<string | Node>)`: ```typescript interface NodeTemplatePart : TemplatePart { readonly attribute ContainerNode parentNode; readonly attribute Node? previousSibling; readonly attribute Node? nextSibling; [NewObject] readonly NodeList replacementNodes; void replace((Node or DOMString)... nodes); void replaceHTML(DOMString html); } ``` This commit changes the type signature and adds coverage for replacing a `NodeTemplatePart` with a `DocumentFragment` instance. [3.2. Template Parts and Custom Template Process Callback]: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Template-Instantiation.md#32-template-parts-and-custom-template-process-callback
Configuration menu - View commit details
-
Copy full SHA for 79b4ee6 - Browse repository at this point
Copy the full SHA 79b4ee6View commit details -
Merge pull request #74 from seanpdoyle/replace-child-node
Change `NodeTemplatePart.replace` type signature
Configuration menu - View commit details
-
Copy full SHA for 743b970 - Browse repository at this point
Copy the full SHA 743b970View commit details -
Implement
InnerTemplatePart
classThe [3.3. Conditionals and Loops using Nested Templates][] section of the specification mentions special treatment of `<template>` elements with `[directive]` and `[expression]` attributes within `<template>` elements. They're to be treated as parts of their own, represented by an `InnerTemplatePart` interface: ```ts InnerTemplatePart : NodeTemplatePart { HTMLTemplateElement template; attribute DOMString directive; } ``` This commit introduces that class, along with special treatment whenever collecting parts from an `HTMLTemplateElement` that also has a `[directive]` attribute. To demonstrate their utility, this commit includes a test case that exercises a naive implementation of an `if` conditional. As a caveat, it's worth mentioning that the specification proposal explicitly mentions the nuance surrounding looping and conditional rendering: > this approach involves the template process callback cloning template > parts along with other nodes, or let author scripts manually specify to > which element each template part belongs. This quickly becomes an > entangled mess because now we could have multiple template parts that > refer to a single DOM location or an attribute, and we have to start > dealing with multiple template parts trying to override one another even > though there is no good use case for such a behavior. > > We like the idea of supporting very basic control flow such as `if` and > `foreach` in the default template process callback but we don't think it's > a show stopper if the default template process callback didn't support > them in the initial cut. This commit does not aim to introduce a canonical implementation for conditionals or looping, but it should enable a change like that in the future. [3.3. Conditionals and Loops using Nested Templates]: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Template-Instantiation.md#33-conditionals-and-loops-using-nested-templates
Configuration menu - View commit details
-
Copy full SHA for 8aba104 - Browse repository at this point
Copy the full SHA 8aba104View commit details -
Merge pull request #75 from seanpdoyle/inner-template-part
Implement `InnerTemplatePart` class
Configuration menu - View commit details
-
Copy full SHA for 187af82 - Browse repository at this point
Copy the full SHA 187af82View commit details -
Add test coverage for both built-in processor strategies
Existing test coverage lacked tests that exercised _both_ the default `processPropertyIdentity` strategy alongside the optional `propertyIdentityOrBooleanAttribute` strategy. This commit doesn't contain any implementation changes, but broadens test coverage instead.
Configuration menu - View commit details
-
Copy full SHA for 4e442b7 - Browse repository at this point
Copy the full SHA 4e442b7View commit details
Commits on Dec 14, 2024
-
Add an entry to the `src/index.ts` to export the new `InnerTemplatePart`. Since consumers are most likely to import `TemplateInstance`, change the `test/template-instance.ts` test file to import properties from the module in a way that more closely resembles the end-user consumer experience.
Configuration menu - View commit details
-
Copy full SHA for 8e84757 - Browse repository at this point
Copy the full SHA 8e84757View commit details -
Merge pull request #78 from seanpdoyle/exports
Export `InnerTemplatePart`
Configuration menu - View commit details
-
Copy full SHA for 4e11d16 - Browse repository at this point
Copy the full SHA 4e11d16View commit details
Commits on Dec 15, 2024
-
Merge pull request #77 from seanpdoyle/add-test-coverage
Add test coverage for both built-in processor strategies
Configuration menu - View commit details
-
Copy full SHA for 65aa8f5 - Browse repository at this point
Copy the full SHA 65aa8f5View commit details
Commits on Jan 10, 2025
-
Configuration menu - View commit details
-
Copy full SHA for b98aa52 - Browse repository at this point
Copy the full SHA b98aa52View commit details
Commits on Jan 14, 2025
-
Configuration menu - View commit details
-
Copy full SHA for 68c4a79 - Browse repository at this point
Copy the full SHA 68c4a79View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff v0.6.0...main