Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: github/template-parts
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.6.3
Choose a base ref
...
head repository: github/template-parts
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.7.0
Choose a head ref
  • 2 commits
  • 5 files changed
  • 2 contributors

Commits on Dec 13, 2024

  1. Implement InnerTemplatePart class

    The [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
    seanpdoyle committed Dec 13, 2024
    Configuration menu
    Copy the full SHA
    8aba104 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #75 from seanpdoyle/inner-template-part

    Implement `InnerTemplatePart` class
    keithamus authored Dec 13, 2024
    Configuration menu
    Copy the full SHA
    187af82 View commit details
    Browse the repository at this point in the history
Loading